[gimp/gtk3-port: 144/234] libgimpwidgets: move all GimpPickButton members to a private struct



commit 6413f7a7c1a8154632ea6bd4c490c18b032e66ec
Author: Michael Natterer <mitch gimp org>
Date:   Wed Dec 29 16:20:00 2010 +0100

    libgimpwidgets: move all GimpPickButton members to a private struct

 libgimpwidgets/Makefile.am              |    1 +
 libgimpwidgets/gimppickbutton-default.c |   22 ++++++++++++----------
 libgimpwidgets/gimppickbutton-private.h |   27 +++++++++++++++++++++++++++
 libgimpwidgets/gimppickbutton-quartz.c  |    1 +
 libgimpwidgets/gimppickbutton.c         |   20 ++++++++++++++------
 libgimpwidgets/gimppickbutton.h         |    9 ++++-----
 6 files changed, 59 insertions(+), 21 deletions(-)
---
diff --git a/libgimpwidgets/Makefile.am b/libgimpwidgets/Makefile.am
index 1048bf2..0fd65e2 100644
--- a/libgimpwidgets/Makefile.am
+++ b/libgimpwidgets/Makefile.am
@@ -147,6 +147,7 @@ libgimpwidgets_sources = \
        gimppatheditor.h                \
        gimppickbutton.c                \
        gimppickbutton.h                \
+       gimppickbutton-private.h        \
        gimppreview.c                   \
        gimppreview.h                   \
        gimppreviewarea.c               \
diff --git a/libgimpwidgets/gimppickbutton-default.c b/libgimpwidgets/gimppickbutton-default.c
index 07404f0..7e5116f 100644
--- a/libgimpwidgets/gimppickbutton-default.c
+++ b/libgimpwidgets/gimppickbutton-default.c
@@ -30,6 +30,7 @@
 #include "gimphelpui.h"
 #include "gimpicons.h"
 #include "gimppickbutton.h"
+#include "gimppickbutton-private.h"
 
 #include "cursors/gimp-color-picker-cursors.c"
 
