aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-01-26 16:08:46 -0600
committerConor Curran <conor.curran@canonical.com>2011-01-26 16:08:46 -0600
commit8bbf7ea5805ed69a2d7450065a558398a623525f (patch)
tree00e929daa442a23616692c23060de8210bbcc995 /src
parent39089ee365c3c36db7cd42f53d782ee938424b5a (diff)
downloadayatana-indicator-sound-8bbf7ea5805ed69a2d7450065a558398a623525f.tar.gz
ayatana-indicator-sound-8bbf7ea5805ed69a2d7450065a558398a623525f.tar.bz2
ayatana-indicator-sound-8bbf7ea5805ed69a2d7450065a558398a623525f.zip
blocking state now workings as expected
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/indicator-sound.c1
-rw-r--r--src/sound-service-dbus.c8
-rw-r--r--src/sound-state-manager.c64
-rw-r--r--src/sound-state-manager.h4
5 files changed, 53 insertions, 26 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 79786af..ed64aeb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,7 +24,7 @@ libsoundmenu_la_SOURCES = \
gen-sound-service.xml.c \
dbus-shared-names.h
-libsoundmenu_la_CFLAGS = $(APPLET_CFLAGS) -Wall -DG_LOG_DOMAIN=\"Indicator-Sound\"
+libsoundmenu_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror -DG_LOG_DOMAIN=\"Indicator-Sound\"
libsoundmenu_la_LIBADD = $(APPLET_LIBS)
libsoundmenu_la_LDFLAGS = -module -avoid-version
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 71310f1..b47290c 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -382,7 +382,6 @@ new_volume_slider_widget(DbusmenuMenuitem * newitem,
newitem,
menu_volume_item,
parent);
- //fetch_state(INDICATOR_SOUND (io));
return TRUE;
}
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c
index 2c1dc4f..3ecca38 100644
--- a/src/sound-service-dbus.c
+++ b/src/sound-service-dbus.c
@@ -258,8 +258,6 @@ sound_service_dbus_finalize (GObject *object)
return;
}
-// TODO until the pulsemanager has been refactored keep in place the consistent api
-// for it to talk to the UI.
void sound_service_dbus_update_volume(SoundServiceDbus* self,
gdouble volume)
{
@@ -323,6 +321,7 @@ static void sound_service_dbus_determine_state (SoundServiceDbus* self,
sound_service_dbus_update_sound_state (self, update);
}
+
// EMIT STATE SIGNAL
// TODO: this will be a bit messy until the pa_manager is sorted.
@@ -338,8 +337,9 @@ void sound_service_dbus_update_sound_state (SoundServiceDbus* self,
DBUSMENU_MUTE_MENUITEM_VALUE) == FALSE ){
update = sound_service_dbus_get_state_from_volume (self);
}
-
- priv->current_sound_state = update;
+ if (update != BLOCKED){
+ priv->current_sound_state = update;
+ }
GVariant* v_output = g_variant_new("(i)", (int)update);
diff --git a/src/sound-state-manager.c b/src/sound-state-manager.c
index 0fce9a8..4a8dbe2 100644
--- a/src/sound-state-manager.c
+++ b/src/sound-state-manager.c
@@ -39,9 +39,10 @@ static GtkIconSize design_team_size;
static gint blocked_id;
static gint animation_id;
static GList* blocked_iter = NULL;
+static gboolean can_animate = FALSE;
static void sound_state_manager_prepare_blocked_animation(SoundStateManager* self);
-static gboolean sound_state_manager_start_animation (SoundStateManager* self);
+static gboolean sound_state_manager_start_animation (gpointer user_data);
static gboolean sound_state_manager_fade_back_to_mute_image (gpointer user_data);
static void sound_state_manager_reset_mute_blocking_animation (SoundStateManager* self);
static void sound_state_manager_free_the_animation_list (SoundStateManager* self);
@@ -54,8 +55,7 @@ static void sound_state_signal_cb ( GDBusProxy* proxy,
static void sound_state_manager_get_state_cb (GObject *object,
GAsyncResult *res,
gpointer user_data);
-
-
+static gboolean sound_state_manager_can_proceed_with_blocking_animation (SoundStateManager* self);
static void
sound_state_manager_init (SoundStateManager* self)
@@ -163,6 +163,7 @@ sound_state_manager_prepare_blocked_animation (SoundStateManager* self)
priv->blocked_animation_list = g_list_append(priv->blocked_animation_list,
gdk_pixbuf_copy(blocked_buf));
}
+ can_animate = TRUE;
g_object_ref_sink(mute_buf);
g_object_unref(mute_buf);
g_object_ref_sink(blocked_buf);
@@ -248,7 +249,7 @@ sound_state_signal_cb ( GDBusProxy* proxy,
GVariant* parameters,
gpointer user_data)
{
- g_debug ( "!!! sound state manager signal_cb" );
+ //g_debug ( "!!! sound state manager signal_cb" );
g_return_if_fail (SOUND_IS_STATE_MANAGER (user_data));
SoundStateManager* self = SOUND_STATE_MANAGER (user_data);
@@ -258,27 +259,40 @@ sound_state_signal_cb ( GDBusProxy* proxy,
GVariant *value = g_variant_get_child_value (parameters, 0);
gint update = g_variant_get_int32 (value);
- g_debug ( "!!! signal_cb with value %i", update);
+ //g_debug ( "!!! signal_cb with value %i", update);
priv->current_state = (SoundState)update;
g_variant_unref (parameters);
if (g_strcmp0(signal_name, INDICATOR_SOUND_SIGNAL_STATE_UPDATE) == 0){
+
gchar* image_name = g_hash_table_lookup (priv->volume_states,
GINT_TO_POINTER(priv->current_state) );
- indicator_image_helper_update (priv->speaker_image, image_name);
+ if (priv->current_state == BLOCKED &&
+ sound_state_manager_can_proceed_with_blocking_animation (self) == TRUE) {
+ blocked_id = g_timeout_add_seconds (4,
+ sound_state_manager_start_animation,
+ self);
+ indicator_image_helper_update (priv->speaker_image, image_name);
+
+ }
+ else{
+ indicator_image_helper_update (priv->speaker_image, image_name);
+ }
}
else {
- g_debug ("sorry don't know what signal this is - %s", signal_name);
+ g_warning ("sorry don't know what signal this is - %s", signal_name);
}
}
void
-sound_state_manager_style_changed_cb(GtkWidget *widget, gpointer user_data)
+sound_state_manager_style_changed_cb (GtkWidget *widget,
+ GtkStyle *previous_style,
+ gpointer user_data)
{
- //g_debug("Just caught a style change event");
+ g_debug("Just caught a style change event");
g_return_if_fail (SOUND_IS_STATE_MANAGER (user_data));
SoundStateManager* self = SOUND_STATE_MANAGER (user_data);
sound_state_manager_reset_mute_blocking_animation (self);
@@ -313,18 +327,12 @@ sound_state_manager_free_the_animation_list (SoundStateManager* self)
}
}
-/*static void
-update_state(const gint state)
-{
- previous_state = current_state;
- current_state = state;
- gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(current_state));
- indicator_image_helper_update(speaker_image, image_name);
-}*/
static gboolean
-sound_state_manager_start_animation (SoundStateManager* self)
+sound_state_manager_start_animation (gpointer userdata)
{
+ g_return_val_if_fail (SOUND_IS_STATE_MANAGER (userdata), FALSE);
+ SoundStateManager* self = SOUND_STATE_MANAGER (userdata);
SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE(self);
blocked_iter = priv->blocked_animation_list;
@@ -339,7 +347,8 @@ static gboolean
sound_state_manager_fade_back_to_mute_image (gpointer user_data)
{
g_return_val_if_fail (SOUND_IS_STATE_MANAGER (user_data), FALSE);
- SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE( SOUND_STATE_MANAGER (user_data) );
+ SoundStateManager* self = SOUND_STATE_MANAGER (user_data);
+ SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE (self);
if (blocked_iter != NULL) {
gtk_image_set_from_pixbuf (priv->speaker_image, blocked_iter->data);
@@ -348,7 +357,24 @@ sound_state_manager_fade_back_to_mute_image (gpointer user_data)
} else {
animation_id = 0;
//g_debug("exit from animation now\n");
+ g_dbus_proxy_call ( priv->dbus_proxy,
+ "GetSoundState",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ (GAsyncReadyCallback)sound_state_manager_get_state_cb,
+ self);
+
return FALSE;
}
}
+
+// Simple static helper to determine if the coast is clear to animate
+static
+gboolean sound_state_manager_can_proceed_with_blocking_animation (SoundStateManager* self)
+{
+ return (can_animate && blocked_id == 0 && animation_id == 0 );
+}
+
diff --git a/src/sound-state-manager.h b/src/sound-state-manager.h
index ef8fc40..76264e2 100644
--- a/src/sound-state-manager.h
+++ b/src/sound-state-manager.h
@@ -47,7 +47,9 @@ struct _SoundStateManager
GType sound_state_manager_get_type (void) G_GNUC_CONST;
-void sound_state_manager_style_changed_cb (GtkWidget *widget, gpointer user_data);
+void sound_state_manager_style_changed_cb (GtkWidget *widget,
+ GtkStyle *previous_style,
+ gpointer user_data);
GtkImage* sound_state_manager_get_current_icon (SoundStateManager* self);
SoundState sound_state_manager_get_current_state (SoundStateManager* self);
void sound_state_manager_connect_to_dbus (SoundStateManager* self,