[gimp] libgimpwidgets: init GimpColorHexEntry's text after construction



commit 722abb5c82f101c58bbe07947528f1d466ca5b20
Author: Ell <ell_se yahoo com>
Date:   Wed Aug 9 10:48:37 2017 -0400

    libgimpwidgets: init GimpColorHexEntry's text after construction
    
    Initialize GimpColorHexEntry's text (to "000000") in constructed(),
    instead of init().  Otherwise, it gets cleared during construction,
    so that color entries set initially to black are empty.

 libgimpwidgets/gimpcolorhexentry.c |   30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolorhexentry.c b/libgimpwidgets/gimpcolorhexentry.c
index 6f60568..7393506 100644
--- a/libgimpwidgets/gimpcolorhexentry.c
+++ b/libgimpwidgets/gimpcolorhexentry.c
@@ -58,13 +58,15 @@ enum
 };
 
 
-static gboolean  gimp_color_hex_entry_events     (GtkWidget          *widget,
-                                                  GdkEvent           *event);
+static void      gimp_color_hex_entry_constructed (GObject            *object);
 
-static gboolean  gimp_color_hex_entry_matched    (GtkEntryCompletion *completion,
-                                                  GtkTreeModel       *model,
-                                                  GtkTreeIter        *iter,
-                                                  GimpColorHexEntry  *entry);
+static gboolean  gimp_color_hex_entry_events      (GtkWidget          *widget,
+                                                   GdkEvent           *event);
+
+static gboolean  gimp_color_hex_entry_matched     (GtkEntryCompletion *completion,
+                                                   GtkTreeModel       *model,
+                                                   GtkTreeIter        *iter,
+                                                   GimpColorHexEntry  *entry);
 
 
 G_DEFINE_TYPE (GimpColorHexEntry, gimp_color_hex_entry, GTK_TYPE_ENTRY)
@@ -77,6 +79,8 @@ static guint entry_signals[LAST_SIGNAL] = { 0 };
 static void
 gimp_color_hex_entry_class_init (GimpColorHexEntryClass *klass)
 {
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
   entry_signals[COLOR_CHANGED] =
     g_signal_new ("color-changed",
                   G_TYPE_FROM_CLASS (klass),
@@ -86,7 +90,9 @@ gimp_color_hex_entry_class_init (GimpColorHexEntryClass *klass)
                   g_cclosure_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
 
-  klass->color_changed = NULL;
+  object_class->constructed = gimp_color_hex_entry_constructed;
+
+  klass->color_changed      = NULL;
 }
 
 static void
@@ -141,8 +147,6 @@ gimp_color_hex_entry_init (GimpColorHexEntry *entry)
   gtk_entry_set_completion (GTK_ENTRY (entry), completion);
   g_object_unref (completion);
 
-  gtk_entry_set_text (GTK_ENTRY (entry), "000000");
-
   g_signal_connect (entry, "focus-out-event",
                     G_CALLBACK (gimp_color_hex_entry_events),
                     NULL);
@@ -155,6 +159,14 @@ gimp_color_hex_entry_init (GimpColorHexEntry *entry)
                     entry);
 }
 
+static void
+gimp_color_hex_entry_constructed (GObject *object)
+{
+  G_OBJECT_CLASS (parent_class)->constructed (object);
+
+  gtk_entry_set_text (GTK_ENTRY (object), "000000");
+}
+
 /**
  * gimp_color_hex_entry_new:
  *


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