app: add color index label to the palette editor.

This commit is contained in:
Sergio Jiménez Herena 2018-06-18 14:16:36 +02:00 committed by Michael Natterer
parent de6f469c16
commit ea27fd912c
2 changed files with 16 additions and 1 deletions

View File

@ -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);
@ -764,11 +771,18 @@ palette_editor_entry_selected (GimpPaletteView *view,
GimpPaletteEditor *editor)
{
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor);
gchar *index = NULL;
if (editor->color != entry)
{
editor->color = entry;
if (entry)
index = g_strdup_printf("%04i", entry->position);
gtk_label_set_text (GTK_LABEL (editor->index_label),
entry ? index : "####");
g_free (index);
g_signal_handlers_block_by_func (editor->color_name,
palette_editor_color_name_changed,
editor);

View File

@ -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;