aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-11-15 13:17:22 +0000
committerConor Curran <conor.curran@canonical.com>2010-11-15 13:17:22 +0000
commit41284d027bd0c0eeff0e83e10b365f98a6977f59 (patch)
tree5bf386df9dfcd316deafdfd218ec8c34aa599d30
parent5fd2c5e12a059ab8c59306676d18dfc56c818077 (diff)
downloadayatana-indicator-sound-41284d027bd0c0eeff0e83e10b365f98a6977f59.tar.gz
ayatana-indicator-sound-41284d027bd0c0eeff0e83e10b365f98a6977f59.tar.bz2
ayatana-indicator-sound-41284d027bd0c0eeff0e83e10b365f98a6977f59.zip
keyboard handling for the transport controls underway
-rw-r--r--src/indicator-sound.c33
-rw-r--r--src/sound-service.c4
-rw-r--r--src/transport-widget.c21
-rw-r--r--src/transport-widget.h2
4 files changed, 56 insertions, 4 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 13f1529..53a4876 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -47,6 +47,7 @@ typedef struct _IndicatorSoundPrivate IndicatorSoundPrivate;
struct _IndicatorSoundPrivate
{
GtkWidget* volume_widget;
+ GtkWidget* transport_widget;
};
#define INDICATOR_SOUND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_SOUND_TYPE, IndicatorSoundPrivate))
@@ -241,11 +242,16 @@ new_transport_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbus
//g_debug("indicator-sound: new_transport_bar() called ");
GtkWidget* bar = NULL;
+ IndicatorObject *io = NULL;
g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
bar = transport_widget_new(newitem);
+ io = g_object_get_data (G_OBJECT (client), "indicator");
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io));
+ priv->transport_widget = bar;
+
GtkMenuItem *menu_transport_bar = GTK_MENU_ITEM(bar);
gtk_widget_show_all(bar);
@@ -706,9 +712,34 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data)
new_value = CLAMP(new_value, 0, 100);
if (new_value != current_value && current_state != STATE_MUTED) {
//g_debug("Attempting to set the range from the key listener to %f", new_value);
- volume_widget_update(VOLUME_WIDGET(priv->volume_widget), new_value);
+ volume_widget_update(VOLUME_WIDGET(priv->volume_widget), new_value);
}
}
+ 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 );
+ digested = TRUE;
+ break;
+ case GDK_Left:
+ transport_widget_react_to_key_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_PLAY_PAUSE );
+ digested = TRUE;
+ break;
+ case GDK_Up:
+ case GDK_Down:
+ digested = FALSE;
+ break;
+ default:
+ break;
+ }
+ }
return digested;
}
diff --git a/src/sound-service.c b/src/sound-service.c
index f19379d..51f5f37 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -41,8 +41,8 @@ service_shutdown (IndicatorService *service, gpointer user_data)
if (mainloop != NULL) {
g_debug("Service shutdown !");
//TODO: uncomment for release !!
- close_pulse_activites();
- g_main_loop_quit(mainloop);
+ //close_pulse_activites();
+ //g_main_loop_quit(mainloop);
}
return;
}
diff --git a/src/transport-widget.c b/src/transport-widget.c
index 26b7a98..3329acc 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -270,7 +270,6 @@ transport_widget_button_release_event (GtkWidget *menuitem,
g_return_val_if_fail(IS_TRANSPORT_WIDGET(menuitem), FALSE);
TransportWidget* transport = TRANSPORT_WIDGET(menuitem);
TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE ( transport );
-
TransportWidgetEvent result = transport_widget_determine_button_event ( transport,
event );
if(result != TRANSPORT_NADA){
@@ -289,6 +288,26 @@ transport_widget_button_release_event (GtkWidget *menuitem,
return TRUE;
}
+void
+transport_widget_react_to_key_event ( TransportWidget* transport,
+ TransportWidgetEvent transport_event )
+{
+ if(transport_event != TRANSPORT_NADA){
+ TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE ( transport );
+ GValue value = {0};
+ g_value_init(&value, G_TYPE_INT);
+ //g_debug("TransportWidget::menu_press_event - going to send value %i", (int)result);
+ g_value_set_int(&value, (int)transport_event);
+ dbusmenu_menuitem_handle_event ( priv->twin_item,
+ "Transport state change",
+ &value,
+ 0 );
+ }
+
+ transport_widget_react_to_button_release ( transport,
+ transport_event );
+}
+
static TransportWidgetEvent
transport_widget_determine_button_event( TransportWidget* button,
GdkEventButton* event )
diff --git a/src/transport-widget.h b/src/transport-widget.h
index 6ccce05..470b1cd 100644
--- a/src/transport-widget.h
+++ b/src/transport-widget.h
@@ -66,6 +66,8 @@ typedef struct
void _color_shade (const CairoColorRGB *a, float k, CairoColorRGB *b);
GType transport_widget_get_type (void);
GtkWidget* transport_widget_new ( DbusmenuMenuitem *item );
+void transport_widget_react_to_key_event ( TransportWidget* widget,
+ TransportWidgetEvent transport_event );
G_END_DECLS