summaryrefslogtreecommitdiff
path: root/mixer
diff options
context:
space:
mode:
authorCallum McKenzie <callum@src.gnome.org>2009-03-04 09:34:19 +0000
committerCallum McKenzie <callum@src.gnome.org>2009-03-04 09:34:19 +0000
commit7a4ea11eeb43bbf7feb4eac1885f91058b9640f5 (patch)
tree6dec7b519f95f2d41e7bc876007b2265112a7e64 /mixer
parent5d3685ed91247f44920f9d336d8b1215073fd949 (diff)
Hide the mixer dock when the escape key is pressed. Bug 572427.
svn path=/trunk/; revision=11321
Diffstat (limited to 'mixer')
-rw-r--r--mixer/ChangeLog3
-rw-r--r--mixer/dock.c25
2 files changed, 28 insertions, 0 deletions
diff --git a/mixer/ChangeLog b/mixer/ChangeLog
index 7cca4f655..47ac827f7 100644
--- a/mixer/ChangeLog
+++ b/mixer/ChangeLog
@@ -1,5 +1,8 @@
2009-03-04 Callum McKenzie <callum@spooky-possum.org>
+ * dock.c (cb_key_press): Hide the dock on an escape key - bug
+ 572427.
+
* applet.c (gnome_volume_applet_refresh): Move the dock update
code to be in sync with the icon update code. Bug 573924. Fixes
problems like bug 573924.
diff --git a/mixer/dock.c b/mixer/dock.c
index e6f8aa12d..67f5e0dc7 100644
--- a/mixer/dock.c
+++ b/mixer/dock.c
@@ -25,6 +25,7 @@
#include <glib-object.h>
#include <glib/gi18n.h>
+#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "dock.h"
@@ -39,6 +40,9 @@ static gboolean cb_button_press (GtkWidget *widget,
static gboolean cb_button_release (GtkWidget *widget,
GdkEventButton *button,
gpointer data);
+static gboolean cb_key_press (GtkWidget *widget,
+ GdkEventKey *event,
+ gpointer data);
static GtkWindowClass *parent_class = NULL;
@@ -127,6 +131,8 @@ gnome_volume_applet_dock_new (GtkOrientation orientation,
NULL);
dock->orientation = orientation;
dock->model = parent;
+ g_signal_connect (dock, "key_press_event", G_CALLBACK (cb_key_press),
+ NULL);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
@@ -275,6 +281,25 @@ cb_button_release (GtkWidget *widget,
return TRUE;
}
+static gboolean
+cb_key_press (GtkWidget *widget,
+ GdkEventKey *event,
+ gpointer data)
+{
+
+ /* Trap the escape key to popdown the dock. */
+ if (event->keyval == GDK_Escape) {
+ /* This is trickier than it looks. The main applet is watching for
+ * this widget to loose focus. Hiding the widget causes a
+ * focus-loss, thus the applet gets the focus-out signal and all
+ * the book-keeping gets done (like setting the applet button
+ * hilight) without an explicit callback. */
+ gtk_widget_hide (widget);
+ }
+
+ return FALSE;
+}
+
/*
* Set the adjustment for the slider.
*/