[gimp/gtk3-port: 188/251] libgimpwidgets: move all GimpButton members to a private struct



commit 5a9ab16e5ad3af3645353fd63e96049f8b3152d8
Author: Michael Natterer <mitch gimp org>
Date:   Fri Dec 31 17:24:54 2010 +0100

    libgimpwidgets: move all GimpButton members to a private struct

 libgimpwidgets/gimpbutton.c |   32 +++++++++++++++++++++++++-------
 libgimpwidgets/gimpbutton.h |    5 +----
 2 files changed, 26 insertions(+), 11 deletions(-)
---
diff --git a/libgimpwidgets/gimpbutton.c b/libgimpwidgets/gimpbutton.c
index 92b4403..c85ed1f 100644
--- a/libgimpwidgets/gimpbutton.c
+++ b/libgimpwidgets/gimpbutton.c
@@ -46,6 +46,18 @@ enum
 };
 
 
+typedef struct _GimpButtonPrivate GimpButtonPrivate;
+
+struct _GimpButtonPrivate
+{
+  GdkModifierType  press_state;
+};
+
+#define GET_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE (obj, \
+                                                      GIMP_TYPE_BUTTON, \
+                                                      GimpButtonPrivate)
+
+
 static gboolean   gimp_button_button_press (GtkWidget      *widget,
                                             GdkEventButton *event);
 static void       gimp_button_clicked      (GtkButton      *button);
@@ -61,6 +73,7 @@ static guint button_signals[LAST_SIGNAL] = { 0 };
 static void
 gimp_button_class_init (GimpButtonClass *klass)
 {
+  GObjectClass   *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
   GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
 
@@ -85,12 +98,16 @@ gimp_button_class_init (GimpButtonClass *klass)
   widget_class->button_press_event = gimp_button_button_press;
 
   button_class->clicked            = gimp_button_clicked;
+
+  g_type_class_add_private (object_class, sizeof (GimpButtonPrivate));
 }
 
 static void
 gimp_button_init (GimpButton *button)
 {
-  button->press_state = 0;
+  GimpButtonPrivate *private = GET_PRIVATE (button);
+
+  private->press_state = 0;
 }
 
 /**
@@ -126,15 +143,15 @@ static gboolean
 gimp_button_button_press (GtkWidget      *widget,
                           GdkEventButton *bevent)
 {
-  GimpButton *button = GIMP_BUTTON (widget);
+  GimpButtonPrivate *private = GET_PRIVATE (widget);
 
   if (bevent->button == 1)
     {
-      button->press_state = bevent->state;
+      private->press_state = bevent->state;
     }
   else
     {
-      button->press_state = 0;
+      private->press_state = 0;
     }
 
   return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, bevent);
@@ -143,13 +160,14 @@ gimp_button_button_press (GtkWidget      *widget,
 static void
 gimp_button_clicked (GtkButton *button)
 {
-  if (GIMP_BUTTON (button)->press_state &
+  GimpButtonPrivate *private = GET_PRIVATE (button);
+
+  if (private->press_state &
       (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK))
     {
       g_signal_stop_emission_by_name (button, "clicked");
 
-      gimp_button_extended_clicked (GIMP_BUTTON (button),
-                                    GIMP_BUTTON (button)->press_state);
+      gimp_button_extended_clicked (GIMP_BUTTON (button), private->press_state);
     }
   else if (GTK_BUTTON_CLASS (parent_class)->clicked)
     {
diff --git a/libgimpwidgets/gimpbutton.h b/libgimpwidgets/gimpbutton.h
index 4df78b1..82d0684 100644
--- a/libgimpwidgets/gimpbutton.h
+++ b/libgimpwidgets/gimpbutton.h
@@ -39,10 +39,7 @@ typedef struct _GimpButtonClass  GimpButtonClass;
 
 struct _GimpButton
 {
-  GtkButton        parent_instance;
-
-  /*< private >*/
-  GdkModifierType  press_state;
+  GtkButton  parent_instance;
 };
 
 struct _GimpButtonClass



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