aboutsummaryrefslogtreecommitdiff
path: root/src/transport-widget.c
diff options
context:
space:
mode:
authorAndrea Cimitan <andrea.cimitan@canonical.com>2010-11-16 02:17:44 +0100
committerAndrea Cimitan <andrea.cimitan@canonical.com>2010-11-16 02:17:44 +0100
commit510a01f7c97b726cd9ee46ffa30d3b0383b36146 (patch)
tree3c8a8cde441abfee25a98716e82febb228c3e30e /src/transport-widget.c
parent31bc33331673b761ba7d6e28bbb87da6b2e6e51a (diff)
parenteaee3afe6312a04ce41daed8d380ac5e49616ed6 (diff)
downloadayatana-indicator-sound-510a01f7c97b726cd9ee46ffa30d3b0383b36146.tar.gz
ayatana-indicator-sound-510a01f7c97b726cd9ee46ffa30d3b0383b36146.tar.bz2
ayatana-indicator-sound-510a01f7c97b726cd9ee46ffa30d3b0383b36146.zip
merge from lp:~cjcurran/indicator-sound/keyboard-handling-for-natty
Diffstat (limited to 'src/transport-widget.c')
-rw-r--r--src/transport-widget.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/src/transport-widget.c b/src/transport-widget.c
index cbe9154..dc79221 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -80,6 +80,7 @@ struct _TransportWidgetPrivate
TransportWidgetState current_state;
GHashTable* command_coordinates;
DbusmenuMenuitem* twin_item;
+ gboolean has_focus;
};
#define TRANSPORT_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRANSPORT_WIDGET_TYPE, TransportWidgetPrivate))
@@ -117,6 +118,9 @@ static void transport_widget_react_to_button_release ( TransportWidget* button,
TransportWidgetEvent command);
static void transport_widget_toggle_play_pause ( TransportWidget* button,
TransportWidgetState update);
+static void transport_widget_select (GtkItem* menu, gpointer Userdata);
+static void transport_widget_deselect (GtkItem* menu, gpointer Userdata);
+
/// Init functions //////////////////////////////////////////////////////////
@@ -142,6 +146,7 @@ transport_widget_init (TransportWidget *self)
TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(self);
priv->current_command = TRANSPORT_NADA;
priv->current_state = PAUSE;
+ priv->has_focus = FALSE;
priv->command_coordinates = g_hash_table_new_full(g_direct_hash,
g_direct_equal,
NULL,
@@ -174,12 +179,20 @@ transport_widget_init (TransportWidget *self)
g_hash_table_insert(priv->command_coordinates,
GINT_TO_POINTER(TRANSPORT_NEXT),
next_list);
-
gtk_widget_set_size_request(GTK_WIDGET(self), 200, 43);
g_signal_connect (G_OBJECT(self),
"notify",
G_CALLBACK (transport_widget_notify),
- NULL);
+ NULL);
+ g_signal_connect (GTK_ITEM(self),
+ "select",
+ G_CALLBACK (transport_widget_select),
+ NULL);
+ g_signal_connect (GTK_ITEM(self),
+ "deselect",
+ G_CALLBACK (transport_widget_deselect),
+ NULL);
+
}
static void
@@ -252,7 +265,6 @@ transport_widget_button_press_event (GtkWidget *menuitem,
{
g_return_val_if_fail ( IS_TRANSPORT_WIDGET(menuitem), FALSE );
TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE ( TRANSPORT_WIDGET(menuitem) );
-
TransportWidgetEvent result = transport_widget_determine_button_event ( TRANSPORT_WIDGET(menuitem),
event);
if(result != TRANSPORT_NADA){
@@ -285,12 +297,27 @@ transport_widget_button_release_event (GtkWidget *menuitem,
&value,
0 );
}
-
transport_widget_react_to_button_release ( transport,
result );
return TRUE;
}
+static void
+transport_widget_select (GtkItem* item, gpointer Userdata)
+{
+ TransportWidget* transport = TRANSPORT_WIDGET(item);
+ TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE ( transport );
+ priv->has_focus = TRUE;
+}
+
+static void
+transport_widget_deselect (GtkItem* item, gpointer Userdata)
+{
+ TransportWidget* transport = TRANSPORT_WIDGET(item);
+ TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE ( transport );
+ priv->has_focus = FALSE;
+}
+
void
transport_widget_react_to_key_event ( TransportWidget* transport,
TransportWidgetEvent transport_event )
@@ -311,6 +338,14 @@ transport_widget_react_to_key_event ( TransportWidget* transport,
transport_event );
}
+void
+transport_widget_focus_update ( TransportWidget* transport, gboolean focus )
+{
+ TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE ( transport );
+ priv->has_focus = focus;
+ g_debug("new focus update = %i", focus);
+}
+
static TransportWidgetEvent
transport_widget_determine_button_event( TransportWidget* button,
GdkEventButton* event )