[gimp/gimp-2-10] libgimpwidgets: declare GimpHintBox with public instance and class



commit 65cda467d6d1c7f91d5cf89ee5bf194ea922dddb
Author: Michael Natterer <mitch gimp org>
Date:   Wed Jul 24 15:11:51 2019 +0200

    libgimpwidgets: declare GimpHintBox with public instance and class
    
    like all other objects, so gtk-doc doesn't cripple its docs.
    
    (cherry picked from commit f67e6073954d3130c9d68f2d3c29caab8dbc0e97)

 libgimpwidgets/gimphintbox.c      | 69 ++++++++++++++-------------------------
 libgimpwidgets/gimphintbox.h      | 34 ++++++++++++++++++-
 libgimpwidgets/gimpwidgetstypes.h |  1 +
 3 files changed, 59 insertions(+), 45 deletions(-)
---
diff --git a/libgimpwidgets/gimphintbox.c b/libgimpwidgets/gimphintbox.c
index 5091f77f23..f1e22919a4 100644
--- a/libgimpwidgets/gimphintbox.c
+++ b/libgimpwidgets/gimphintbox.c
@@ -36,20 +36,6 @@
  **/
 
 
-typedef GtkBoxClass  GimpHintBoxClass;
-
-typedef struct
-{
-  GtkBox    parent_instance;
-
-  gchar    *icon_name;
-  gchar    *stock_id;
-  gchar    *hint;
-} GimpHintBox;
-
-#define GIMP_HINT_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_HINT_BOX, GimpHintBox))
-
-
 enum
 {
   PROP_0,
@@ -58,6 +44,13 @@ enum
   PROP_HINT
 };
 
+struct _GimpHintBoxPrivate
+{
+  gchar *icon_name;
+  gchar *stock_id;
+  gchar *hint;
+};
+
 
 static void   gimp_hint_box_constructed  (GObject      *object);
 static void   gimp_hint_box_finalize     (GObject      *object);
@@ -71,7 +64,7 @@ static void   gimp_hint_box_get_property (GObject      *object,
                                           GParamSpec   *pspec);
 
 
-G_DEFINE_TYPE (GimpHintBox, gimp_hint_box, GTK_TYPE_BOX)
+G_DEFINE_TYPE_WITH_PRIVATE (GimpHintBox, gimp_hint_box, GTK_TYPE_BOX)
 
 #define parent_class gimp_hint_box_parent_class
 
@@ -114,6 +107,8 @@ gimp_hint_box_class_init (GimpHintBoxClass *klass)
 static void
 gimp_hint_box_init (GimpHintBox *box)
 {
+  box->priv = gimp_hint_box_get_instance_private (box);
+
   gtk_orientable_set_orientation (GTK_ORIENTABLE (box),
                                   GTK_ORIENTATION_HORIZONTAL);
 }
@@ -129,14 +124,14 @@ gimp_hint_box_constructed (GObject *object)
 
   gtk_box_set_spacing (GTK_BOX (box), 12);
 
