[gimp/gimp-2-10] app: add color index label to the palette editor.



commit cc6e21e05b5ce3d115e1166da0e69d40ca69a063
Author: Sergio Jiménez Herena <sergio jimenez herena gmail com>
Date:   Fri Sep 14 20:41:50 2018 +0200

    app: add color index label to the palette editor.

 app/widgets/gimppaletteeditor.c | 16 ++++++++++++++++
 app/widgets/gimppaletteeditor.h |  3 ++-
 2 files changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/app/widgets/gimppaletteeditor.c b/app/widgets/gimppaletteeditor.c
index 0d89867770..4cbf7aceed 100644
--- a/app/widgets/gimppaletteeditor.c
+++ b/app/widgets/gimppaletteeditor.c
@@ -243,6 +243,13 @@ gimp_palette_editor_init (GimpPaletteEditor *editor)
   gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0);
   gtk_widget_show (hbox);
 
+  /*  The color index number  */
+  editor->index_label = gtk_label_new ("####");
+  gtk_box_pack_start (GTK_BOX (hbox), editor->index_label, FALSE, FALSE, 0);
+  gimp_label_set_attributes (GTK_LABEL (editor->index_label),
+                             PANGO_ATTR_FAMILY, "Monospace", -1);
+  gtk_widget_show (editor->index_label);
+  
   /*  The color name entry  */
   editor->color_name = gtk_entry_new ();
   gtk_box_pack_start (GTK_BOX (hbox), editor->color_name, TRUE, TRUE, 0);
@@ -771,8 +778,17 @@ palette_editor_entry_selected (GimpPaletteView   *view,
 
   if (editor->color != entry)
     {
+      gchar index[8];
+      
       editor->color = entry;
 
+      if (entry)
+        g_snprintf (index, sizeof (index), "%04i", entry->position);
+      else
+        g_snprintf (index, sizeof (index), "####");
+      
+      gtk_label_set_text (GTK_LABEL (editor->index_label), index);
+
       g_signal_handlers_block_by_func (editor->color_name,
                                        palette_editor_color_name_changed,
                                        editor);
diff --git a/app/widgets/gimppaletteeditor.h b/app/widgets/gimppaletteeditor.h
index 8058d87cd9..4c5febc38c 100644
--- a/app/widgets/gimppaletteeditor.h
+++ b/app/widgets/gimppaletteeditor.h
@@ -38,6 +38,7 @@ struct _GimpPaletteEditor
 
   GtkWidget        *view;
 
+  GtkWidget        *index_label;
   GtkWidget        *color_name;
   GtkAdjustment    *columns_adj;
 
@@ -45,7 +46,7 @@ struct _GimpPaletteEditor
 
   GimpPaletteEntry *color;
 
-  gfloat            zoom_factor;  /* range from 0.1 to 4.0 */
+  gdouble           zoom_factor;  /* range from 0.1 to 4.0 */
   gint              col_width;
   gint              last_width;
   gint              columns;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]