diff options
author | Andrea Cimitan <andrea.cimitan@canonical.com> | 2010-11-17 11:27:40 +0100 |
---|---|---|
committer | Andrea Cimitan <andrea.cimitan@canonical.com> | 2010-11-17 11:27:40 +0100 |
commit | f301b9c10c8e867acf076a3351060703d0049652 (patch) | |
tree | 166ad32c8fa113bf236d1b14ca576a1fe97bc056 /src/indicator-sound.c | |
parent | 9c5e8107b0d034a422e3397858a91c51b695f3f2 (diff) | |
download | ayatana-indicator-sound-f301b9c10c8e867acf076a3351060703d0049652.tar.gz ayatana-indicator-sound-f301b9c10c8e867acf076a3351060703d0049652.tar.bz2 ayatana-indicator-sound-f301b9c10c8e867acf076a3351060703d0049652.zip |
implementing the focus/key_press thing
Diffstat (limited to 'src/indicator-sound.c')
-rw-r--r-- | src/indicator-sound.c | 60 |
1 files changed, 54 insertions, 6 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c index b39d064..d4e5f3f 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -72,6 +72,7 @@ static void indicator_sound_scroll (IndicatorObject* io, gint delta, Indicato //Slider related static gboolean new_volume_slider_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data); +static gboolean key_release_cb(GtkWidget* widget, GdkEventKey* event, gpointer data); static void style_changed_cb(GtkWidget *widget, gpointer user_data); //player widget realisation methods @@ -222,7 +223,8 @@ get_menu (IndicatorObject * io) dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), DBUSMENU_TITLE_MENUITEM_TYPE, new_title_widget); // register Key-press listening on the menu widget as the slider does not allow this. g_signal_connect(menu, "key-press-event", G_CALLBACK(key_press_cb), io); - + g_signal_connect(menu, "key-release-event", G_CALLBACK(key_release_cb), io); + return GTK_MENU(menu); } @@ -718,17 +720,63 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) else if (IS_TRANSPORT_WIDGET(menuitem) == TRUE) { switch (event->keyval) { case GDK_Right: - transport_widget_react_to_key_event ( TRANSPORT_WIDGET ( priv->transport_widget ), - TRANSPORT_NEXT ); + transport_widget_react_to_key_press_event ( TRANSPORT_WIDGET ( priv->transport_widget ), + TRANSPORT_NEXT ); + digested = TRUE; + break; + case GDK_Left: + transport_widget_react_to_key_press_event ( TRANSPORT_WIDGET ( priv->transport_widget ), + TRANSPORT_PREVIOUS ); + digested = TRUE; + break; + case GDK_KEY_space: + transport_widget_react_to_key_press_event ( TRANSPORT_WIDGET ( priv->transport_widget ), + TRANSPORT_PLAY_PAUSE ); + digested = TRUE; + break; + case GDK_Up: + case GDK_Down: + digested = FALSE; + break; + default: + break; + } + } + return digested; +} + + +/** +key_release_cb: +**/ +static gboolean +key_release_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) +{ + gboolean digested = FALSE; + + g_return_val_if_fail(IS_INDICATOR_SOUND(data), FALSE); + + IndicatorSound *indicator = INDICATOR_SOUND (data); + + IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(indicator); + + GtkWidget *menuitem; + + menuitem = GTK_MENU_SHELL (widget)->active_menu_item; + if (IS_TRANSPORT_WIDGET(menuitem) == TRUE) { + switch (event->keyval) { + case GDK_Right: + transport_widget_react_to_key_release_event ( TRANSPORT_WIDGET ( priv->transport_widget ), + TRANSPORT_NEXT ); digested = TRUE; break; case GDK_Left: - transport_widget_react_to_key_event ( TRANSPORT_WIDGET ( priv->transport_widget ), - TRANSPORT_PREVIOUS ); + transport_widget_react_to_key_release_event ( TRANSPORT_WIDGET ( priv->transport_widget ), + TRANSPORT_PREVIOUS ); digested = TRUE; break; case GDK_KEY_space: - transport_widget_react_to_key_event ( TRANSPORT_WIDGET ( priv->transport_widget ), + transport_widget_react_to_key_release_event ( TRANSPORT_WIDGET ( priv->transport_widget ), TRANSPORT_PLAY_PAUSE ); digested = TRUE; break; |