-  if (box->icon_name)
+  if (box->priv->icon_name)
     {
-      image = gtk_image_new_from_icon_name (box->icon_name,
+      image = gtk_image_new_from_icon_name (box->priv->icon_name,
                                             GTK_ICON_SIZE_DIALOG);
     }
-  else if (box->stock_id)
+  else if (box->priv->stock_id)
     {
-      image = gtk_image_new_from_stock (box->stock_id,
+      image = gtk_image_new_from_stock (box->priv->stock_id,
                                         GTK_ICON_SIZE_DIALOG);
     }
 
@@ -147,7 +142,7 @@ gimp_hint_box_constructed (GObject *object)
     }
 
   label = g_object_new (GTK_TYPE_LABEL,
-                        "label",   box->hint,
+                        "label",   box->priv->hint,
                         "wrap",    TRUE,
                         "justify", GTK_JUSTIFY_LEFT,
                         "xalign",  0.0,
@@ -166,23 +161,9 @@ gimp_hint_box_finalize (GObject *object)
 {
   GimpHintBox *box = GIMP_HINT_BOX (object);
 
-  if (box->icon_name)
-    {
-      g_free (box->icon_name);
-      box->icon_name = NULL;
-    }
-
-  if (box->stock_id)
-    {
-      g_free (box->stock_id);
-      box->stock_id = NULL;
-    }
-
-  if (box->hint)
-    {
-      g_free (box->hint);
-      box->hint = NULL;
-    }
+  g_clear_pointer (&box->priv->icon_name, g_free);
+  g_clear_pointer (&box->priv->stock_id,  g_free);
+  g_clear_pointer (&box->priv->hint,      g_free);
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -198,15 +179,15 @@ gimp_hint_box_set_property (GObject      *object,
   switch (property_id)
     {
     case PROP_ICON_NAME:
-      box->icon_name = g_value_dup_string (value);
+      box->priv->icon_name = g_value_dup_string (value);
       break;
 
     case PROP_STOCK_ID:
-      box->stock_id = g_value_dup_string (value);
+      box->priv->stock_id = g_value_dup_string (value);
       break;
 
     case PROP_HINT:
-      box->hint = g_value_dup_string (value);
+      box->priv->hint = g_value_dup_string (value);
       break;
 
     default:
@@ -226,15 +207,15 @@ gimp_hint_box_get_property (GObject    *object,
   switch (property_id)
     {
     case PROP_ICON_NAME:
-      g_value_set_string (value, box->icon_name);
+      g_value_set_string (value, box->priv->icon_name);
       break;
 
     case PROP_STOCK_ID:
-      g_value_set_string (value, box->stock_id);
+      g_value_set_string (value, box->priv->stock_id);
       break;
 
     case PROP_HINT:
-      g_value_set_string (value, box->hint);
+      g_value_set_string (value, box->priv->hint);
       break;
 
     default:
@@ -248,7 +229,7 @@ gimp_hint_box_get_property (GObject    *object,
  * @hint: text to display as a user hint
  *
  * Creates a new widget that shows a text label showing @hint,
- * decorated with a GIMP_STOCK_INFO wilber icon.
+ * decorated with a GIMP_ICON_DIALOG_INFORMATION wilber icon.
  *
  * Return value: a new widget
  *
diff --git a/libgimpwidgets/gimphintbox.h b/libgimpwidgets/gimphintbox.h
index ee53187339..c5c050e0ea 100644
--- a/libgimpwidgets/gimphintbox.h
+++ b/libgimpwidgets/gimphintbox.h
@@ -31,7 +31,39 @@ G_BEGIN_DECLS
 /* For information look into the C source or the html documentation */
 
 
-#define GIMP_TYPE_HINT_BOX  (gimp_hint_box_get_type ())
+#define GIMP_TYPE_HINT_BOX            (gimp_hint_box_get_type ())
+#define GIMP_HINT_BOX(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_HINT_BOX, GimpHintBox))
+#define GIMP_HINT_BOX_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_HINT_BOX, 
GimpHintBoxClass))
+#define GIMP_IS_HINT_BOX(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_HINT_BOX))
+#define GIMP_IS_HINT_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_HINT_BOX))
+#define GIMP_HINT_BOX_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_HINT_BOX, 
GimpHintBoxClass))
+
+
+typedef struct _GimpHintBoxPrivate GimpHintBoxPrivate;
+typedef struct _GimpHintBoxClass   GimpHintBoxClass;
+
+struct _GimpHintBox
+{
+  GtkBox              parent_instance;
+
+  GimpHintBoxPrivate *priv;
+};
+
+struct _GimpHintBoxClass
+{
+  GtkBoxClass  parent_class;
+
+  /* Padding for future expansion */
+  void (* _gimp_reserved1) (void);
+  void (* _gimp_reserved2) (void);
+  void (* _gimp_reserved3) (void);
+  void (* _gimp_reserved4) (void);
+  void (* _gimp_reserved5) (void);
+  void (* _gimp_reserved6) (void);
+  void (* _gimp_reserved7) (void);
+  void (* _gimp_reserved8) (void);
+};
+
 
 GType       gimp_hint_box_get_type (void) G_GNUC_CONST;
 
diff --git a/libgimpwidgets/gimpwidgetstypes.h b/libgimpwidgets/gimpwidgetstypes.h
index 3dfec172d9..cf2ac14fb7 100644
--- a/libgimpwidgets/gimpwidgetstypes.h
+++ b/libgimpwidgets/gimpwidgetstypes.h
@@ -58,6 +58,7 @@ typedef struct _GimpEnumComboBox              GimpEnumComboBox;
 typedef struct _GimpEnumLabel                 GimpEnumLabel;
 typedef struct _GimpFileEntry                 GimpFileEntry;
 typedef struct _GimpFrame                     GimpFrame;
+typedef struct _GimpHintBox                   GimpHintBox;
 typedef struct _GimpIntComboBox               GimpIntComboBox;
 typedef struct _GimpIntStore                  GimpIntStore;
 typedef struct _GimpMemsizeEntry              GimpMemsizeEntry;


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