summaryrefslogtreecommitdiff
path: root/mixer
diff options
context:
space:
mode:
authorCallum McKenzie <callum@spooky-possum.org>2009-05-20 12:35:20 +1200
committerCallum McKenzie <callum@spooky-possum.org>2009-05-20 13:05:17 +1200
commitb070247359aafa14893335d2578ea526be724a14 (patch)
tree157d3f868217c711baa01637cb1ca16b1c8700fb /mixer
parenta47f0d171a1ca89b453c1fa851e26737021fc8ea (diff)
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.
Diffstat (limited to 'mixer')
-rw-r--r--mixer/ChangeLog7
-rw-r--r--mixer/applet.c19
-rw-r--r--mixer/dock.c34
3 files changed, 56 insertions, 4 deletions
diff --git a/mixer/ChangeLog b/mixer/ChangeLog
index c82085bb8..5036a6bea 100644
--- a/mixer/ChangeLog
+++ b/mixer/ChangeLog
@@ -1,3 +1,10 @@
+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.27.1 ======================
==================== 2.26.0 ======================
diff --git a/mixer/applet.c b/mixer/applet.c
index 3bf09598e..dd49c2646 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 67f5e0dc7..3acc40781 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,