[gimp/cage: 105/130] app: add gimp_devices_check_callback() with the signature of an event callback



commit e372d857b60ce3c0c87df1fc3e24cee66ce40b93
Author: Michael Natterer <mitch gimp org>
Date:   Mon Dec 6 10:23:15 2010 +0100

    app: add gimp_devices_check_callback() with the signature of an event callback
    
    and use it in the toolbox. Will soon be used in more places.

 app/widgets/gimpdevices.c |   13 +++++++++++++
 app/widgets/gimpdevices.h |   27 +++++++++++++++------------
 app/widgets/gimptoolbox.c |   15 +--------------
 3 files changed, 29 insertions(+), 26 deletions(-)
---
diff --git a/app/widgets/gimpdevices.c b/app/widgets/gimpdevices.c
index cecfa94..02a42ca 100644
--- a/app/widgets/gimpdevices.c
+++ b/app/widgets/gimpdevices.c
@@ -312,6 +312,19 @@ gimp_devices_get_current (Gimp *gimp)
 }
 
 gboolean
+gimp_devices_check_callback (GtkWidget *widget,
+                             GdkEvent  *event,
+                             Gimp      *gimp)
+{
+  g_return_val_if_fail (event != NULL, FALSE);
+  g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
+
+  gimp_devices_check_change (gimp, event);
+
+  return FALSE;
+}
+
+gboolean
 gimp_devices_check_change (Gimp     *gimp,
                            GdkEvent *event)
 {
diff --git a/app/widgets/gimpdevices.h b/app/widgets/gimpdevices.h
index 682de19..a3449b7 100644
--- a/app/widgets/gimpdevices.h
+++ b/app/widgets/gimpdevices.h
@@ -22,22 +22,25 @@
 typedef void (* GimpDeviceChangeNotify) (Gimp *gimp);
 
 
-void             gimp_devices_init          (Gimp                   *gimp,
-                                             GimpDeviceChangeNotify  callback);
-void             gimp_devices_exit          (Gimp                   *gimp);
+void             gimp_devices_init           (Gimp                   *gimp,
+                                              GimpDeviceChangeNotify  callback);
+void             gimp_devices_exit           (Gimp                   *gimp);
 
-void             gimp_devices_restore       (Gimp                   *gimp);
-void             gimp_devices_save          (Gimp                   *gimp,
-                                             gboolean                always_save);
+void             gimp_devices_restore        (Gimp                   *gimp);
+void             gimp_devices_save           (Gimp                   *gimp,
+                                              gboolean                always_save);
 
-gboolean         gimp_devices_clear         (Gimp                   *gimp,
-                                             GError                **error);
+gboolean         gimp_devices_clear          (Gimp                   *gimp,
+                                              GError                **error);
 
-GimpContainer  * gimp_devices_get_list      (Gimp                   *gimp);
-GimpDeviceInfo * gimp_devices_get_current   (Gimp                   *gimp);
+GimpContainer  * gimp_devices_get_list       (Gimp                   *gimp);
+GimpDeviceInfo * gimp_devices_get_current    (Gimp                   *gimp);
 
-gboolean         gimp_devices_check_change  (Gimp                   *gimp,
-                                             GdkEvent               *event);
+gboolean         gimp_devices_check_callback (GtkWidget              *widget,
+                                              GdkEvent               *event,
+                                              Gimp                   *gimp);
+gboolean         gimp_devices_check_change   (Gimp                   *gimp,
+                                              GdkEvent               *event);
 
 
 #endif /* __GIMP_DEVICES_H__ */
diff --git a/app/widgets/gimptoolbox.c b/app/widgets/gimptoolbox.c
index ef656e6..eb24752 100644
--- a/app/widgets/gimptoolbox.c
+++ b/app/widgets/gimptoolbox.c
@@ -144,9 +144,6 @@ static void        toolbox_area_notify                  (GimpGuiConfig  *config,
 static void        toolbox_wilber_notify                (GimpGuiConfig  *config,
                                                          GParamSpec     *pspec,
                                                          GtkWidget      *wilber);
-static gboolean    toolbox_check_device                 (GtkWidget      *widget,
-                                                         GdkEvent       *event,
-                                                         Gimp           *gimp);
 static void        toolbox_paste_received               (GtkClipboard   *clipboard,
                                                          const gchar    *text,
                                                          gpointer        data);
@@ -309,7 +306,7 @@ gimp_toolbox_constructed (GObject *object)
   if (! list)  /* all devices have cursor */
     {
       g_signal_connect (toolbox, "motion-notify-event",
-                        G_CALLBACK (toolbox_check_device),
+                        G_CALLBACK (gimp_devices_check_callback),
                         toolbox->p->context->gimp);
 
       gtk_widget_add_events (GTK_WIDGET (toolbox), GDK_POINTER_MOTION_MASK);
@@ -839,16 +836,6 @@ toolbox_wilber_notify (GimpGuiConfig *config,
   g_object_set (wilber, "visible", visible, NULL);
 }
 
-static gboolean
-toolbox_check_device (GtkWidget *widget,
-                      GdkEvent  *event,
-                      Gimp      *gimp)
-{
-  gimp_devices_check_change (gimp, event);
-
-  return FALSE;
-}
-
 static void
 toolbox_paste_received (GtkClipboard *clipboard,
                         const gchar  *text,



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