aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-03-16 17:24:34 +0000
committerConor Curran <conor.curran@canonical.com>2011-03-16 17:24:34 +0000
commit4c7f07ce4106f7e0f4e04ca034fd781b309e2985 (patch)
treeba4fce4f0256e5420a2fd5cd366ce717b7230793
parent2937537d66777034bb2fdfd23200acfb5b8de042 (diff)
downloadayatana-indicator-sound-4c7f07ce4106f7e0f4e04ca034fd781b309e2985.tar.gz
ayatana-indicator-sound-4c7f07ce4106f7e0f4e04ca034fd781b309e2985.tar.bz2
ayatana-indicator-sound-4c7f07ce4106f7e0f4e04ca034fd781b309e2985.zip
working as expected
-rw-r--r--src/common-defs.h3
-rw-r--r--src/sound-service.c2
-rw-r--r--src/transport-menu-item.vala6
-rw-r--r--src/transport-widget.c104
-rw-r--r--vapi/common-defs.vapi3
5 files changed, 111 insertions, 7 deletions
diff --git a/src/common-defs.h b/src/common-defs.h
index 21aab60..a3bcda0 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -42,7 +42,8 @@ typedef enum {
typedef enum {
TRANSPORT_STATE_PLAYING,
- TRANSPORT_STATE_PAUSED
+ TRANSPORT_STATE_PAUSED,
+ TRANSPORT_STATE_LAUNCHING
}TransportState;
#define NOT_ACTIVE -1
diff --git a/src/sound-service.c b/src/sound-service.c
index 20d9137..77909d1 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -39,8 +39,10 @@ service_shutdown (IndicatorService *service, gpointer user_data)
{
if (mainloop != NULL) {
g_debug("Service shutdown !");
+/*
close_pulse_activites();
g_main_loop_quit(mainloop);
+*/
}
return;
}
diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala
index e767a90..e383b0b 100644
--- a/src/transport-menu-item.vala
+++ b/src/transport-menu-item.vala
@@ -43,8 +43,9 @@ public class TransportMenuitem : PlayerItem
public void handle_cached_action()
{
- if (this.cached_action != Transport.Action.NO_ACTION){
- Timeout.add_seconds (4, send_cached_action);
+ if (this.cached_action != Transport.Action.NO_ACTION){
+ //send_cached_action();
+ Timeout.add_seconds (1, send_cached_action);
}
}
@@ -78,6 +79,7 @@ public class TransportMenuitem : PlayerItem
else{
this.cached_action = (Transport.Action)input;
this.owner.instantiate();
+ this.property_set_int (MENUITEM_PLAY_STATE, (int)Transport.State.LAUNCHING);
}
}
diff --git a/src/transport-widget.c b/src/transport-widget.c
index ef2916d..f1e7c10 100644
--- a/src/transport-widget.c
+++ b/src/transport-widget.c
@@ -85,6 +85,9 @@ struct _TransportWidgetPrivate
gboolean has_focus;
gint hold_timer;
gint skip_frequency;
+ gint launching_timer;
+ gdouble launching_transparency;
+ gboolean fade_out;
};
// TODO refactor the UI handlers, consolidate functionality between key press /release
@@ -136,6 +139,7 @@ static TransportAction transport_widget_collision_detection (gint x, gint y);
static void transport_widget_start_timing (TransportWidget* widget);
static gboolean transport_widget_trigger_seek (gpointer userdata);
static gboolean transport_widget_seek (gpointer userdata);
+static gboolean transport_widget_fade_playbutton (gpointer userdata);
/// Init functions //////////////////////////////////////////////////////////
@@ -168,6 +172,9 @@ transport_widget_init (TransportWidget *self)
priv->has_focus = FALSE;
priv->hold_timer = 0;
priv->skip_frequency = 0;
+ priv->launching_timer = 0;
+ priv->launching_transparency = 1.0f;
+ priv->fade_out = TRUE;
priv->command_coordinates = g_hash_table_new_full(g_direct_hash,
g_direct_equal,
NULL,
@@ -1733,6 +1740,59 @@ draw (GtkWidget* button, cairo_t *cr)
FALSE);
_finalize (cr, &cr_surf, &surf, PAUSE_X-0.5f, PAUSE_Y);
}
+ else if(priv->current_state == TRANSPORT_STATE_LAUNCHING)
+ {
+ g_debug ("launching in draw");
+ _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));
+
+ double BUTTON_SHADOW_LAUNCHING[] = {color_button[3].r,
+ color_button[3].g,
+ color_button[3].b,
+ priv->launching_transparency};
+ double BUTTON_LAUNCHING_END[] = {color_button[0].r,
+ color_button[0].g,
+ color_button[0].b,
+ priv->launching_transparency};
+ double BUTTON_LAUNCHING_START[] = {color_button[1].r,
+ color_button[1].g,
+ color_button[1].b,
+ priv->launching_transparency};
+ _fill (cr_surf,
+ PLAY_PADDING,
+ PLAY_PADDING,
+ PLAY_WIDTH - (2*PLAY_PADDING),
+ PLAY_HEIGHT - (2*PLAY_PADDING),
+ BUTTON_SHADOW_LAUNCHING,
+ BUTTON_SHADOW_LAUNCHING,
+ FALSE);
+ _surface_blur (surf, 3);
+ _finalize_repaint (cr, &cr_surf, &surf, PAUSE_X-0.5f, PAUSE_Y + 0.5f, 3);
+
+ // draw play-button
+ _setup (&cr_surf, &surf, PLAY_WIDTH, PLAY_HEIGHT);
+ cairo_set_line_width (cr, 10.5);
+ cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND);
+ _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_LAUNCHING_START,
+ BUTTON_LAUNCHING_END,
+ FALSE);
+ _finalize (cr, &cr_surf, &surf, PAUSE_X-0.5f, PAUSE_Y);
+ }
}
static void
@@ -1750,6 +1810,28 @@ transport_widget_set_twin_item(TransportWidget* self,
(TransportState)initial_state);
}
+static gboolean
+transport_widget_fade_playbutton (gpointer userdata)
+{
+ TransportWidget* bar = (TransportWidget*)userdata;
+ g_return_val_if_fail(IS_TRANSPORT_WIDGET(bar), FALSE);
+ g_debug ("fade in /out timeout");
+ TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(bar);
+ if (priv->launching_transparency == 1.0f){
+ priv->fade_out = TRUE;
+ }
+ else if (priv->launching_transparency <= 0.3F){
+ priv->fade_out = FALSE;
+ }
+ if (priv->fade_out == TRUE){
+ priv->launching_transparency -= 0.05f;
+ }
+ else{
+ priv->launching_transparency += 0.05f;
+ }
+ gtk_widget_queue_draw (GTK_WIDGET(bar));
+ return TRUE;
+}
/**
* transport_widget_update_state()
* Callback for updates from the other side of dbus
@@ -1761,12 +1843,28 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property,
//g_debug("transport_widget_update_state - with property %s", property);
TransportWidget* bar = (TransportWidget*)userdata;
g_return_if_fail(IS_TRANSPORT_WIDGET(bar));
+ TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(bar);
if(g_ascii_strcasecmp(DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE, property) == 0)
{
- int update_value = g_variant_get_int32(value);
- //g_debug("transport_widget_update_state - with value %i", update_value);
- transport_widget_toggle_play_pause(bar, (TransportState)update_value);
+ TransportState new_state = (TransportState)g_variant_get_int32(value);
+ //g_debug("transport_widget_update_state - with value %i", update_value);
+ if (new_state == TRANSPORT_STATE_LAUNCHING){
+ priv->current_state = TRANSPORT_STATE_LAUNCHING;
+ priv->launching_timer = g_timeout_add (100,
+ transport_widget_fade_playbutton,
+ bar);
+ //g_debug("TransportWidget::toggle play state : %i", priv->current_state);
+ }
+ else{
+ if (priv->launching_timer != 0){
+ g_source_remove (priv->launching_timer);
+ priv->launching_timer = 0;
+ priv->fade_out = TRUE;
+ priv->launching_transparency = 1.0f;
+ }
+ transport_widget_toggle_play_pause(bar, new_state);
+ }
}
}
diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi
index 9aca32d..0d28cdb 100644
--- a/vapi/common-defs.vapi
+++ b/vapi/common-defs.vapi
@@ -64,6 +64,7 @@ namespace Transport{
}
public enum State{
PLAYING,
- PAUSED
+ PAUSED,
+ LAUNCHING
}
}