[gimp/soc-2010-cage-2] app: add gimp_devices_add_widget()



commit ae045b71941cbf9ca70b857749ba645f845aa3f3
Author: Michael Natterer <mitch gimp org>
Date:   Sun Dec 19 21:23:54 2010 +0100

    app: add gimp_devices_add_widget()
    
    which is supposed to set up a widget for tablet events and make sure
    the context changes on device changes. "supposed" because everything
    is currently horribly broken on GTK+ 2.x. Use the function for all
    affected widgets except for the canvas.

 app/display/gimpdisplayshell.c |    8 +++-----
 app/widgets/gimpdevices.c      |   17 ++++++++++++++++-
 app/widgets/gimpdevices.h      |    3 +++
 app/widgets/gimptoolbox.c      |    7 +------
 4 files changed, 23 insertions(+), 12 deletions(-)
---
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 2e0973c..d2dba11 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -46,6 +46,7 @@
 #include "core/gimpmarshal.h"
 #include "core/gimptemplate.h"
 
+#include "widgets/gimpdevices.h"
 #include "widgets/gimphelp-ids.h"
 #include "widgets/gimpuimanager.h"
 #include "widgets/gimpwidgets-utils.h"
@@ -544,11 +545,8 @@ gimp_display_shell_constructor (GType                  type,
 
   gimp_help_set_help_data (shell->vrule, NULL, GIMP_HELP_IMAGE_WINDOW_RULER);
 
-  /*  Workaround for GTK+ Wintab bug on Windows when creating guides by
-   *  dragging from the rulers. See bug #168516.
-   */
-  gtk_widget_set_extension_events (shell->hrule, GDK_EXTENSION_EVENTS_ALL);
-  gtk_widget_set_extension_events (shell->vrule, GDK_EXTENSION_EVENTS_ALL);
+  gimp_devices_add_widget (shell->display->gimp, shell->hrule);
+  gimp_devices_add_widget (shell->display->gimp, shell->vrule);
 
   g_signal_connect (shell->canvas, "realize",
                     G_CALLBACK (gimp_display_shell_canvas_realize),
diff --git a/app/widgets/gimpdevices.c b/app/widgets/gimpdevices.c
index 7a484b7..b09a9ac 100644
--- a/app/widgets/gimpdevices.c
+++ b/app/widgets/gimpdevices.c
@@ -309,6 +309,20 @@ gimp_devices_get_current (Gimp *gimp)
   return manager->current_device;
 }
 
+void
+gimp_devices_add_widget (Gimp      *gimp,
+                         GtkWidget *widget)
+{
+  g_return_if_fail (GIMP_IS_GIMP (gimp));
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  gtk_widget_set_extension_events (widget, GDK_EXTENSION_EVENTS_ALL);
+
+  g_signal_connect (widget, "motion-notify-event",
+                    G_CALLBACK (gimp_devices_check_callback),
+                    gimp);
+}
+
 gboolean
 gimp_devices_check_callback (GtkWidget *widget,
                              GdkEvent  *event,
@@ -317,7 +331,8 @@ gimp_devices_check_callback (GtkWidget *widget,
   g_return_val_if_fail (event != NULL, FALSE);
   g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
 
-  gimp_devices_check_change (gimp, event);
+  if (! gimp->busy)
+    gimp_devices_check_change (gimp, event);
 
   return FALSE;
 }
diff --git a/app/widgets/gimpdevices.h b/app/widgets/gimpdevices.h
index a3449b7..b07b8c6 100644
--- a/app/widgets/gimpdevices.h
+++ b/app/widgets/gimpdevices.h
@@ -36,6 +36,9 @@ gboolean         gimp_devices_clear          (Gimp                   *gimp,
 GimpContainer  * gimp_devices_get_list       (Gimp                   *gimp);
 GimpDeviceInfo * gimp_devices_get_current    (Gimp                   *gimp);
 
+void             gimp_devices_add_widget     (Gimp                   *gimp,
+                                              GtkWidget              *widget);
+
 gboolean         gimp_devices_check_callback (GtkWidget              *widget,
                                               GdkEvent               *event,
                                               Gimp                   *gimp);
diff --git a/app/widgets/gimptoolbox.c b/app/widgets/gimptoolbox.c
index b6fd332..64e01c9 100644
--- a/app/widgets/gimptoolbox.c
+++ b/app/widgets/gimptoolbox.c
@@ -305,13 +305,8 @@ gimp_toolbox_constructed (GObject *object)
 
   if (! list)  /* all devices have cursor */
     {
-      g_signal_connect (toolbox, "motion-notify-event",
-                        G_CALLBACK (gimp_devices_check_callback),
-                        toolbox->p->context->gimp);
-
       gtk_widget_add_events (GTK_WIDGET (toolbox), GDK_POINTER_MOTION_MASK);
-      gtk_widget_set_extension_events (GTK_WIDGET (toolbox),
-                                       GDK_EXTENSION_EVENTS_CURSOR);
+      gimp_devices_add_widget (toolbox->p->context->gimp, GTK_WIDGET (toolbox));
     }
 
   toolbox->p->color_area = toolbox_create_color_area (toolbox,



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