[gimp/gimp-2-8] libgimpwidgets: init GimpColorHexEntry's text after construction



commit 0eed2308b96e81b1084c6d36d2b50813d166026e
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.
    
    (cherry picked from commit 1e9898cb6bb623b3abd2ee503cc83d991243cb7e)

 libgimpwidgets/gimpcolorhexentry.c |   30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolorhexentry.c b/libgimpwidgets/gimpcolorhexentry.c
index a107393..929d8ba 100644
--- a/libgimpwidgets/gimpcolorhexentry.c
+++ b/libgimpwidgets/gimpcolorhexentry.c
@@ -57,13 +57,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)
@@ -76,6 +78,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),
@@ -85,7 +89,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
@@ -140,8 +146,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);
@@ -154,6 +158,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]