From ee981578fa2261bdea4a3c6bd0beaf89e7ed11e8 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 12 Nov 2010 18:00:37 +0000 Subject: icon loading now assumes there is an app name plus -panel lying around from the theme --- src/title-widget.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/title-widget.c b/src/title-widget.c index 5bc2a93..73f846a 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -32,7 +32,7 @@ typedef struct _TitleWidgetPrivate TitleWidgetPrivate; struct _TitleWidgetPrivate { - DbusmenuMenuitem* twin_item; + DbusmenuMenuitem* twin_item; }; #define TITLE_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TITLE_WIDGET_TYPE, TitleWidgetPrivate)) @@ -83,25 +83,23 @@ title_widget_set_icon(TitleWidget *self) { TitleWidgetPrivate *priv = TITLE_WIDGET_GET_PRIVATE(self); - gchar* icon_name = g_strdup(dbusmenu_menuitem_property_get(priv->twin_item, - DBUSMENU_TITLE_MENUITEM_ICON)); gint padding = 0; gtk_widget_style_get(GTK_WIDGET(self), "horizontal-padding", &padding, NULL); gint width, height; gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); - - GtkWidget * icon = gtk_image_new_from_icon_name(icon_name, - GTK_ICON_SIZE_MENU); - - gtk_widget_set_size_request(icon, width + GString* app_panel = g_string_new ( g_utf8_strdown ( dbusmenu_menuitem_property_get(priv->twin_item, DBUSMENU_TITLE_MENUITEM_NAME), + -1 )); + g_string_append(app_panel, "-panel"); + GtkWidget * icon = gtk_image_new_from_icon_name( g_string_free ( app_panel, FALSE), + GTK_ICON_SIZE_MENU ); + gtk_widget_set_size_request(icon, width + 5 /* ref triangle is 5x9 pixels */ + 1 /* padding */, height); gtk_misc_set_alignment(GTK_MISC(icon), 0.5 /* right aligned */, 0); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(self), GTK_WIDGET(icon)); gtk_widget_show(icon); - g_free(icon_name); } static void -- cgit v1.2.3 From 41284d027bd0c0eeff0e83e10b365f98a6977f59 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 15 Nov 2010 13:17:22 +0000 Subject: keyboard handling for the transport controls underway --- src/indicator-sound.c | 33 ++++++++++++++++++++++++++++++++- src/sound-service.c | 4 ++-- src/transport-widget.c | 21 ++++++++++++++++++++- src/transport-widget.h | 2 ++ 4 files changed, 56 insertions(+), 4 deletions(-) (limited to 'src') 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 -- cgit v1.2.3 From eaee3afe6312a04ce41daed8d380ac5e49616ed6 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 15 Nov 2010 17:18:19 +0000 Subject: key handling all set up --- src/indicator-sound.c | 3 +-- src/sound-service.c | 4 ++-- src/transport-widget.c | 43 +++++++++++++++++++++++++++++++++++++++---- src/transport-widget.h | 1 - 4 files changed, 42 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 53a4876..b39d064 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -715,7 +715,7 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) volume_widget_update(VOLUME_WIDGET(priv->volume_widget), new_value); } } - if (IS_TRANSPORT_WIDGET(menuitem) == TRUE) { + else if (IS_TRANSPORT_WIDGET(menuitem) == TRUE) { switch (event->keyval) { case GDK_Right: transport_widget_react_to_key_event ( TRANSPORT_WIDGET ( priv->transport_widget ), @@ -761,7 +761,6 @@ indicator_sound_scroll (IndicatorObject *io, gint delta, IndicatorScrollDirectio if (device_available == FALSE || current_state == STATE_MUTED) return; - IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io)); GtkWidget* slider_widget = volume_widget_get_ido_slider(VOLUME_WIDGET(priv->volume_widget)); diff --git a/src/sound-service.c b/src/sound-service.c index 51f5f37..f19379d 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 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 ) diff --git a/src/transport-widget.h b/src/transport-widget.h index 470b1cd..58a224c 100644 --- a/src/transport-widget.h +++ b/src/transport-widget.h @@ -68,7 +68,6 @@ 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 #endif -- cgit v1.2.3 From 225bdefba8a4b98f8ca126ddf33bc1fe9b062ea8 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Tue, 16 Nov 2010 11:13:23 +0100 Subject: focus the play button --- src/transport-widget.c | 89 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 70 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/transport-widget.c b/src/transport-widget.c index dc79221..b08ce1a 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -645,6 +645,28 @@ _finalize (cairo_t* cr, cairo_destroy (*cr_surf); } +static void +_finalize_repaint (cairo_t* cr, + cairo_t** cr_surf, + cairo_surface_t** surf, + double x, + double y, + int repaints) +{ + if (!cr || !cr_surf || !surf) + return; + + while (repaints > 0) + { + cairo_set_source_surface (cr, *surf, x, y); + cairo_paint (cr); + repaints--; + } + + cairo_surface_destroy (*surf); + cairo_destroy (*cr_surf); +} + static void _color_rgb_to_hls (gdouble *r, gdouble *g, @@ -1063,8 +1085,8 @@ draw (GtkWidget* button, cairo_t *cr) GtkStyle *style; - CairoColorRGB bg_color, fg_color; - CairoColorRGB color_inner[2], color_middle[2], color_outer[2], color_button[3], color_button_outer[2], color_button_shadow, color_inner_compressed[2]; + CairoColorRGB bg_color, fg_color, bg_selected; + CairoColorRGB color_inner[2], color_middle[2], color_outer[2], color_button[4], color_button_outer[2], color_button_shadow, color_inner_compressed[2]; style = gtk_widget_get_style (button); @@ -1073,6 +1095,10 @@ draw (GtkWidget* button, cairo_t *cr) bg_color.g = style->bg[0].green/65535.0; bg_color.b = style->bg[0].blue/65535.0; + bg_selected.r = style->bg[GTK_STATE_SELECTED].red/65535.0; + bg_selected.g = style->bg[GTK_STATE_SELECTED].green/65535.0; + bg_selected.b = style->bg[GTK_STATE_SELECTED].blue/65535.0; + fg_color.r = style->fg[0].red/65535.0; fg_color.g = style->fg[0].green/65535.0; fg_color.b = style->fg[0].blue/65535.0; @@ -1089,6 +1115,7 @@ draw (GtkWidget* button, cairo_t *cr) _color_shade (&fg_color, BUTTON_START_SHADE, &color_button[0]); _color_shade (&fg_color, BUTTON_END_SHADE, &color_button[1]); _color_shade (&bg_color, BUTTON_SHADOW_SHADE, &color_button[2]); + _color_shade (&bg_selected, 1.0, &color_button[3]); _color_shade (&bg_color, INNER_COMPRESSED_START_SHADE, &color_inner_compressed[0]); _color_shade (&bg_color, INNER_COMPRESSED_END_SHADE, &color_inner_compressed[1]); @@ -1102,6 +1129,7 @@ draw (GtkWidget* button, cairo_t *cr) double BUTTON_END[] = {color_button[0].r, color_button[0].g, color_button[0].b, 1.0f}; double BUTTON_START[] = {color_button[1].r, color_button[1].g, color_button[1].b, 1.0f}; double BUTTON_SHADOW[] = {color_button[2].r, color_button[2].g, color_button[2].b, 0.75f}; + double BUTTON_SHADOW_FOCUS[] = {color_button[3].r, color_button[3].g, color_button[3].b, 1.0f}; double INNER_COMPRESSED_END[] = {color_inner_compressed[1].r, color_inner_compressed[1].g, color_inner_compressed[1].b, 1.0f}; double INNER_COMPRESSED_START[] = {color_inner_compressed[0].r, color_inner_compressed[0].g, color_inner_compressed[0].b, 1.0f}; @@ -1195,6 +1223,7 @@ draw (GtkWidget* button, cairo_t *cr) SHADOW_BUTTON, SHADOW_BUTTON); } + // play/pause border if(priv->current_command == TRANSPORT_PLAY_PAUSE){ draw_circle (cr, @@ -1323,7 +1352,7 @@ draw (GtkWidget* button, cairo_t *cr) BUTTON_SHADOW, TRUE); _surface_blur (surf, 1); - _finalize (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y + 1.0f); + _finalize_repaint (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y + 1.0f, 3); // draw pause-button _setup (&cr_surf, &surf, PAUSE_WIDTH, PAUSE_HEIGHT); @@ -1344,22 +1373,44 @@ draw (GtkWidget* button, cairo_t *cr) _finalize (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y); } else if(priv->current_state == PAUSE){ - _setup (&cr_surf, &surf, PLAY_WIDTH, PLAY_HEIGHT); - _mask_play (cr_surf, - PLAY_PADDING, - PLAY_PADDING, - PLAY_WIDTH - (2*PLAY_PADDING), - PLAY_HEIGHT - (2*PLAY_PADDING)); - _fill (cr_surf, - PLAY_PADDING, - PLAY_PADDING, - PLAY_WIDTH - (2*PLAY_PADDING), - PLAY_HEIGHT - (2*PLAY_PADDING), - BUTTON_SHADOW, - BUTTON_SHADOW, - FALSE); - _surface_blur (surf, 1); - _finalize (cr, &cr_surf, &surf, PAUSE_X-0.75f, PAUSE_Y + 1.0f); + if (priv->has_focus) + { + _setup (&cr_surf, &surf, PLAY_WIDTH+6, PLAY_HEIGHT+6); + _mask_play (cr_surf, + PLAY_PADDING, + PLAY_PADDING, + PLAY_WIDTH - (2*PLAY_PADDING), + PLAY_HEIGHT - (2*PLAY_PADDING)); + _fill (cr_surf, + PLAY_PADDING, + PLAY_PADDING, + PLAY_WIDTH - (2*PLAY_PADDING), + PLAY_HEIGHT - (2*PLAY_PADDING), + BUTTON_SHADOW_FOCUS, + BUTTON_SHADOW_FOCUS, + FALSE); + _surface_blur (surf, 3); + _finalize_repaint (cr, &cr_surf, &surf, PAUSE_X-0.5f, PAUSE_Y + 0.5f, 3); + } + else + { + _setup (&cr_surf, &surf, PLAY_WIDTH, PLAY_HEIGHT); + _mask_play (cr_surf, + PLAY_PADDING, + PLAY_PADDING, + PLAY_WIDTH - (2*PLAY_PADDING), + PLAY_HEIGHT - (2*PLAY_PADDING)); + _fill (cr_surf, + PLAY_PADDING, + PLAY_PADDING, + PLAY_WIDTH - (2*PLAY_PADDING), + PLAY_HEIGHT - (2*PLAY_PADDING), + BUTTON_SHADOW, + BUTTON_SHADOW, + FALSE); + _surface_blur (surf, 1); + _finalize (cr, &cr_surf, &surf, PAUSE_X-0.75f, PAUSE_Y + 1.0f); + } // draw play-button _setup (&cr_surf, &surf, PLAY_WIDTH, PLAY_HEIGHT); cairo_set_line_width (cr, 10.5); -- cgit v1.2.3 From 9c5e8107b0d034a422e3397858a91c51b695f3f2 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Tue, 16 Nov 2010 11:24:23 +0100 Subject: applied to all buttons --- src/transport-widget.c | 171 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 120 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/transport-widget.c b/src/transport-widget.c index b08ce1a..88a352d 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -1261,23 +1261,46 @@ draw (GtkWidget* button, cairo_t *cr) } // draw previous-button drop-shadow - _setup (&cr_surf, &surf, PREV_WIDTH, PREV_HEIGHT); - _mask_prev (cr_surf, - (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, - (PREV_HEIGHT - TRI_HEIGHT) / 2.0f, - TRI_WIDTH, - TRI_HEIGHT, - TRI_OFFSET); - _fill (cr_surf, - (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, - (PREV_HEIGHT - TRI_HEIGHT) / 2.0f, - (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, - (double) TRI_HEIGHT, - BUTTON_SHADOW, - BUTTON_SHADOW, - FALSE); - _surface_blur (surf, 1); - _finalize (cr, &cr_surf, &surf, PREV_X, PREV_Y + 1.0f); + if (priv->has_focus) + { + _setup (&cr_surf, &surf, PREV_WIDTH+6, PREV_HEIGHT+6); + _mask_prev (cr_surf, + (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (PREV_HEIGHT - TRI_HEIGHT) / 2.0f, + TRI_WIDTH, + TRI_HEIGHT, + TRI_OFFSET); + _fill (cr_surf, + (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (PREV_HEIGHT - TRI_HEIGHT) / 2.0f, + (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (double) TRI_HEIGHT, + BUTTON_SHADOW_FOCUS, + BUTTON_SHADOW_FOCUS, + FALSE); + _surface_blur (surf, 3); + _finalize_repaint (cr, &cr_surf, &surf, PREV_X, PREV_Y + 0.5f, 3); + } + else + { + _setup (&cr_surf, &surf, PREV_WIDTH, PREV_HEIGHT); + _mask_prev (cr_surf, + (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (PREV_HEIGHT - TRI_HEIGHT) / 2.0f, + TRI_WIDTH, + TRI_HEIGHT, + TRI_OFFSET); + _fill (cr_surf, + (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (PREV_HEIGHT - TRI_HEIGHT) / 2.0f, + (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (double) TRI_HEIGHT, + BUTTON_SHADOW, + BUTTON_SHADOW, + FALSE); + _surface_blur (surf, 1); + _finalize (cr, &cr_surf, &surf, PREV_X, PREV_Y + 1.0f); + } // draw previous-button _setup (&cr_surf, &surf, PREV_WIDTH, PREV_HEIGHT); @@ -1298,23 +1321,46 @@ draw (GtkWidget* button, cairo_t *cr) _finalize (cr, &cr_surf, &surf, PREV_X, PREV_Y); // draw next-button drop-shadow - _setup (&cr_surf, &surf, NEXT_WIDTH, NEXT_HEIGHT); - _mask_next (cr_surf, - (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, - (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f, - TRI_WIDTH, - TRI_HEIGHT, - TRI_OFFSET); - _fill (cr_surf, - (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, - (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f, - (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, - (double) TRI_HEIGHT, - BUTTON_SHADOW, - BUTTON_SHADOW, - FALSE); - _surface_blur (surf, 1); - _finalize (cr, &cr_surf, &surf, NEXT_X, NEXT_Y + 1.0f); + if (priv->has_focus) + { + _setup (&cr_surf, &surf, NEXT_WIDTH+6, NEXT_HEIGHT+6); + _mask_next (cr_surf, + (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f, + TRI_WIDTH, + TRI_HEIGHT, + TRI_OFFSET); + _fill (cr_surf, + (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f, + (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (double) TRI_HEIGHT, + BUTTON_SHADOW_FOCUS, + BUTTON_SHADOW_FOCUS, + FALSE); + _surface_blur (surf, 3); + _finalize_repaint (cr, &cr_surf, &surf, NEXT_X, NEXT_Y + 0.5f, 3); + } + else + { + _setup (&cr_surf, &surf, NEXT_WIDTH, NEXT_HEIGHT); + _mask_next (cr_surf, + (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f, + TRI_WIDTH, + TRI_HEIGHT, + TRI_OFFSET); + _fill (cr_surf, + (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f, + (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (double) TRI_HEIGHT, + BUTTON_SHADOW, + BUTTON_SHADOW, + FALSE); + _surface_blur (surf, 1); + _finalize (cr, &cr_surf, &surf, NEXT_X, NEXT_Y + 1.0f); + } // draw next-button _setup (&cr_surf, &surf, NEXT_WIDTH, NEXT_HEIGHT); @@ -1336,23 +1382,46 @@ draw (GtkWidget* button, cairo_t *cr) // draw pause-button drop-shadow if(priv->current_state == PLAY){ - _setup (&cr_surf, &surf, PAUSE_WIDTH, PAUSE_HEIGHT); - _mask_pause (cr_surf, - (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, - (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, - BAR_WIDTH, - BAR_HEIGHT - 2.0f * BAR_WIDTH, - BAR_OFFSET); - _fill (cr_surf, - (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, - (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, - (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, - (double) BAR_HEIGHT, - BUTTON_SHADOW, - BUTTON_SHADOW, - TRUE); - _surface_blur (surf, 1); - _finalize_repaint (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y + 1.0f, 3); + if (priv->has_focus) + { + _setup (&cr_surf, &surf, PAUSE_WIDTH+6, PAUSE_HEIGHT+6); + _mask_pause (cr_surf, + (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, + (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, + BAR_WIDTH, + BAR_HEIGHT - 2.0f * BAR_WIDTH, + BAR_OFFSET); + _fill (cr_surf, + (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, + (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, + (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, + (double) BAR_HEIGHT, + BUTTON_SHADOW_FOCUS, + BUTTON_SHADOW_FOCUS, + TRUE); + _surface_blur (surf, 3); + _finalize_repaint (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y + 0.5f, 3); + } + else + { + _setup (&cr_surf, &surf, PAUSE_WIDTH, PAUSE_HEIGHT); + _mask_pause (cr_surf, + (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, + (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, + BAR_WIDTH, + BAR_HEIGHT - 2.0f * BAR_WIDTH, + BAR_OFFSET); + _fill (cr_surf, + (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, + (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, + (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, + (double) BAR_HEIGHT, + BUTTON_SHADOW, + BUTTON_SHADOW, + TRUE); + _surface_blur (surf, 1); + _finalize (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y + 1.0f); + } // draw pause-button _setup (&cr_surf, &surf, PAUSE_WIDTH, PAUSE_HEIGHT); -- cgit v1.2.3 From 6c882bee8faa60b3eeac4246adfcfdc10a5cadbf Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 16 Nov 2010 19:52:02 +0000 Subject: title widget icon implemented as discussed at uds --- src/title-widget.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/title-widget.c b/src/title-widget.c index 73f846a..0754958 100644 --- a/src/title-widget.c +++ b/src/title-widget.c @@ -85,23 +85,40 @@ title_widget_set_icon(TitleWidget *self) gint padding = 0; gtk_widget_style_get(GTK_WIDGET(self), "horizontal-padding", &padding, NULL); - gint width, height; gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); + + GString* banshee_string = g_string_new ( "banshee" ); GString* app_panel = g_string_new ( g_utf8_strdown ( dbusmenu_menuitem_property_get(priv->twin_item, DBUSMENU_TITLE_MENUITEM_NAME), - -1 )); - g_string_append(app_panel, "-panel"); - GtkWidget * icon = gtk_image_new_from_icon_name( g_string_free ( app_panel, FALSE), - GTK_ICON_SIZE_MENU ); + -1 )); + GtkWidget * icon = NULL; + + // Not ideal but apparently we want the banshee icon to be the greyscale one + // and any others to be the icon from the desktop file => colour. + if ( g_string_equal ( banshee_string, app_panel ) == TRUE && + gtk_icon_theme_has_icon ( gtk_icon_theme_get_default(), app_panel->str ) ){ + g_string_append ( app_panel, "-panel" ); + icon = gtk_image_new_from_icon_name ( app_panel->str, + GTK_ICON_SIZE_MENU ); + } + else{ + icon = gtk_image_new_from_icon_name ( g_strdup (dbusmenu_menuitem_property_get ( priv->twin_item, DBUSMENU_TITLE_MENUITEM_ICON )), + GTK_ICON_SIZE_MENU ); + } + g_string_free ( app_panel, FALSE) ; + g_string_free ( banshee_string, FALSE) ; + gtk_widget_set_size_request(icon, width + 5 /* ref triangle is 5x9 pixels */ + 1 /* padding */, height); gtk_misc_set_alignment(GTK_MISC(icon), 0.5 /* right aligned */, 0); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(self), GTK_WIDGET(icon)); - gtk_widget_show(icon); + gtk_widget_show(icon); } + + static void title_widget_dispose (GObject *object) { -- cgit v1.2.3 From f301b9c10c8e867acf076a3351060703d0049652 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Wed, 17 Nov 2010 11:27:40 +0100 Subject: implementing the focus/key_press thing --- src/indicator-sound.c | 60 +++++++++++++++++++++++++++++++++++++++++++++----- src/transport-widget.c | 40 +++++++++++++++++++++++++-------- src/transport-widget.h | 6 +++-- 3 files changed, 89 insertions(+), 17 deletions(-) (limited to 'src') 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; diff --git a/src/transport-widget.c b/src/transport-widget.c index 88a352d..8c674a6 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -77,6 +77,7 @@ typedef struct _TransportWidgetPrivate TransportWidgetPrivate; struct _TransportWidgetPrivate { TransportWidgetEvent current_command; + TransportWidgetEvent key_event; TransportWidgetState current_state; GHashTable* command_coordinates; DbusmenuMenuitem* twin_item; @@ -146,6 +147,7 @@ transport_widget_init (TransportWidget *self) TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(self); priv->current_command = TRANSPORT_NADA; priv->current_state = PAUSE; + priv->key_event = TRANSPORT_NADA; priv->has_focus = FALSE; priv->command_coordinates = g_hash_table_new_full(g_direct_hash, g_direct_equal, @@ -267,6 +269,7 @@ transport_widget_button_press_event (GtkWidget *menuitem, TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE ( TRANSPORT_WIDGET(menuitem) ); TransportWidgetEvent result = transport_widget_determine_button_event ( TRANSPORT_WIDGET(menuitem), event); + if(result != TRANSPORT_NADA){ priv->current_command = result; cairo_t *cr; @@ -319,8 +322,24 @@ transport_widget_deselect (GtkItem* item, gpointer Userdata) } void -transport_widget_react_to_key_event ( TransportWidget* transport, - TransportWidgetEvent transport_event ) +transport_widget_react_to_key_press_event ( TransportWidget* transport, + TransportWidgetEvent transport_event ) +{ + if(transport_event != TRANSPORT_NADA){ + TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE ( transport ); + priv->current_command = transport_event; + priv->key_event = transport_event; + + cairo_t *cr; + cr = gdk_cairo_create ( GTK_WIDGET(transport)->window ); + draw ( GTK_WIDGET(transport), cr ); + cairo_destroy (cr); + } +} + +void +transport_widget_react_to_key_release_event ( TransportWidget* transport, + TransportWidgetEvent transport_event ) { if(transport_event != TRANSPORT_NADA){ TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE ( transport ); @@ -378,7 +397,9 @@ 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"); - return; + + /* Update the drawing in any case, should not hurt :) */ + // return; } else if(priv->current_command != TRANSPORT_NADA && command != TRANSPORT_NADA){ @@ -386,11 +407,12 @@ transport_widget_react_to_button_release ( TransportWidget* button, } cairo_t *cr; cr = gdk_cairo_create ( GTK_WIDGET(button)->window ); - priv->current_command = TRANSPORT_NADA; + priv->current_command = TRANSPORT_NADA; + priv->key_event = TRANSPORT_NADA; draw ( GTK_WIDGET(button), cr ); cairo_destroy (cr); -} +} /// internal helper functions ////////////////////////////////////////////////// @@ -1261,7 +1283,7 @@ draw (GtkWidget* button, cairo_t *cr) } // draw previous-button drop-shadow - if (priv->has_focus) + if (priv->has_focus && priv->key_event == TRANSPORT_PREVIOUS) { _setup (&cr_surf, &surf, PREV_WIDTH+6, PREV_HEIGHT+6); _mask_prev (cr_surf, @@ -1321,7 +1343,7 @@ draw (GtkWidget* button, cairo_t *cr) _finalize (cr, &cr_surf, &surf, PREV_X, PREV_Y); // draw next-button drop-shadow - if (priv->has_focus) + if (priv->has_focus && priv->key_event == TRANSPORT_NEXT) { _setup (&cr_surf, &surf, NEXT_WIDTH+6, NEXT_HEIGHT+6); _mask_next (cr_surf, @@ -1382,7 +1404,7 @@ draw (GtkWidget* button, cairo_t *cr) // draw pause-button drop-shadow if(priv->current_state == PLAY){ - if (priv->has_focus) + if (priv->has_focus && (priv->key_event == TRANSPORT_NADA || priv->key_event == TRANSPORT_PLAY_PAUSE)) { _setup (&cr_surf, &surf, PAUSE_WIDTH+6, PAUSE_HEIGHT+6); _mask_pause (cr_surf, @@ -1442,7 +1464,7 @@ draw (GtkWidget* button, cairo_t *cr) _finalize (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y); } else if(priv->current_state == PAUSE){ - if (priv->has_focus) + if (priv->has_focus && (priv->key_event == TRANSPORT_NADA || priv->key_event == TRANSPORT_PLAY_PAUSE)) { _setup (&cr_surf, &surf, PLAY_WIDTH+6, PLAY_HEIGHT+6); _mask_play (cr_surf, diff --git a/src/transport-widget.h b/src/transport-widget.h index 58a224c..7c087fb 100644 --- a/src/transport-widget.h +++ b/src/transport-widget.h @@ -66,8 +66,10 @@ 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 ); +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 ); G_END_DECLS #endif -- cgit v1.2.3 From ca946b13d56c7df56d30c8824baf8e943b07dd3e Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Wed, 17 Nov 2010 12:01:10 +0100 Subject: indents --- src/transport-widget.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/transport-widget.c b/src/transport-widget.c index 8c674a6..8b42bd0 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -330,9 +330,9 @@ transport_widget_react_to_key_press_event ( TransportWidget* transport, priv->current_command = transport_event; priv->key_event = transport_event; - cairo_t *cr; - cr = gdk_cairo_create ( GTK_WIDGET(transport)->window ); - draw ( GTK_WIDGET(transport), cr ); + cairo_t *cr; + cr = gdk_cairo_create ( GTK_WIDGET(transport)->window ); + draw ( GTK_WIDGET(transport), cr ); cairo_destroy (cr); } } -- cgit v1.2.3 From 7889e51f4346844c63aa8c11d127134d4ce292e9 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Wed, 17 Nov 2010 12:11:56 +0100 Subject: Added printf for debugging --- src/transport-widget.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/transport-widget.c b/src/transport-widget.c index 8b42bd0..f8aca57 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -329,7 +329,7 @@ transport_widget_react_to_key_press_event ( TransportWidget* transport, TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE ( transport ); priv->current_command = transport_event; priv->key_event = transport_event; - + printf("transport_widget_react_to_key_press_event: before drawing\n"); cairo_t *cr; cr = gdk_cairo_create ( GTK_WIDGET(transport)->window ); draw ( GTK_WIDGET(transport), cr ); @@ -352,7 +352,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 +397,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 ); -- cgit v1.2.3 From a9dea58aef77180c83d8827690f11b9a5acb56fc Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Wed, 17 Nov 2010 13:10:31 +0100 Subject: commented the prints and try to realize the widget in press event --- src/transport-widget.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/transport-widget.c b/src/transport-widget.c index f8aca57..fffbdef 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -213,7 +213,7 @@ static gboolean transport_widget_expose (GtkWidget *button, GdkEventExpose *event) { cairo_t *cr; - cr = gdk_cairo_create (button->window); + cr = gdk_cairo_create (button); //g_debug("In the playbutton's expose method, x = %i, y=%i and width: %i and height: %i'"); cairo_rectangle (cr, @@ -329,7 +329,9 @@ transport_widget_react_to_key_press_event ( TransportWidget* transport, TransportWidgetPrivate * priv = TRANSPORT_WIDGET_GET_PRIVATE ( transport ); priv->current_command = transport_event; priv->key_event = transport_event; - printf("transport_widget_react_to_key_press_event: before drawing\n"); +/* printf("transport_widget_react_to_key_press_event: before drawing\n");*/ + gtk_widget_realize ( GTK_WIDGET(transport) ); + cairo_t *cr; cr = gdk_cairo_create ( GTK_WIDGET(transport)->window ); draw ( GTK_WIDGET(transport), cr ); @@ -352,7 +354,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"); +/* 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,16 +399,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"); +/* 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: inside if(priv->current_command != TRANSPORT_NADA && command != TRANSPORT_NADA)\n");*/ } - printf("transport_widget_react_to_button_release: before drawing\n"); +/* printf("transport_widget_react_to_button_release: before drawing\n");*/ cairo_t *cr; cr = gdk_cairo_create ( GTK_WIDGET(button)->window ); -- cgit v1.2.3 From 8a1071905651219598cd04ee06ecafe6ceafaa67 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Wed, 17 Nov 2010 13:17:05 +0100 Subject: ops :) --- src/transport-widget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/transport-widget.c b/src/transport-widget.c index fffbdef..abccb7d 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -213,7 +213,7 @@ static gboolean transport_widget_expose (GtkWidget *button, GdkEventExpose *event) { cairo_t *cr; - cr = gdk_cairo_create (button); + cr = gdk_cairo_create (button->window); //g_debug("In the playbutton's expose method, x = %i, y=%i and width: %i and height: %i'"); cairo_rectangle (cr, -- cgit v1.2.3 From f5aa1d3501cb44f31ce94a1ec188355b41926c95 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Wed, 17 Nov 2010 15:58:47 +0100 Subject: prelight state, redrawings are causing bugs --- src/transport-widget.c | 562 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 363 insertions(+), 199 deletions(-) (limited to 'src') diff --git a/src/transport-widget.c b/src/transport-widget.c index abccb7d..1588308 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -64,8 +64,8 @@ Uses code from ctk #define OUTER_START_SHADE 0.75 #define OUTER_END_SHADE 1.3 #define SHADOW_BUTTON_SHADE 0.8 -#define OUTER_BUTTON_START_SHADE 0.7 -#define OUTER_BUTTON_END_SHADE 1.38 +#define OUTER_PLAY_START_SHADE 0.7 +#define OUTER_PLAY_END_SHADE 1.38 #define BUTTON_START_SHADE 1.1 #define BUTTON_END_SHADE 0.9 #define BUTTON_SHADOW_SHADE 0.8 @@ -78,6 +78,7 @@ struct _TransportWidgetPrivate { TransportWidgetEvent current_command; TransportWidgetEvent key_event; + TransportWidgetEvent motion_event; TransportWidgetState current_state; GHashTable* command_coordinates; DbusmenuMenuitem* twin_item; @@ -103,7 +104,11 @@ static void draw (GtkWidget* button, cairo_t *cr); static gboolean transport_widget_button_press_event (GtkWidget *menuitem, GdkEventButton *event); static gboolean transport_widget_button_release_event (GtkWidget *menuitem, - GdkEventButton *event); + GdkEventButton *event); +static gboolean transport_widget_motion_notify_event (GtkWidget *menuitem, + GdkEventMotion *event); +static gboolean transport_widget_leave_notify_event (GtkWidget *menuitem, + GdkEventCrossing *event); static void transport_widget_property_update ( DbusmenuMenuitem* item, gchar * property, GValue * value, @@ -115,6 +120,8 @@ static void transport_widget_notify ( GObject *item, gpointer user_data ); static TransportWidgetEvent transport_widget_determine_button_event ( TransportWidget* button, GdkEventButton* event); +static TransportWidgetEvent transport_widget_determine_motion_event ( TransportWidget* button, + GdkEventMotion* event); static void transport_widget_react_to_button_release ( TransportWidget* button, TransportWidgetEvent command); static void transport_widget_toggle_play_pause ( TransportWidget* button, @@ -134,7 +141,9 @@ transport_widget_class_init (TransportWidgetClass *klass) g_type_class_add_private (klass, sizeof (TransportWidgetPrivate)); widget_class->button_press_event = transport_widget_button_press_event; - widget_class->button_release_event = transport_widget_button_release_event; + widget_class->button_release_event = transport_widget_button_release_event; + widget_class->motion_notify_event = transport_widget_motion_notify_event; + widget_class->leave_notify_event = transport_widget_leave_notify_event; widget_class->expose_event = transport_widget_expose; gobject_class->dispose = transport_widget_dispose; @@ -148,6 +157,7 @@ transport_widget_init (TransportWidget *self) priv->current_command = TRANSPORT_NADA; priv->current_state = PAUSE; priv->key_event = TRANSPORT_NADA; + priv->motion_event = TRANSPORT_NADA; priv->has_focus = FALSE; priv->command_coordinates = g_hash_table_new_full(g_direct_hash, g_direct_equal, @@ -260,6 +270,40 @@ transport_widget_menu_hidden ( GtkWidget *menu, transport_widget_react_to_button_release(transport, TRANSPORT_NADA); } +static gboolean +transport_widget_motion_notify_event (GtkWidget *menuitem, + GdkEventMotion *event) +{ + g_return_val_if_fail ( IS_TRANSPORT_WIDGET(menuitem), FALSE ); + TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE ( TRANSPORT_WIDGET(menuitem) ); + TransportWidgetEvent result = transport_widget_determine_motion_event ( TRANSPORT_WIDGET(menuitem), + event); + + priv->motion_event = result; + cairo_t *cr; + cr = gdk_cairo_create (menuitem->window); + draw ( menuitem, cr ); + cairo_destroy ( cr ); + + return TRUE; +} + +static gboolean +transport_widget_leave_notify_event (GtkWidget *menuitem, + GdkEventCrossing *event) +{ + g_return_val_if_fail ( IS_TRANSPORT_WIDGET(menuitem), FALSE ); + TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE ( TRANSPORT_WIDGET(menuitem) ); + + priv->motion_event = TRANSPORT_NADA; + cairo_t *cr; + cr = gdk_cairo_create (menuitem->window); + draw ( menuitem, cr ); + cairo_destroy ( cr ); + + return TRUE; +} + /* keyevents */ static gboolean transport_widget_button_press_event (GtkWidget *menuitem, @@ -390,6 +434,28 @@ transport_widget_determine_button_event( TransportWidget* button, return button_event; } +static TransportWidgetEvent +transport_widget_determine_motion_event( TransportWidget* button, + GdkEventMotion* event ) +{ +/* g_debug("event x coordinate = %f", event->x);*/ +/* g_debug("event y coordinate = %f", event->y);*/ + TransportWidgetEvent motion_event = TRANSPORT_NADA; + // For now very simple rectangular collision detection + if(event->x > 67 && event->x < 112 + && event->y > 12 && event->y < 40){ + motion_event = TRANSPORT_PREVIOUS; + } + else if(event->x > 111 && event->x < 153 + && event->y > 5 && event->y < 47){ + motion_event = TRANSPORT_PLAY_PAUSE; + } + else if(event->x > 152 && event->x < 197 + && event->y > 12 && event->y < 40){ + motion_event = TRANSPORT_NEXT; + } + return motion_event; +} static void transport_widget_react_to_button_release ( TransportWidget* button, @@ -1111,16 +1177,21 @@ draw (GtkWidget* button, cairo_t *cr) GtkStyle *style; - CairoColorRGB bg_color, fg_color, bg_selected; - CairoColorRGB color_inner[2], color_middle[2], color_outer[2], color_button[4], color_button_outer[2], color_button_shadow, color_inner_compressed[2]; + CairoColorRGB bg_color, fg_color, bg_selected, bg_prelight; + CairoColorRGB color_middle[2], color_middle_prelight[2], color_outer[2], color_outer_prelight[2], + color_play_outer[2], color_play_outer_prelight[2], + color_button[4], color_button_shadow, color_inner[2], color_inner_compressed[2]; style = gtk_widget_get_style (button); - bg_color.r = style->bg[0].red/65535.0; bg_color.g = style->bg[0].green/65535.0; bg_color.b = style->bg[0].blue/65535.0; + bg_prelight.r = style->bg[GTK_STATE_PRELIGHT].red/65535.0; + bg_prelight.g = style->bg[GTK_STATE_PRELIGHT].green/65535.0; + bg_prelight.b = style->bg[GTK_STATE_PRELIGHT].blue/65535.0; + bg_selected.r = style->bg[GTK_STATE_SELECTED].red/65535.0; bg_selected.g = style->bg[GTK_STATE_SELECTED].green/65535.0; bg_selected.b = style->bg[GTK_STATE_SELECTED].blue/65535.0; @@ -1129,77 +1200,71 @@ draw (GtkWidget* button, cairo_t *cr) fg_color.g = style->fg[0].green/65535.0; fg_color.b = style->fg[0].blue/65535.0; + _color_shade (&bg_color, MIDDLE_START_SHADE, &color_middle[0]); + _color_shade (&bg_color, MIDDLE_END_SHADE, &color_middle[1]); + _color_shade (&bg_prelight, MIDDLE_START_SHADE, &color_middle_prelight[0]); + _color_shade (&bg_prelight, MIDDLE_END_SHADE, &color_middle_prelight[1]); + _color_shade (&bg_color, OUTER_START_SHADE, &color_outer[0]); + _color_shade (&bg_color, OUTER_END_SHADE, &color_outer[1]); + _color_shade (&bg_prelight, OUTER_START_SHADE, &color_outer_prelight[0]); + _color_shade (&bg_prelight, OUTER_END_SHADE, &color_outer_prelight[1]); + _color_shade (&bg_color, OUTER_PLAY_START_SHADE, &color_play_outer[0]); + _color_shade (&bg_color, OUTER_PLAY_END_SHADE, &color_play_outer[1]); + _color_shade (&bg_prelight, OUTER_PLAY_START_SHADE, &color_play_outer_prelight[0]); + _color_shade (&bg_prelight, OUTER_PLAY_END_SHADE, &color_play_outer_prelight[1]); _color_shade (&bg_color, INNER_START_SHADE, &color_inner[0]); _color_shade (&bg_color, INNER_END_SHADE, &color_inner[1]); - _color_shade (&bg_color, MIDDLE_START_SHADE, &color_middle[0]); - _color_shade (&bg_color, MIDDLE_END_SHADE, &color_middle[1]); - _color_shade (&bg_color, OUTER_START_SHADE, &color_outer[0]); - _color_shade (&bg_color, OUTER_END_SHADE, &color_outer[1]); - _color_shade (&bg_color, OUTER_BUTTON_START_SHADE, &color_button_outer[0]); - _color_shade (&bg_color, OUTER_BUTTON_END_SHADE, &color_button_outer[1]); - _color_shade (&bg_color, SHADOW_BUTTON_SHADE, &color_button_shadow); _color_shade (&fg_color, BUTTON_START_SHADE, &color_button[0]); _color_shade (&fg_color, BUTTON_END_SHADE, &color_button[1]); _color_shade (&bg_color, BUTTON_SHADOW_SHADE, &color_button[2]); + _color_shade (&bg_color, SHADOW_BUTTON_SHADE, &color_button_shadow); _color_shade (&bg_selected, 1.0, &color_button[3]); _color_shade (&bg_color, INNER_COMPRESSED_START_SHADE, &color_inner_compressed[0]); _color_shade (&bg_color, INNER_COMPRESSED_END_SHADE, &color_inner_compressed[1]); - double MIDDLE_END[] = {color_middle[0].r, color_middle[0].g, color_middle[0].b, 1.0f}; + double MIDDLE_END[] = {color_middle[0].r, color_middle[0].g, color_middle[0].b, 1.0f}; double MIDDLE_START[] = {color_middle[1].r, color_middle[1].g, color_middle[1].b, 1.0f}; - double SHADOW_BUTTON[] = {color_button_shadow.r, color_button_shadow.g, color_button_shadow.b, 0.16f}; - double OUTER_END[] = {color_outer[0].r, color_outer[0].g, color_outer[0].b, 1.0f}; + double MIDDLE_END_PRELIGHT[] = {color_middle_prelight[0].r, color_middle_prelight[0].g, color_middle_prelight[0].b, 1.0f}; + double MIDDLE_START_PRELIGHT[] = {color_middle_prelight[1].r, color_middle_prelight[1].g, color_middle_prelight[1].b, 1.0f}; + double OUTER_END[] = {color_outer[0].r, color_outer[0].g, color_outer[0].b, 1.0f}; double OUTER_START[] = {color_outer[1].r, color_outer[1].g, color_outer[1].b, 1.0f}; - double OUTER_BUTTON_END[] = {color_button_outer[0].r, color_button_outer[0].g, color_button_outer[0].b, 1.0f}; - double OUTER_BUTTON_START[] = {color_button_outer[1].r, color_button_outer[1].g, color_button_outer[1].b, 1.0f}; + double OUTER_END_PRELIGHT[] = {color_outer_prelight[0].r, color_outer_prelight[0].g, color_outer_prelight[0].b, 1.0f}; + double OUTER_START_PRELIGHT[] = {color_outer_prelight[1].r, color_outer_prelight[1].g, color_outer_prelight[1].b, 1.0f}; + double SHADOW_BUTTON[] = {color_button_shadow.r, color_button_shadow.g, color_button_shadow.b, 0.16f}; + double OUTER_PLAY_END[] = {color_play_outer[0].r, color_play_outer[0].g, color_play_outer[0].b, 1.0f}; + double OUTER_PLAY_START[] = {color_play_outer[1].r, color_play_outer[1].g, color_play_outer[1].b, 1.0f}; + double OUTER_PLAY_END_PRELIGHT[] = {color_play_outer_prelight[0].r, color_play_outer_prelight[0].g, color_play_outer_prelight[0].b, 1.0f}; + double OUTER_PLAY_START_PRELIGHT[] = {color_play_outer_prelight[1].r, color_play_outer_prelight[1].g, color_play_outer_prelight[1].b, 1.0f}; double BUTTON_END[] = {color_button[0].r, color_button[0].g, color_button[0].b, 1.0f}; double BUTTON_START[] = {color_button[1].r, color_button[1].g, color_button[1].b, 1.0f}; double BUTTON_SHADOW[] = {color_button[2].r, color_button[2].g, color_button[2].b, 0.75f}; double BUTTON_SHADOW_FOCUS[] = {color_button[3].r, color_button[3].g, color_button[3].b, 1.0f}; double INNER_COMPRESSED_END[] = {color_inner_compressed[1].r, color_inner_compressed[1].g, color_inner_compressed[1].b, 1.0f}; double INNER_COMPRESSED_START[] = {color_inner_compressed[0].r, color_inner_compressed[0].g, color_inner_compressed[0].b, 1.0f}; - - // prev/next-background -/* if(priv->current_command != TRANSPORT_PREVIOUS && priv->current_command != TRANSPORT_NEXT){*/ -/* draw_gradient (cr,*/ -/* X-0.25,*/ -/* Y-1,*/ -/* RECT_WIDTH+2,*/ -/* OUTER_RADIUS+1,*/ -/* SHADOW_BUTTON,*/ -/* SHADOW_BUTTON);*/ + + // prev/next shadow +/* if(priv->current_command != TRANSPORT_PREVIOUS && priv->current_command != TRANSPORT_NEXT)*/ +/* {*/ +/* draw_gradient (cr,*/ +/* X-0.25,*/ +/* Y-1,*/ +/* RECT_WIDTH+2,*/ +/* OUTER_RADIUS+1,*/ +/* SHADOW_BUTTON,*/ +/* SHADOW_BUTTON);*/ /* }*/ - draw_gradient (cr, - X, - Y, - RECT_WIDTH, - OUTER_RADIUS, - OUTER_START, - OUTER_END); - draw_gradient (cr, - X, - Y + 1, - RECT_WIDTH - 2, - MIDDLE_RADIUS, - MIDDLE_START, - MIDDLE_END); - draw_gradient (cr, - X, - Y + 2, - RECT_WIDTH - 4, - MIDDLE_RADIUS, - MIDDLE_START, - MIDDLE_END); - - if(priv->current_command == TRANSPORT_PREVIOUS){ - draw_gradient (cr, - X, - Y, - RECT_WIDTH/2, - OUTER_RADIUS, - OUTER_END, - OUTER_START); - + + //prev/next button + if(priv->current_command == TRANSPORT_PREVIOUS) + { + draw_gradient (cr, + X, + Y, + RECT_WIDTH/2, + OUTER_RADIUS, + OUTER_END, + OUTER_START); + draw_gradient (cr, X, Y + 1, @@ -1207,6 +1272,7 @@ draw (GtkWidget* button, cairo_t *cr) MIDDLE_RADIUS, INNER_COMPRESSED_START, INNER_COMPRESSED_END); + draw_gradient (cr, X, Y + 2, @@ -1214,15 +1280,16 @@ draw (GtkWidget* button, cairo_t *cr) MIDDLE_RADIUS, INNER_COMPRESSED_START, INNER_COMPRESSED_END); - } - else if(priv->current_command == TRANSPORT_NEXT){ + } + else if(priv->current_command == TRANSPORT_NEXT) + { draw_gradient (cr, - RECT_WIDTH / 2 + X, - Y, - RECT_WIDTH/2, - OUTER_RADIUS, - OUTER_END, - OUTER_START); + RECT_WIDTH / 2 + X, + Y, + RECT_WIDTH/2, + OUTER_RADIUS, + OUTER_END, + OUTER_START); draw_gradient (cr, RECT_WIDTH / 2 + X, @@ -1230,60 +1297,154 @@ draw (GtkWidget* button, cairo_t *cr) (RECT_WIDTH - 7)/2, MIDDLE_RADIUS, INNER_COMPRESSED_START, - INNER_COMPRESSED_END); + INNER_COMPRESSED_END); + draw_gradient (cr, RECT_WIDTH / 2 + X, Y + 2, (RECT_WIDTH - 7)/2, MIDDLE_RADIUS, INNER_COMPRESSED_START, - INNER_COMPRESSED_END); - } + INNER_COMPRESSED_END); + } + else if (priv->motion_event == TRANSPORT_PREVIOUS) + { + draw_gradient (cr, + X, + Y, + RECT_WIDTH/2, + OUTER_RADIUS, + OUTER_START_PRELIGHT, + OUTER_END_PRELIGHT); + + draw_gradient (cr, + X, + Y + 1, + RECT_WIDTH/2, + MIDDLE_RADIUS, + MIDDLE_START_PRELIGHT, + MIDDLE_END_PRELIGHT); + draw_gradient (cr, + X, + Y + 2, + RECT_WIDTH/2, + MIDDLE_RADIUS, + MIDDLE_START_PRELIGHT, + MIDDLE_END_PRELIGHT); + } + else if (priv->motion_event == TRANSPORT_NEXT) + { + draw_gradient (cr, + RECT_WIDTH / 2 + X, + Y, + RECT_WIDTH/2, + OUTER_RADIUS, - // play/pause shadow - if(priv->current_command != TRANSPORT_PLAY_PAUSE){ - draw_circle (cr, - X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f - 1.0f, - Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) - 1.0f, - CIRCLE_RADIUS + 1.0f, - SHADOW_BUTTON, - SHADOW_BUTTON); + OUTER_START_PRELIGHT, + OUTER_END_PRELIGHT); + + draw_gradient (cr, + RECT_WIDTH / 2 + X, + Y + 1, + (RECT_WIDTH - 7)/2, + MIDDLE_RADIUS, + MIDDLE_START_PRELIGHT, + MIDDLE_END_PRELIGHT); + + draw_gradient (cr, + RECT_WIDTH / 2 + X, + Y + 2, + (RECT_WIDTH - 7)/2, + MIDDLE_RADIUS, + MIDDLE_START_PRELIGHT, + MIDDLE_END_PRELIGHT); + } + else + { + draw_gradient (cr, + X, + Y, + RECT_WIDTH, + OUTER_RADIUS, + OUTER_START, + OUTER_END); + + draw_gradient (cr, + X, + Y + 1, + RECT_WIDTH - 2, + MIDDLE_RADIUS, + MIDDLE_START, + MIDDLE_END); + + draw_gradient (cr, + X, + Y + 2, + RECT_WIDTH - 4, + MIDDLE_RADIUS, + MIDDLE_START, + MIDDLE_END); } - // play/pause border - if(priv->current_command == TRANSPORT_PLAY_PAUSE){ + // play/pause shadow + if(priv->current_command != TRANSPORT_PLAY_PAUSE) + { draw_circle (cr, - X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f, - Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) , - CIRCLE_RADIUS, - OUTER_BUTTON_END, - OUTER_BUTTON_START); + X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f - 1.0f, + Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) - 1.0f, + CIRCLE_RADIUS + 1.0f, + SHADOW_BUTTON, + SHADOW_BUTTON); } - else { + + // play/pause button + if(priv->current_command == TRANSPORT_PLAY_PAUSE) + { + draw_circle (cr, + X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f, + Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) , + CIRCLE_RADIUS, + OUTER_PLAY_END, + OUTER_PLAY_START); + draw_circle (cr, - X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f, - Y - ((CIRCLE_RADIUS - OUTER_RADIUS)), - CIRCLE_RADIUS, - OUTER_BUTTON_START, - OUTER_BUTTON_END); + X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 1.25f, + Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 1.25f, + CIRCLE_RADIUS - 1.25, + INNER_COMPRESSED_START, + INNER_COMPRESSED_END); } + else if (priv->motion_event == TRANSPORT_PLAY_PAUSE) + { + draw_circle (cr, + X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f, + Y - ((CIRCLE_RADIUS - OUTER_RADIUS)), + CIRCLE_RADIUS, + OUTER_PLAY_START_PRELIGHT, + OUTER_PLAY_END_PRELIGHT); - // play/pause-background - if(priv->current_command == TRANSPORT_PLAY_PAUSE){ - draw_circle (cr, - X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 1.25f, - Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 1.25f, - CIRCLE_RADIUS - 1.25, - INNER_COMPRESSED_START, - INNER_COMPRESSED_END); + draw_circle (cr, + X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 1.25f, + Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 1.25f, + CIRCLE_RADIUS - 1.25, + MIDDLE_START_PRELIGHT, + MIDDLE_END_PRELIGHT); } - else { + else + { + draw_circle (cr, + X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f, + Y - ((CIRCLE_RADIUS - OUTER_RADIUS)), + CIRCLE_RADIUS, + OUTER_PLAY_START, + OUTER_PLAY_END); + draw_circle (cr, - X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 1.25f, - Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 1.25f, - CIRCLE_RADIUS - 1.25, - MIDDLE_START, - MIDDLE_END); + X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 1.25f, + Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 1.25f, + CIRCLE_RADIUS - 1.25, + MIDDLE_START, + MIDDLE_END); } // draw previous-button drop-shadow @@ -1291,11 +1452,11 @@ draw (GtkWidget* button, cairo_t *cr) { _setup (&cr_surf, &surf, PREV_WIDTH+6, PREV_HEIGHT+6); _mask_prev (cr_surf, - (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, - (PREV_HEIGHT - TRI_HEIGHT) / 2.0f, - TRI_WIDTH, - TRI_HEIGHT, - TRI_OFFSET); + (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (PREV_HEIGHT - TRI_HEIGHT) / 2.0f, + TRI_WIDTH, + TRI_HEIGHT, + TRI_OFFSET); _fill (cr_surf, (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, (PREV_HEIGHT - TRI_HEIGHT) / 2.0f, @@ -1311,11 +1472,11 @@ draw (GtkWidget* button, cairo_t *cr) { _setup (&cr_surf, &surf, PREV_WIDTH, PREV_HEIGHT); _mask_prev (cr_surf, - (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, - (PREV_HEIGHT - TRI_HEIGHT) / 2.0f, - TRI_WIDTH, - TRI_HEIGHT, - TRI_OFFSET); + (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (PREV_HEIGHT - TRI_HEIGHT) / 2.0f, + TRI_WIDTH, + TRI_HEIGHT, + TRI_OFFSET); _fill (cr_surf, (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, (PREV_HEIGHT - TRI_HEIGHT) / 2.0f, @@ -1331,19 +1492,19 @@ draw (GtkWidget* button, cairo_t *cr) // draw previous-button _setup (&cr_surf, &surf, PREV_WIDTH, PREV_HEIGHT); _mask_prev (cr_surf, - (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, - (PREV_HEIGHT - TRI_HEIGHT) / 2.0f, - TRI_WIDTH, - TRI_HEIGHT, - TRI_OFFSET); + (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (PREV_HEIGHT - TRI_HEIGHT) / 2.0f, + TRI_WIDTH, + TRI_HEIGHT, + TRI_OFFSET); _fill (cr_surf, - (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, - (PREV_HEIGHT - TRI_HEIGHT) / 2.0f, - (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, - (double) TRI_HEIGHT, - BUTTON_START, - BUTTON_END, - FALSE); + (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (PREV_HEIGHT - TRI_HEIGHT) / 2.0f, + (PREV_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (double) TRI_HEIGHT, + BUTTON_START, + BUTTON_END, + FALSE); _finalize (cr, &cr_surf, &surf, PREV_X, PREV_Y); // draw next-button drop-shadow @@ -1351,11 +1512,11 @@ draw (GtkWidget* button, cairo_t *cr) { _setup (&cr_surf, &surf, NEXT_WIDTH+6, NEXT_HEIGHT+6); _mask_next (cr_surf, - (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, - (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f, - TRI_WIDTH, - TRI_HEIGHT, - TRI_OFFSET); + (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f, + TRI_WIDTH, + TRI_HEIGHT, + TRI_OFFSET); _fill (cr_surf, (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f, @@ -1371,11 +1532,11 @@ draw (GtkWidget* button, cairo_t *cr) { _setup (&cr_surf, &surf, NEXT_WIDTH, NEXT_HEIGHT); _mask_next (cr_surf, - (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, - (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f, - TRI_WIDTH, - TRI_HEIGHT, - TRI_OFFSET); + (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f, + TRI_WIDTH, + TRI_HEIGHT, + TRI_OFFSET); _fill (cr_surf, (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f, @@ -1391,11 +1552,11 @@ draw (GtkWidget* button, cairo_t *cr) // draw next-button _setup (&cr_surf, &surf, NEXT_WIDTH, NEXT_HEIGHT); _mask_next (cr_surf, - (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, - (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f, - TRI_WIDTH, - TRI_HEIGHT, - TRI_OFFSET); + (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, + (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f, + TRI_WIDTH, + TRI_HEIGHT, + TRI_OFFSET); _fill (cr_surf, (NEXT_WIDTH - (2.0f * TRI_WIDTH - TRI_OFFSET)) / 2.0f, (NEXT_HEIGHT - TRI_HEIGHT) / 2.0f, @@ -1407,24 +1568,25 @@ draw (GtkWidget* button, cairo_t *cr) _finalize (cr, &cr_surf, &surf, NEXT_X, NEXT_Y); // draw pause-button drop-shadow - if(priv->current_state == PLAY){ + if(priv->current_state == PLAY) + { if (priv->has_focus && (priv->key_event == TRANSPORT_NADA || priv->key_event == TRANSPORT_PLAY_PAUSE)) { _setup (&cr_surf, &surf, PAUSE_WIDTH+6, PAUSE_HEIGHT+6); _mask_pause (cr_surf, - (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, - (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, - BAR_WIDTH, - BAR_HEIGHT - 2.0f * BAR_WIDTH, - BAR_OFFSET); + (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, + (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, + BAR_WIDTH, + BAR_HEIGHT - 2.0f * BAR_WIDTH, + BAR_OFFSET); _fill (cr_surf, - (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, - (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, - (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, - (double) BAR_HEIGHT, - BUTTON_SHADOW_FOCUS, - BUTTON_SHADOW_FOCUS, - TRUE); + (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, + (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, + (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, + (double) BAR_HEIGHT, + BUTTON_SHADOW_FOCUS, + BUTTON_SHADOW_FOCUS, + TRUE); _surface_blur (surf, 3); _finalize_repaint (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y + 0.5f, 3); } @@ -1432,19 +1594,19 @@ draw (GtkWidget* button, cairo_t *cr) { _setup (&cr_surf, &surf, PAUSE_WIDTH, PAUSE_HEIGHT); _mask_pause (cr_surf, - (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, - (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, - BAR_WIDTH, - BAR_HEIGHT - 2.0f * BAR_WIDTH, - BAR_OFFSET); + (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, + (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, + BAR_WIDTH, + BAR_HEIGHT - 2.0f * BAR_WIDTH, + BAR_OFFSET); _fill (cr_surf, - (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, - (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, - (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, - (double) BAR_HEIGHT, - BUTTON_SHADOW, - BUTTON_SHADOW, - TRUE); + (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, + (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, + (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, + (double) BAR_HEIGHT, + BUTTON_SHADOW, + BUTTON_SHADOW, + TRUE); _surface_blur (surf, 1); _finalize (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y + 1.0f); } @@ -1452,38 +1614,39 @@ draw (GtkWidget* button, cairo_t *cr) // draw pause-button _setup (&cr_surf, &surf, PAUSE_WIDTH, PAUSE_HEIGHT); _mask_pause (cr_surf, - (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, - (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, - BAR_WIDTH, - BAR_HEIGHT - 2.0f * BAR_WIDTH, - BAR_OFFSET); + (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, + (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, + BAR_WIDTH, + BAR_HEIGHT - 2.0f * BAR_WIDTH, + BAR_OFFSET); _fill (cr_surf, - (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, - (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, - (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, - (double) BAR_HEIGHT, - BUTTON_START, - BUTTON_END, - TRUE); + (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, + (PAUSE_HEIGHT - BAR_HEIGHT) / 2.0f, + (PAUSE_WIDTH - (2.0f * BAR_WIDTH + BAR_OFFSET)) / 2.0f, + (double) BAR_HEIGHT, + BUTTON_START, + BUTTON_END, + TRUE); _finalize (cr, &cr_surf, &surf, PAUSE_X, PAUSE_Y); } - else if(priv->current_state == PAUSE){ + else if(priv->current_state == PAUSE) + { if (priv->has_focus && (priv->key_event == TRANSPORT_NADA || priv->key_event == TRANSPORT_PLAY_PAUSE)) { _setup (&cr_surf, &surf, PLAY_WIDTH+6, PLAY_HEIGHT+6); _mask_play (cr_surf, - PLAY_PADDING, - PLAY_PADDING, - PLAY_WIDTH - (2*PLAY_PADDING), - PLAY_HEIGHT - (2*PLAY_PADDING)); + PLAY_PADDING, + PLAY_PADDING, + PLAY_WIDTH - (2*PLAY_PADDING), + PLAY_HEIGHT - (2*PLAY_PADDING)); _fill (cr_surf, PLAY_PADDING, PLAY_PADDING, PLAY_WIDTH - (2*PLAY_PADDING), PLAY_HEIGHT - (2*PLAY_PADDING), - BUTTON_SHADOW_FOCUS, - BUTTON_SHADOW_FOCUS, - FALSE); + BUTTON_SHADOW_FOCUS, + BUTTON_SHADOW_FOCUS, + FALSE); _surface_blur (surf, 3); _finalize_repaint (cr, &cr_surf, &surf, PAUSE_X-0.5f, PAUSE_Y + 0.5f, 3); } @@ -1491,21 +1654,22 @@ draw (GtkWidget* button, cairo_t *cr) { _setup (&cr_surf, &surf, PLAY_WIDTH, PLAY_HEIGHT); _mask_play (cr_surf, - PLAY_PADDING, - PLAY_PADDING, - PLAY_WIDTH - (2*PLAY_PADDING), - PLAY_HEIGHT - (2*PLAY_PADDING)); + PLAY_PADDING, + PLAY_PADDING, + PLAY_WIDTH - (2*PLAY_PADDING), + PLAY_HEIGHT - (2*PLAY_PADDING)); _fill (cr_surf, PLAY_PADDING, PLAY_PADDING, PLAY_WIDTH - (2*PLAY_PADDING), PLAY_HEIGHT - (2*PLAY_PADDING), - BUTTON_SHADOW, - BUTTON_SHADOW, - FALSE); + BUTTON_SHADOW, + BUTTON_SHADOW, + FALSE); _surface_blur (surf, 1); _finalize (cr, &cr_surf, &surf, PAUSE_X-0.75f, PAUSE_Y + 1.0f); } + // draw play-button _setup (&cr_surf, &surf, PLAY_WIDTH, PLAY_HEIGHT); cairo_set_line_width (cr, 10.5); @@ -1515,15 +1679,15 @@ draw (GtkWidget* button, cairo_t *cr) PLAY_PADDING, PLAY_PADDING, PLAY_WIDTH - (2*PLAY_PADDING), - PLAY_HEIGHT - (2*PLAY_PADDING)); + PLAY_HEIGHT - (2*PLAY_PADDING)); _fill (cr_surf, PLAY_PADDING, PLAY_PADDING, PLAY_WIDTH - (2*PLAY_PADDING), PLAY_HEIGHT - (2*PLAY_PADDING), - BUTTON_START, - BUTTON_END, - FALSE); + BUTTON_START, + BUTTON_END, + FALSE); _finalize (cr, &cr_surf, &surf, PAUSE_X-0.5f, PAUSE_Y); } } -- cgit v1.2.3 From 237041021ddb7d0c08542fbdca41d845b14dea82 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 17 Nov 2010 15:34:27 +0000 Subject: fixed the crashes and made the key presss/release work nicely with multiple players --- src/indicator-sound.c | 44 ++++++++++++++++++++++++++++++++++---------- src/transport-widget.c | 24 +++++++++++++++++++----- src/transport-widget.h | 1 + 3 files changed, 54 insertions(+), 15 deletions(-) (limited to 'src') 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 -- cgit v1.2.3 From acd7737d412eeeb9d072e13d2d9b1815f334de2c Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Wed, 17 Nov 2010 16:45:09 +0100 Subject: fixed the redraw --- src/transport-widget.c | 51 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/transport-widget.c b/src/transport-widget.c index 1588308..eb1a8a7 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -1254,6 +1254,30 @@ draw (GtkWidget* button, cairo_t *cr) /* SHADOW_BUTTON);*/ /* }*/ + draw_gradient (cr, + X, + Y, + RECT_WIDTH, + OUTER_RADIUS, + OUTER_START, + OUTER_END); + + draw_gradient (cr, + X, + Y + 1, + RECT_WIDTH - 2, + MIDDLE_RADIUS, + MIDDLE_START, + MIDDLE_END); + + draw_gradient (cr, + X, + Y + 2, + RECT_WIDTH - 4, + MIDDLE_RADIUS, + MIDDLE_START, + MIDDLE_END); + //prev/next button if(priv->current_command == TRANSPORT_PREVIOUS) { @@ -1324,6 +1348,7 @@ draw (GtkWidget* button, cairo_t *cr) MIDDLE_RADIUS, MIDDLE_START_PRELIGHT, MIDDLE_END_PRELIGHT); + draw_gradient (cr, X, Y + 2, @@ -1359,32 +1384,6 @@ draw (GtkWidget* button, cairo_t *cr) MIDDLE_START_PRELIGHT, MIDDLE_END_PRELIGHT); } - else - { - draw_gradient (cr, - X, - Y, - RECT_WIDTH, - OUTER_RADIUS, - OUTER_START, - OUTER_END); - - draw_gradient (cr, - X, - Y + 1, - RECT_WIDTH - 2, - MIDDLE_RADIUS, - MIDDLE_START, - MIDDLE_END); - - draw_gradient (cr, - X, - Y + 2, - RECT_WIDTH - 4, - MIDDLE_RADIUS, - MIDDLE_START, - MIDDLE_END); - } // play/pause shadow if(priv->current_command != TRANSPORT_PLAY_PAUSE) -- cgit v1.2.3 From ba69a13a8b79fe1acceff439da98b6d547079a70 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Wed, 17 Nov 2010 16:51:01 +0100 Subject: comment shadow code --- src/transport-widget.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/transport-widget.c b/src/transport-widget.c index eb1a8a7..5618d23 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -1386,15 +1386,15 @@ draw (GtkWidget* button, cairo_t *cr) } // play/pause shadow - if(priv->current_command != TRANSPORT_PLAY_PAUSE) - { - draw_circle (cr, - X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f - 1.0f, - Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) - 1.0f, - CIRCLE_RADIUS + 1.0f, - SHADOW_BUTTON, - SHADOW_BUTTON); - } +/* if(priv->current_command != TRANSPORT_PLAY_PAUSE)*/ +/* {*/ +/* draw_circle (cr,*/ +/* X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f - 1.0f,*/ +/* Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) - 1.0f,*/ +/* CIRCLE_RADIUS + 1.0f,*/ +/* SHADOW_BUTTON,*/ +/* SHADOW_BUTTON);*/ +/* }*/ // play/pause button if(priv->current_command == TRANSPORT_PLAY_PAUSE) -- cgit v1.2.3 From 595ae6b37e22a7a4b8450caa918078308ea514e9 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Wed, 17 Nov 2010 17:29:39 +0100 Subject: Final touch --- src/transport-widget.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/transport-widget.c b/src/transport-widget.c index 5618d23..28aff6f 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -1230,7 +1230,7 @@ draw (GtkWidget* button, cairo_t *cr) double OUTER_START[] = {color_outer[1].r, color_outer[1].g, color_outer[1].b, 1.0f}; double OUTER_END_PRELIGHT[] = {color_outer_prelight[0].r, color_outer_prelight[0].g, color_outer_prelight[0].b, 1.0f}; double OUTER_START_PRELIGHT[] = {color_outer_prelight[1].r, color_outer_prelight[1].g, color_outer_prelight[1].b, 1.0f}; - double SHADOW_BUTTON[] = {color_button_shadow.r, color_button_shadow.g, color_button_shadow.b, 0.16f}; + double SHADOW_BUTTON[] = {color_button_shadow.r, color_button_shadow.g, color_button_shadow.b, 0.3f}; double OUTER_PLAY_END[] = {color_play_outer[0].r, color_play_outer[0].g, color_play_outer[0].b, 1.0f}; double OUTER_PLAY_START[] = {color_play_outer[1].r, color_play_outer[1].g, color_play_outer[1].b, 1.0f}; double OUTER_PLAY_END_PRELIGHT[] = {color_play_outer_prelight[0].r, color_play_outer_prelight[0].g, color_play_outer_prelight[0].b, 1.0f}; @@ -1364,7 +1364,6 @@ draw (GtkWidget* button, cairo_t *cr) Y, RECT_WIDTH/2, OUTER_RADIUS, - OUTER_START_PRELIGHT, OUTER_END_PRELIGHT); @@ -1386,15 +1385,21 @@ draw (GtkWidget* button, cairo_t *cr) } // play/pause shadow -/* if(priv->current_command != TRANSPORT_PLAY_PAUSE)*/ -/* {*/ -/* draw_circle (cr,*/ -/* X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f - 1.0f,*/ -/* Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) - 1.0f,*/ -/* CIRCLE_RADIUS + 1.0f,*/ -/* SHADOW_BUTTON,*/ -/* SHADOW_BUTTON);*/ -/* }*/ + if(priv->current_command != TRANSPORT_PLAY_PAUSE) + { + cairo_save (cr); + cairo_rectangle (cr, X, Y, RECT_WIDTH, MIDDLE_RADIUS*2); + cairo_clip (cr); + + draw_circle (cr, + X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f - 1.0f, + Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) - 1.0f, + CIRCLE_RADIUS + 1.0f, + SHADOW_BUTTON, + SHADOW_BUTTON); + + cairo_restore (cr); + } // play/pause button if(priv->current_command == TRANSPORT_PLAY_PAUSE) @@ -1415,10 +1420,11 @@ draw (GtkWidget* button, cairo_t *cr) } else if (priv->motion_event == TRANSPORT_PLAY_PAUSE) { + /* this subtle offset is to fix alpha borders, should be removed once this draw routine will be refactored */ draw_circle (cr, - X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f, - Y - ((CIRCLE_RADIUS - OUTER_RADIUS)), - CIRCLE_RADIUS, + X + RECT_WIDTH / 2.0f - 2.0f * OUTER_RADIUS - 5.5f + 0.1, + Y - ((CIRCLE_RADIUS - OUTER_RADIUS)) + 0.1, + CIRCLE_RADIUS - 0.1, OUTER_PLAY_START_PRELIGHT, OUTER_PLAY_END_PRELIGHT); -- cgit v1.2.3 From c2b222eca845810c2ca54ce11f6791dc715322c7 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 17 Nov 2010 17:44:00 +0000 Subject: removed commented code --- src/transport-widget.c | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/transport-widget.c b/src/transport-widget.c index e814ce5..5be9d4a 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -474,11 +474,7 @@ transport_widget_react_to_button_release ( TransportWidget* button, { g_return_if_fail(IS_TRANSPORT_WIDGET(button)); TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(button); - if(priv->current_command == TRANSPORT_NADA){ - /* Update the drawing in any case, should not hurt :) */ - // return; - } - else if(priv->current_command != TRANSPORT_NADA && + if(priv->current_command != TRANSPORT_NADA && command != TRANSPORT_NADA){ priv->current_command = command; } @@ -504,10 +500,6 @@ draw_gradient (cairo_t* cr, { cairo_pattern_t* pattern = NULL; -/* cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);*/ -/* cairo_save (cr);*/ -/* cairo_rectangle (cr, x-2.0*r, y, w+2*r, r*2);*/ -/* cairo_clip (cr);*/ cairo_move_to (cr, x, y); cairo_line_to (cr, x + w - 2.0f * r, y); cairo_arc (cr, @@ -525,12 +517,6 @@ draw_gradient (cairo_t* cr, 270.0f * G_PI / 180.0f); cairo_close_path (cr); -/* cairo_arc (cr,*/ -/* x+(w-2*r)/2+1, y+(CIRCLE_RADIUS)/2+2,*/ -/* CIRCLE_RADIUS+1,*/ -/* 0.0f * G_PI / 180.0f,*/ -/* 360.0f * G_PI / 180.0f);*/ - pattern = cairo_pattern_create_linear (x, y, x, y + 2.0f * r); cairo_pattern_add_color_stop_rgba (pattern, 0.0f, @@ -547,7 +533,6 @@ draw_gradient (cairo_t* cr, cairo_set_source (cr, pattern); cairo_fill (cr); cairo_pattern_destroy (pattern); -/* cairo_restore(cr);*/ } static void @@ -679,8 +664,7 @@ _mask_play (cairo_t* cr, double x, double y, double tri_width, - double tri_height - /*double tri_offset*/) + double tri_height) { if (!cr) return; @@ -1249,17 +1233,6 @@ draw (GtkWidget* button, cairo_t *cr) double INNER_COMPRESSED_END[] = {color_inner_compressed[1].r, color_inner_compressed[1].g, color_inner_compressed[1].b, 1.0f}; double INNER_COMPRESSED_START[] = {color_inner_compressed[0].r, color_inner_compressed[0].g, color_inner_compressed[0].b, 1.0f}; - // prev/next shadow -/* if(priv->current_command != TRANSPORT_PREVIOUS && priv->current_command != TRANSPORT_NEXT)*/ -/* {*/ -/* draw_gradient (cr,*/ -/* X-0.25,*/ -/* Y-1,*/ -/* RECT_WIDTH+2,*/ -/* OUTER_RADIUS+1,*/ -/* SHADOW_BUTTON,*/ -/* SHADOW_BUTTON);*/ -/* }*/ draw_gradient (cr, X, -- cgit v1.2.3 From 3ea42eb34e8cf787c98bb783d39c6f237381ffe2 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 18 Nov 2010 11:30:03 +0000 Subject: made the necessary changes to ensure compatibility with valac-0.12, and dealt with a compiler warning --- src/familiar-players-db.vala | 7 ++++++- src/fetch-file.vala | 2 +- src/metadata-menu-item.vala | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/familiar-players-db.vala b/src/familiar-players-db.vala index af7d07f..47ddc70 100644 --- a/src/familiar-players-db.vala +++ b/src/familiar-players-db.vala @@ -167,9 +167,14 @@ public class FamiliarPlayersDB : GLib.Object desktop_keyfile.load_from_file (desktop_path, KeyFileFlags.NONE); } catch(GLib.FileError error){ - warning("Error loading keyfile"); + warning("Error loading keyfile - FileError"); return null; } + catch(GLib.KeyFileError error){ + warning("Error loading keyfile - KeyFileError"); + return null; + } + try{ return desktop_keyfile.get_string (KeyFileDesktop.GROUP, KeyFileDesktop.KEY_ICON); diff --git a/src/fetch-file.vala b/src/fetch-file.vala index 1811cc1..e6fc11d 100644 --- a/src/fetch-file.vala +++ b/src/fetch-file.vala @@ -64,7 +64,7 @@ public class FetchFile : Object ssize_t bufsize = 1; do { try { - bufsize = yield this.stream.read_async (buffer, size, GLib.Priority.DEFAULT, null); + bufsize = yield this.stream.read_async (buffer, GLib.Priority.DEFAULT, null); if (bufsize < 1) { break;} if (bufsize != size) diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala index 3f71653..c9ab4dd 100644 --- a/src/metadata-menu-item.vala +++ b/src/metadata-menu-item.vala @@ -133,7 +133,7 @@ public class MetadataMenuitem : PlayerItem { try{ PixbufLoader loader = new PixbufLoader (); - loader.write (update.data, update.len); + loader.write (update.data); loader.close (); Pixbuf icon = loader.get_pixbuf (); string path = this.album_art_cache_dir.concat("/downloaded-coverart-XXXXXX"); -- cgit v1.2.3