aboutsummaryrefslogtreecommitdiff
path: root/src/transport-widget.c
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-11-15 17:18:19 +0000
committerConor Curran <conor.curran@canonical.com>2010-11-15 17:18:19 +0000
commiteaee3afe6312a04ce41daed8d380ac5e49616ed6 (patch)
tree63102d9a835f95b9a4314f1af2c75a17577a92d0 /src/transport-widget.c
parent41284d027bd0c0eeff0e83e10b365f98a6977f59 (diff)
downloadayatana-indicator-sound-eaee3afe6312a04ce41daed8d380ac5e49616ed6.tar.gz
ayatana-indicator-sound-eaee3afe6312a04ce41daed8d380ac5e49616ed6.tar.bz2
ayatana-indicator-sound-eaee3afe6312a04ce41daed8d380ac5e49616ed6.zip
key handling all set up
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 3329acc..63fec4b 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -77,6 +77,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))
@@ -114,6 +115,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 //////////////////////////////////////////////////////////
@@ -139,6 +143,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,
@@ -171,12 +176,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
@@ -249,7 +262,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){
@@ -282,12 +294,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 )
@@ -308,6 +335,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 )