[gimp/gtk3-port: 160/233] libgimpwidgets: move GimpColorProfileComboBox::dialog to private



commit 5a6444fe27e9cbe04b608d1323f9b7d94bfefe8b
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jan 3 12:58:57 2011 +0100

    libgimpwidgets: move GimpColorProfileComboBox::dialog to private

 libgimpwidgets/gimpcolorprofilecombobox.c |   73 +++++++++++++----------------
 libgimpwidgets/gimpcolorprofilecombobox.h |    4 +-
 2 files changed, 34 insertions(+), 43 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolorprofilecombobox.c b/libgimpwidgets/gimpcolorprofilecombobox.c
index 40e9b37..01414e1 100644
--- a/libgimpwidgets/gimpcolorprofilecombobox.c
+++ b/libgimpwidgets/gimpcolorprofilecombobox.c
@@ -51,15 +51,17 @@ enum
 };
 
 
-typedef struct
+typedef struct _GimpColorProfileComboBoxPrivate GimpColorProfileComboBoxPrivate;
+
+struct _GimpColorProfileComboBoxPrivate
 {
+  GtkWidget   *dialog;
   GtkTreePath *last_path;
-} GimpColorProfileComboBoxPrivate;
+};
 
-#define GIMP_COLOR_PROFILE_COMBO_BOX_GET_PRIVATE(obj) \
-  G_TYPE_INSTANCE_GET_PRIVATE (obj, \
-                               GIMP_TYPE_COLOR_PROFILE_COMBO_BOX, \
-                               GimpColorProfileComboBoxPrivate)
+#define GET_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE (obj, \
+                                                      GIMP_TYPE_COLOR_PROFILE_COMBO_BOX, \
+                                                      GimpColorProfileComboBoxPrivate)
 
 
 static void  gimp_color_profile_combo_box_finalize     (GObject      *object);
@@ -156,26 +158,21 @@ gimp_color_profile_combo_box_init (GimpColorProfileComboBox *combo_box)
 static void
 gimp_color_profile_combo_box_finalize (GObject *object)
 {
-  GimpColorProfileComboBox        *combo;
-  GimpColorProfileComboBoxPrivate *priv;
+  GimpColorProfileComboBoxPrivate *private = GET_PRIVATE (object);
 
-  combo = GIMP_COLOR_PROFILE_COMBO_BOX (object);
-
-  if (combo->dialog)
+  if (private->dialog)
     {
-      if (GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG (combo->dialog))
-        gtk_widget_destroy (combo->dialog);
+      if (GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG (private->dialog))
+        gtk_widget_destroy (private->dialog);
 
-      g_object_unref (combo->dialog);
-      combo->dialog = NULL;
+      g_object_unref (private->dialog);
+      private->dialog = NULL;
     }
 
-  priv = GIMP_COLOR_PROFILE_COMBO_BOX_GET_PRIVATE (combo);
-
-  if (priv->last_path)
+  if (private->last_path)
     {
-      gtk_tree_path_free (priv->last_path);
-      priv->last_path = NULL;
+      gtk_tree_path_free (private->last_path);
+      private->last_path = NULL;
     }
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -187,22 +184,22 @@ gimp_color_profile_combo_box_set_property (GObject      *object,
                                            const GValue *value,
                                            GParamSpec   *pspec)
 {
-  GimpColorProfileComboBox *combo_box = GIMP_COLOR_PROFILE_COMBO_BOX (object);
+  GimpColorProfileComboBoxPrivate *private = GET_PRIVATE (object);
 
   switch (property_id)
     {
     case PROP_DIALOG:
-      g_return_if_fail (combo_box->dialog == NULL);
-      combo_box->dialog = g_value_dup_object (value);
+      g_return_if_fail (private->dialog == NULL);
+      private->dialog = g_value_dup_object (value);
 
-      if (GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG (combo_box->dialog))
-        g_signal_connect (combo_box->dialog, "response",
+      if (GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG (private->dialog))
+        g_signal_connect (private->dialog, "response",
                           G_CALLBACK (gimp_color_profile_combo_dialog_response),
-                          combo_box);
+                          object);
       break;
 
     case PROP_MODEL:
-      gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box),
+      gtk_combo_box_set_model (GTK_COMBO_BOX (object),
                                g_value_get_object (value));
       break;
 
@@ -218,17 +215,17 @@ gimp_color_profile_combo_box_get_property (GObject    *object,
                                            GValue     *value,
                                            GParamSpec *pspec)
 {
-  GimpColorProfileComboBox *combo_box = GIMP_COLOR_PROFILE_COMBO_BOX (object);
+  GimpColorProfileComboBoxPrivate *private = GET_PRIVATE (object);
 
   switch (property_id)
     {
     case PROP_DIALOG:
-      g_value_set_object (value, combo_box->dialog);
+      g_value_set_object (value, private->dialog);
       break;
 
     case PROP_MODEL:
       g_value_set_object (value,
-                          gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)));
+                          gtk_combo_box_get_model (GTK_COMBO_BOX (object)));
       break;
 
     default:
@@ -240,11 +237,10 @@ gimp_color_profile_combo_box_get_property (GObject    *object,
 static void
 gimp_color_profile_combo_box_changed (GtkComboBox *combo)
 {
-  GimpColorProfileComboBoxPrivate *priv;
-
-  GtkTreeModel *model = gtk_combo_box_get_model (combo);
-  GtkTreeIter   iter;
-  gint          type;
+  GimpColorProfileComboBoxPrivate *priv  = GET_PRIVATE (combo);
+  GtkTreeModel                    *model = gtk_combo_box_get_model (combo);
+  GtkTreeIter                      iter;
+  gint                             type;
 
   if (! gtk_combo_box_get_active_iter (combo, &iter))
     return;
@@ -253,20 +249,17 @@ gimp_color_profile_combo_box_changed (GtkComboBox *combo)
                       GIMP_COLOR_PROFILE_STORE_ITEM_TYPE, &type,
                       -1);
 
-  priv = GIMP_COLOR_PROFILE_COMBO_BOX_GET_PRIVATE (combo);
-
   switch (type)
     {
     case GIMP_COLOR_PROFILE_STORE_ITEM_DIALOG:
       {
-        GtkWidget *dialog = GIMP_COLOR_PROFILE_COMBO_BOX (combo)->dialog;
         GtkWidget *parent = gtk_widget_get_toplevel (GTK_WIDGET (combo));
 
         if (GTK_IS_WINDOW (parent))
-          gtk_window_set_transient_for (GTK_WINDOW (dialog),
+          gtk_window_set_transient_for (GTK_WINDOW (priv->dialog),
                                         GTK_WINDOW (parent));
 
-        gtk_window_present (GTK_WINDOW (dialog));
+        gtk_window_present (GTK_WINDOW (priv->dialog));
 
         if (priv->last_path &&
             gtk_tree_model_get_iter (model, &iter, priv->last_path))
diff --git a/libgimpwidgets/gimpcolorprofilecombobox.h b/libgimpwidgets/gimpcolorprofilecombobox.h
index 31f7bc5..4861ff4 100644
--- a/libgimpwidgets/gimpcolorprofilecombobox.h
+++ b/libgimpwidgets/gimpcolorprofilecombobox.h
@@ -40,9 +40,7 @@ typedef struct _GimpColorProfileComboBoxClass  GimpColorProfileComboBoxClass;
 
 struct _GimpColorProfileComboBox
 {
-  GtkComboBox       parent_instance;
-
-  GtkWidget        *dialog;
+  GtkComboBox  parent_instance;
 };
 
 struct _GimpColorProfileComboBoxClass


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