@@ -183,13 +184,13 @@ gimp_pick_button_mouse_release (GtkWidget      *invisible,
 static void
 gimp_pick_button_shutdown (GimpPickButton *button)
 {
-  GdkDisplay *display   = gtk_widget_get_display (button->grab_widget);
+  GdkDisplay *display   = gtk_widget_get_display (button->priv->grab_widget);
   guint32     timestamp = gtk_get_current_event_time ();
 
   gdk_display_keyboard_ungrab (display, timestamp);
   gdk_display_pointer_ungrab (display, timestamp);
 
-  gtk_grab_remove (button->grab_widget);
+  gtk_grab_remove (button->priv->grab_widget);
 }
 
 static void
@@ -231,22 +232,23 @@ _gimp_pick_button_default_pick (GimpPickButton *button)
   GtkWidget *widget;
   guint32    timestamp;
 
-  if (! button->cursor)
-    button->cursor = make_cursor (gtk_widget_get_display (GTK_WIDGET (button)));
+  if (! button->priv->cursor)
+    button->priv->cursor =
+      make_cursor (gtk_widget_get_display (GTK_WIDGET (button)));
 
-  if (! button->grab_widget)
+  if (! button->priv->grab_widget)
     {
-      button->grab_widget = gtk_invisible_new ();
+      button->priv->grab_widget = gtk_invisible_new ();
 
-      gtk_widget_add_events (button->grab_widget,
+      gtk_widget_add_events (button->priv->grab_widget,
                              GDK_BUTTON_RELEASE_MASK |
                              GDK_BUTTON_PRESS_MASK   |
                              GDK_POINTER_MOTION_MASK);
 
-      gtk_widget_show (button->grab_widget);
+      gtk_widget_show (button->priv->grab_widget);
     }
 
-  widget = button->grab_widget;
+  widget = button->priv->grab_widget;
   timestamp = gtk_get_current_event_time ();
 
   if (gdk_keyboard_grab (gtk_widget_get_window (widget), FALSE,
@@ -261,7 +263,7 @@ _gimp_pick_button_default_pick (GimpPickButton *button)
                         GDK_BUTTON_PRESS_MASK   |
                         GDK_POINTER_MOTION_MASK,
                         NULL,
-                        button->cursor,
+                        button->priv->cursor,
                         timestamp) != GDK_GRAB_SUCCESS)
     {
       gdk_display_keyboard_ungrab (gtk_widget_get_display (widget), timestamp);
diff --git a/libgimpwidgets/gimppickbutton-private.h b/libgimpwidgets/gimppickbutton-private.h
new file mode 100644
index 0000000..aeccd07
--- /dev/null
+++ b/libgimpwidgets/gimppickbutton-private.h
@@ -0,0 +1,27 @@
+/* LIBGIMP - The GIMP Library
+ * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
+ *
+ * gimppickbutton-private.h
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_PICK_BUTTON_PRIVATE_H__
+#define __GIMP_PICK_BUTTON_PRIVATE_H__
+
+
+struct _GimpPickButtonPrivate
+{
+  GdkCursor *cursor;
+  GtkWidget *grab_widget;
+};
+
+
+#endif /* ! __GIMP_PICK_BUTTON_PRIVATE_H__ */
diff --git a/libgimpwidgets/gimppickbutton-quartz.c b/libgimpwidgets/gimppickbutton-quartz.c
index 7241a2d..accfe6a 100644
--- a/libgimpwidgets/gimppickbutton-quartz.c
+++ b/libgimpwidgets/gimppickbutton-quartz.c
@@ -24,6 +24,7 @@
 
 #include "gimpwidgetstypes.h"
 #include "gimppickbutton.h"
+#include "gimppickbutton-private.h"
 
 #include "cursors/gimp-color-picker-cursors.c"
 
diff --git a/libgimpwidgets/gimppickbutton.c b/libgimpwidgets/gimppickbutton.c
index 200fb46..de577bf 100644
--- a/libgimpwidgets/gimppickbutton.c
+++ b/libgimpwidgets/gimppickbutton.c
@@ -30,6 +30,7 @@
 #include "gimphelpui.h"
 #include "gimpicons.h"
 #include "gimppickbutton.h"
+#include "gimppickbutton-private.h"
 
 #include "libgimp/libgimp-intl.h"
 
@@ -50,6 +51,7 @@ enum
   LAST_SIGNAL
 };
 
+
 /* entry points to gimppickbutton-{default,quartz}.c */
 void              _gimp_pick_button_default_pick (GimpPickButton *button);
 void              _gimp_pick_button_quartz_pick  (GimpPickButton *button);
@@ -94,6 +96,8 @@ gimp_pick_button_class_init (GimpPickButtonClass* klass)
   button_class->clicked = gimp_pick_button_clicked;
 
   klass->color_picked   = NULL;
+
+  g_type_class_add_private (object_class, sizeof (GimpPickButtonPrivate));
 }
 
 static void
@@ -101,6 +105,10 @@ gimp_pick_button_init (GimpPickButton *button)
 {
   GtkWidget *image;
 
+  button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button,
+                                              GIMP_TYPE_PICK_BUTTON,
+                                              GimpPickButtonPrivate);
+
   image = gtk_image_new_from_icon_name (GIMP_STOCK_COLOR_PICK_FROM_SCREEN,
                                         GTK_ICON_SIZE_BUTTON);
   gtk_container_add (GTK_CONTAINER (button), image);
@@ -117,16 +125,16 @@ gimp_pick_button_dispose (GObject *object)
 {
   GimpPickButton *button = GIMP_PICK_BUTTON (object);
 
-  if (button->cursor)
+  if (button->priv->cursor)
     {
-      g_object_unref (button->cursor);
-      button->cursor = NULL;
+      g_object_unref (button->priv->cursor);
+      button->priv->cursor = NULL;
     }
 
-  if (button->grab_widget)
+  if (button->priv->grab_widget)
     {
-      gtk_widget_destroy (button->grab_widget);
-      button->grab_widget = NULL;
+      gtk_widget_destroy (button->priv->grab_widget);
+      button->priv->grab_widget = NULL;
     }
 
   G_OBJECT_CLASS (parent_class)->dispose (object);
diff --git a/libgimpwidgets/gimppickbutton.h b/libgimpwidgets/gimppickbutton.h
index 45b3035..bfd16a8 100644
--- a/libgimpwidgets/gimppickbutton.h
+++ b/libgimpwidgets/gimppickbutton.h
@@ -34,15 +34,14 @@ G_BEGIN_DECLS
 #define GIMP_PICK_BUTTON_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PICK_BUTTON, 
GimpPickButtonClass))
 
 
-typedef struct _GimpPickButtonClass GimpPickButtonClass;
+typedef struct _GimpPickButtonPrivate GimpPickButtonPrivate;
+typedef struct _GimpPickButtonClass   GimpPickButtonClass;
 
 struct _GimpPickButton
 {
-  GtkButton   parent_instance;
+  GtkButton              parent_instance;
 
-  /*< private >*/
-  GdkCursor  *cursor;
-  GtkWidget  *grab_widget;
+  GimpPickButtonPrivate *priv;
 };
 
 struct _GimpPickButtonClass


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