[gnome-control-center] shell: Make the mouse back button go to the homepage



commit c764fbe7455e4fe7162807724f3913d6a38e55e1
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Mar 26 14:39:34 2013 +0100

    shell: Make the mouse back button go to the homepage
    
    https://bugzilla.gnome.org/show_bug.cgi?id=690087

 shell/cc-window.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/shell/cc-window.c b/shell/cc-window.c
index 3f26fe2..353f0ae 100644
--- a/shell/cc-window.c
+++ b/shell/cc-window.c
@@ -56,6 +56,8 @@ G_DEFINE_TYPE_WITH_CODE (CcWindow, cc_window, GTK_TYPE_APPLICATION_WINDOW,
 
 #define MIN_ICON_VIEW_HEIGHT 300
 
+#define MOUSE_BACK_BUTTON 8
+
 #define DEFAULT_WINDOW_TITLE N_("Settings")
 #define DEFAULT_WINDOW_ICON_NAME "preferences-desktop"
 
@@ -1158,6 +1160,18 @@ cc_window_class_init (CcWindowClass *klass)
 }
 
 static gboolean
+window_button_release_event (GtkWidget          *win,
+                            GdkEventButton     *event,
+                            CcWindow           *self)
+{
+       g_message ("button release");
+  /* back button */
+  if (event->button == MOUSE_BACK_BUTTON)
+    shell_show_overview_page (self);
+  return FALSE;
+}
+
+static gboolean
 window_key_press_event (GtkWidget   *win,
                         GdkEventKey *event,
                         CcWindow    *self)
@@ -1453,6 +1467,10 @@ create_window (CcWindow *self)
   g_signal_connect (self, "notify::application", G_CALLBACK (application_set_cb), self);
   g_signal_connect_after (self, "key_press_event",
                           G_CALLBACK (window_key_press_event), self);
+  gtk_widget_add_events (GTK_WIDGET (self), GDK_BUTTON_RELEASE_MASK);
+  g_signal_connect (self, "button-release-event",
+                    G_CALLBACK (window_button_release_event), self);
+
   g_signal_connect (self, "notify::window", G_CALLBACK (gdk_window_set_cb), self);
 
   g_signal_connect (priv->stack, "notify::visible-child",


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