[gnome-applets/gnome-2-26] Work around GTK+s wonky ideas about the up key and scrollers.



commit 052253de05d46458fc1fda0a0b3aa1fa3acdce3e
Author: Callum McKenzie <callum spooky-possum org>
Date:   Wed May 20 12:53:51 2009 +1200

    Work around GTK+s wonky ideas about the up key and scrollers.
    
    Proxy events from the dock scroller to the applet so that they both do the same thing with the same keys (and scroll events). See bug 581448.
    (cherry picked from commit 49c89567f896dd9119e9d44973768f61ac5385cb)
---
 mixer/ChangeLog |    8 ++++++++
 mixer/applet.c  |   19 +++++++++++++++----
 mixer/dock.c    |   34 ++++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/mixer/ChangeLog b/mixer/ChangeLog
index 129f38d..827f307 100644
--- a/mixer/ChangeLog
+++ b/mixer/ChangeLog
@@ -1,4 +1,12 @@
 ==================== 2.26.1 ======================
+2009-05-20  Callum McKenzie  <callum spooky-possum org>
+
+	* applet.c: 
+	* dock.c: Work around GTK+s wonky ideas about what the up key
+	means for a horizontal scroller so the dock and applet are in sync
+	with each other. See bug 581448.
+
+==================== 2.26.1 ======================
 
 ==================== 2.26.0 ======================
 
diff --git a/mixer/applet.c b/mixer/applet.c
index 3bf0959..dd49c26 100644
--- a/mixer/applet.c
+++ b/mixer/applet.c
@@ -57,11 +57,14 @@ static void     gnome_volume_applet_size_allocate (GtkWidget     *widget,
 static void	gnome_volume_applet_popup_dock	(GnomeVolumeApplet *applet);
 static void	gnome_volume_applet_popdown_dock (GnomeVolumeApplet *applet);
 
-static gboolean	gnome_volume_applet_scroll	(GtkWidget *widget,
+/* This function and gnome_volume_applet_key are not static so we can
+ * inject external events into the applet. Its to work around a GTK+
+ * misfeature. See dock.c for details. */
+gboolean	gnome_volume_applet_scroll	(GtkWidget *widget,
 						 GdkEventScroll *event);
 static gboolean	gnome_volume_applet_button	(GtkWidget *widget,
 						 GdkEventButton *event);
-static gboolean	gnome_volume_applet_key		(GtkWidget *widget,
+gboolean	gnome_volume_applet_key		(GtkWidget *widget,
 						 GdkEventKey *event);
 static gdouble  gnome_volume_applet_get_volume  (GstMixer *mixer, 
 						 GstMixerTrack *track);
@@ -721,7 +724,11 @@ gnome_volume_applet_run_mixer (GnomeVolumeApplet *applet)
  * Control events, change volume and so on.
  */
 
-static gboolean
+/* This is not static so we can inject external events
+ * into the applet. Its to work around a GTK+ misfeature. See dock.c 
+ * for details. */
+
+gboolean
 gnome_volume_applet_scroll (GtkWidget      *widget,
 			    GdkEventScroll *event)
 {
@@ -811,7 +818,11 @@ gnome_volume_applet_button (GtkWidget      *widget,
   return FALSE;
 }
 
-static gboolean
+/* This is not static so we can inject external events
+ * into the applet. Its to work around a GTK+ misfeature. See dock.c 
+ * for details. */
+
+gboolean
 gnome_volume_applet_key (GtkWidget   *widget,
 			 GdkEventKey *event)
 {
diff --git a/mixer/dock.c b/mixer/dock.c
index 67f5e0d..3acc407 100644
--- a/mixer/dock.c
+++ b/mixer/dock.c
@@ -103,6 +103,36 @@ static void launch_mixer_cb (GtkButton *button, GnomeVolumeAppletDock *dock)
   gnome_volume_applet_run_mixer (dock->model);
 }
 
+/*
+ * This is evil.
+ *
+ * Because we can't get a horizontal slider to behave sanely
+ * with respect to up/down keys, we capture those keypress
+ * and send them to the main applet - which can handle them sanely.
+ * To emphasise that this is exceptional behaviour, the declarations
+ * of the appropriate functions are made here rather than in a header.
+ *
+ */
+gboolean gnome_volume_applet_key (GtkWidget   *widget,
+				  GdkEventKey *event);
+gboolean gnome_volume_applet_scroll (GtkWidget      *widget,
+				     GdkEventScroll *event);
+
+static gboolean proxy_key_event (GtkWidget *self, GdkEventKey *event, 
+				 GtkWidget *applet)
+{
+  gnome_volume_applet_key (applet, event);
+
+  return TRUE;
+}
+
+static gboolean proxy_scroll_event (GtkWidget *self, GdkEventScroll *event, 
+				    GtkWidget *applet)
+{
+  gnome_volume_applet_scroll (applet, event);
+
+  return TRUE;
+}
 
 GtkWidget *
 gnome_volume_applet_dock_new (GtkOrientation orientation,
@@ -170,6 +200,10 @@ gnome_volume_applet_dock_new (GtkOrientation orientation,
   }
 
   scale = magic[orientation].sfunc (NULL);
+  g_signal_connect (scale, "key-press-event", G_CALLBACK (proxy_key_event),
+		    parent);
+  g_signal_connect (scale, "scroll-event", G_CALLBACK (proxy_scroll_event),
+		    parent);
   dock->scale = GTK_RANGE (scale);
   gtk_widget_set_size_request (scale,
 			       magic[orientation].sw,



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