[gnome-settings-daemon] wacom: Move the OSD related key release processing to the GsdWacomOSDWindow



commit b9744e37a4ea263f5959b0f09642f3fabfb92a5c
Author: Joaquim Rocha <jrocha redhat com>
Date:   Mon Jul 15 11:51:47 2013 +0200

    wacom: Move the OSD related key release processing to the GsdWacomOSDWindow
    
    Instead of doing it in the GsdWacomManager; this way, it gets more modular and
    makes it easier for the OSD to process the keys.
    Also changes what some keys do.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=701200

 plugins/wacom/gsd-wacom-manager.c    |   28 ++--------------------------
 plugins/wacom/gsd-wacom-osd-window.c |   27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 26 deletions(-)
---
diff --git a/plugins/wacom/gsd-wacom-manager.c b/plugins/wacom/gsd-wacom-manager.c
index abab928..29e1a28 100644
--- a/plugins/wacom/gsd-wacom-manager.c
+++ b/plugins/wacom/gsd-wacom-manager.c
@@ -916,29 +916,6 @@ osd_window_destroy (GsdWacomManager *manager)
 }
 
 static gboolean
-osd_window_on_key_release_event (GtkWidget   *widget,
-                                 GdkEventKey *event,
-                                 GsdWacomManager *manager)
-{
-       gboolean editing_mode;
-
-       /* If it's in edition mode, we don't destroy the window */
-       g_object_get (widget, "edition-mode", &editing_mode, NULL);
-
-       if (editing_mode)
-               return FALSE;
-
-       if (event->type != GDK_KEY_RELEASE)
-               return FALSE;
-       if (event->keyval != GDK_KEY_Escape)
-               return FALSE;
-
-       osd_window_destroy (manager);
-
-       return FALSE;
-}
-
-static gboolean
 osd_window_on_focus_out_event (GtkWidget *widget,
                                GdkEvent  *event,
                                GsdWacomManager *manager)
@@ -988,9 +965,8 @@ osd_window_toggle_visibility (GsdWacomManager *manager,
 
        widget = gsd_wacom_osd_window_new (device, NULL);
 
-       /* Connect some signals to the OSD window */
-       g_signal_connect (widget, "key-release-event",
-                         G_CALLBACK(osd_window_on_key_release_event), manager);
+       g_object_add_weak_pointer (G_OBJECT (widget), (gpointer *) &manager->priv->osd_window);
+
        g_signal_connect (widget, "focus-out-event",
                          G_CALLBACK(osd_window_on_focus_out_event), manager);
        g_object_add_weak_pointer (G_OBJECT (widget), (gpointer *) &manager->priv->osd_window);
diff --git a/plugins/wacom/gsd-wacom-osd-window.c b/plugins/wacom/gsd-wacom-osd-window.c
index 03918c5..3949bcf 100644
--- a/plugins/wacom/gsd-wacom-osd-window.c
+++ b/plugins/wacom/gsd-wacom-osd-window.c
@@ -1636,6 +1636,32 @@ gsd_wacom_osd_window_realized (GtkWidget *widget,
        gtk_window_set_keep_above (GTK_WINDOW (osd_window), TRUE);
 }
 
+static gboolean
+gsd_wacom_osd_window_key_release_event (GtkWidget    *widget,
+                                       GdkEventKey  *event)
+{
+       GsdWacomOSDWindow *osd_window;
+       osd_window = GSD_WACOM_OSD_WINDOW (widget);
+
+       if (event->type != GDK_KEY_RELEASE)
+               goto out;
+
+       if (osd_window->priv->edition_mode) {
+               if (event->keyval == GDK_KEY_Escape && !gtk_widget_get_visible (osd_window->priv->editor))
+                       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON 
(osd_window->priv->change_mode_button),
+                                                     FALSE);
+
+               goto out;
+       }
+
+       gtk_widget_destroy (widget);
+
+ out:
+       GTK_WIDGET_CLASS (gsd_wacom_osd_window_parent_class)->key_release_event (widget, event);
+
+       return FALSE;
+}
+
 static void
 gsd_wacom_osd_window_set_device (GsdWacomOSDWindow *osd_window,
                                 GsdWacomDevice    *device)
@@ -1965,6 +1991,7 @@ gsd_wacom_osd_window_class_init (GsdWacomOSDWindowClass *klass)
        widget_class->draw          = gsd_wacom_osd_window_draw;
        widget_class->motion_notify_event = gsd_wacom_osd_window_motion_notify_event;
        widget_class->show          = gsd_wacom_osd_window_show;
+       widget_class->key_release_event = gsd_wacom_osd_window_key_release_event;
 
        g_object_class_install_property (gobject_class,
                                         PROP_OSD_WINDOW_MESSAGE,


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