aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-11-17 15:34:27 +0000
committerConor Curran <conor.curran@canonical.com>2010-11-17 15:34:27 +0000
commit237041021ddb7d0c08542fbdca41d845b14dea82 (patch)
tree807f0748ed1af6a9f482356d1c24742346ca1ba6
parentca946b13d56c7df56d30c8824baf8e943b07dd3e (diff)
downloadayatana-indicator-sound-237041021ddb7d0c08542fbdca41d845b14dea82.tar.gz
ayatana-indicator-sound-237041021ddb7d0c08542fbdca41d845b14dea82.tar.bz2
ayatana-indicator-sound-237041021ddb7d0c08542fbdca41d845b14dea82.zip
fixed the crashes and made the key presss/release work nicely with multiple players
-rw-r--r--src/indicator-sound.c44
-rw-r--r--src/transport-widget.c24
-rw-r--r--src/transport-widget.h1
3 files changed, 54 insertions, 15 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index d4e5f3f..7797f49 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -47,7 +47,7 @@ typedef struct _IndicatorSoundPrivate IndicatorSoundPrivate;
struct _IndicatorSoundPrivate
{
GtkWidget* volume_widget;
- GtkWidget* transport_widget;
+ GList* transport_widgets_list;
};
#define INDICATOR_SOUND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_SOUND_TYPE, IndicatorSoundPrivate))
@@ -156,6 +156,8 @@ indicator_sound_init (IndicatorSound *self)
IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
priv->volume_widget = NULL;
+ GList* t_list = NULL;
+ priv->transport_widgets_list = t_list;
g_signal_connect(G_OBJECT(self->service),
INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE,
@@ -176,6 +178,10 @@ indicator_sound_dispose (GObject *object)
free_the_animation_list();
+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (self));
+
+ g_list_free ( priv->transport_widgets_list );
+
G_OBJECT_CLASS (indicator_sound_parent_class)->dispose (object);
return;
}
@@ -252,7 +258,7 @@ new_transport_widget(DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbus
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;
+ priv->transport_widgets_list = g_list_append ( priv->transport_widgets_list, bar );
GtkMenuItem *menu_transport_bar = GTK_MENU_ITEM(bar);
@@ -718,19 +724,28 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data)
}
}
else if (IS_TRANSPORT_WIDGET(menuitem) == TRUE) {
+ TransportWidget* transport_widget;
+ GList* elem;
+
+ for ( elem = priv->transport_widgets_list; elem; elem = elem->next ) {
+ transport_widget = TRANSPORT_WIDGET ( elem->data );
+ if ( transport_widget_is_selected( transport_widget ) )
+ break;
+ }
+
switch (event->keyval) {
case GDK_Right:
- transport_widget_react_to_key_press_event ( TRANSPORT_WIDGET ( priv->transport_widget ),
+ transport_widget_react_to_key_press_event ( transport_widget,
TRANSPORT_NEXT );
digested = TRUE;
break;
case GDK_Left:
- transport_widget_react_to_key_press_event ( TRANSPORT_WIDGET ( priv->transport_widget ),
+ transport_widget_react_to_key_press_event ( transport_widget,
TRANSPORT_PREVIOUS );
digested = TRUE;
break;
case GDK_KEY_space:
- transport_widget_react_to_key_press_event ( TRANSPORT_WIDGET ( priv->transport_widget ),
+ transport_widget_react_to_key_press_event ( transport_widget,
TRANSPORT_PLAY_PAUSE );
digested = TRUE;
break;
@@ -764,20 +779,29 @@ key_release_cb(GtkWidget* widget, GdkEventKey* event, gpointer data)
menuitem = GTK_MENU_SHELL (widget)->active_menu_item;
if (IS_TRANSPORT_WIDGET(menuitem) == TRUE) {
+ TransportWidget* transport_widget;
+ GList* elem;
+
+ for(elem = priv->transport_widgets_list; elem; elem = elem->next) {
+ transport_widget = TRANSPORT_WIDGET (elem->data);
+ if ( transport_widget_is_selected( transport_widget ) )
+ break;
+ }
+
switch (event->keyval) {
case GDK_Right:
- transport_widget_react_to_key_release_event ( TRANSPORT_WIDGET ( priv->transport_widget ),
+ transport_widget_react_to_key_release_event ( transport_widget,
TRANSPORT_NEXT );
- digested = TRUE;
+ digested = TRUE;
break;
case GDK_Left:
- transport_widget_react_to_key_release_event ( TRANSPORT_WIDGET ( priv->transport_widget ),
+ transport_widget_react_to_key_release_event ( transport_widget,
TRANSPORT_PREVIOUS );
digested = TRUE;
break;
case GDK_KEY_space:
- transport_widget_react_to_key_release_event ( TRANSPORT_WIDGET ( priv->transport_widget ),
- TRANSPORT_PLAY_PAUSE );
+ transport_widget_react_to_key_release_event ( transport_widget,
+ TRANSPORT_PLAY_PAUSE );
digested = TRUE;
break;
case GDK_Up:
diff --git a/src/transport-widget.c b/src/transport-widget.c
index 8b42bd0..64ac04a 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -193,8 +193,9 @@ transport_widget_init (TransportWidget *self)
g_signal_connect (GTK_ITEM(self),
"deselect",
G_CALLBACK (transport_widget_deselect),
- NULL);
-
+ NULL);
+ gtk_widget_realize ( GTK_WIDGET (self) );
+
}
static void
@@ -227,6 +228,13 @@ transport_widget_expose (GtkWidget *button, GdkEventExpose *event)
return FALSE;
}
+gboolean
+transport_widget_is_selected ( TransportWidget* widget )
+{
+ TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(widget);
+ return priv->has_focus;
+}
+
static void
transport_widget_toggle_play_pause(TransportWidget* button,
TransportWidgetState update)
@@ -330,10 +338,14 @@ transport_widget_react_to_key_press_event ( TransportWidget* transport,
priv->current_command = transport_event;
priv->key_event = transport_event;
+ printf ( "transport widget - react to key press event -> is the window null: %i",
+ gtk_widget_get_window (GTK_WIDGET (transport) ) == NULL );
cairo_t *cr;
+
+ printf("transport_widget_react_to_key_press_event: before drawing\n");
cr = gdk_cairo_create ( GTK_WIDGET(transport)->window );
draw ( GTK_WIDGET(transport), cr );
- cairo_destroy (cr);
+ cairo_destroy (cr);
}
}
@@ -352,7 +364,7 @@ transport_widget_react_to_key_release_event ( TransportWidget* transport,
&value,
0 );
}
-
+ printf("transport_widget_react_to_key_release_event: before transport_widget_react_to_key_release_event\n");
transport_widget_react_to_button_release ( transport,
transport_event );
}
@@ -397,14 +409,16 @@ transport_widget_react_to_button_release ( TransportWidget* button,
TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(button);
if(priv->current_command == TRANSPORT_NADA){
//g_debug("returning from the playbutton release because my previous command was nada");
-
+ printf("transport_widget_react_to_button_release: inside if(priv->current_command == TRANSPORT_NADA)\n");
/* Update the drawing in any case, should not hurt :) */
// return;
}
else if(priv->current_command != TRANSPORT_NADA &&
command != TRANSPORT_NADA){
priv->current_command = command;
+ printf("transport_widget_react_to_button_release: inside if(priv->current_command != TRANSPORT_NADA && command != TRANSPORT_NADA)\n");
}
+ printf("transport_widget_react_to_button_release: before drawing\n");
cairo_t *cr;
cr = gdk_cairo_create ( GTK_WIDGET(button)->window );
diff --git a/src/transport-widget.h b/src/transport-widget.h
index 7c087fb..70ce6aa 100644
--- a/src/transport-widget.h
+++ b/src/transport-widget.h
@@ -70,6 +70,7 @@ void transport_widget_react_to_key_press_event ( TransportWidget* widget,
TransportWidgetEvent transport_event );
void transport_widget_react_to_key_release_event ( TransportWidget* widget,
TransportWidgetEvent transport_event );
+gboolean transport_widget_is_selected ( TransportWidget* widget );
G_END_DECLS
#endif