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



commit be003f986df1f761c715044668ec63ce1f0ddfb0
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 c23d79a..a7b364d 100644
--- a/libgimpwidgets/Makefile.am
+++ b/libgimpwidgets/Makefile.am
@@ -157,6 +157,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 795c05a..01be8e3 100644
--- a/libgimpwidgets/gimppickbutton-default.c
+++ b/libgimpwidgets/gimppickbutton-default.c
@@ -36,6 +36,7 @@
 #include "gimpicons.h"
 #include "gimppickbutton.h"
 #include "gimppickbutton-default.h"
+#include "gimppickbutton-private.h"
 #include "gimpwidgetsutils.h"
 
 #include "cursors/gimp-color-picker-cursors.c"
@@ -188,13 +189,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
@@ -319,22 +320,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,
@@ -349,7 +351,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 2556263..afb9b1d 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 "gimppickbutton-quartz.h"
 
 #include "cursors/gimp-color-picker-cursors.c"
diff --git a/libgimpwidgets/gimppickbutton.c b/libgimpwidgets/gimppickbutton.c
index 913d1bc..14c22d9 100644
--- a/libgimpwidgets/gimppickbutton.c
+++ b/libgimpwidgets/gimppickbutton.c
@@ -32,6 +32,7 @@
 #include "gimppickbutton.h"
 #include "gimppickbutton-default.h"
 #include "gimppickbutton-kwin.h"
+#include "gimppickbutton-private.h"
 
 #ifdef GDK_WINDOWING_QUARTZ
 #include "gimppickbutton-quartz.h"
@@ -56,6 +57,7 @@ enum
   LAST_SIGNAL
 };
 
+
 static void       gimp_pick_button_dispose         (GObject        *object);
 
 static void       gimp_pick_button_clicked         (GtkButton      *button);
@@ -96,6 +98,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
@@ -103,6 +107,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_ICON_COLOR_PICK_FROM_SCREEN,
                                         GTK_ICON_SIZE_BUTTON);
   gtk_container_add (GTK_CONTAINER (button), image);
@@ -119,16 +127,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]