diff options
Diffstat (limited to 'src/indicator-sound.c')
-rw-r--r-- | src/indicator-sound.c | 54 |
1 files changed, 22 insertions, 32 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c index b57cd43..d59d300 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -40,7 +40,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "dbus-shared-names.h" #include "sound-service-client.h" #include "common-defs.h" -#include "sound-service-marshal.h" // GObject Boiler plate #define INDICATOR_SOUND_TYPE (indicator_sound_get_type ()) @@ -122,7 +121,6 @@ static gboolean initial_mute = FALSE; static gboolean device_available = TRUE; static gboolean slider_in_direct_use = FALSE; -#define DESIGN_TEAM_SIZE design_team_size static GtkIconSize design_team_size; static gint animation_id; static GList * blocked_animation_list = NULL; @@ -170,8 +168,12 @@ indicator_sound_dispose (GObject *object) self->service = NULL; } g_hash_table_destroy(volume_states); - g_list_foreach (blocked_animation_list, (GFunc)g_object_unref, NULL); - g_list_free(blocked_animation_list); + + if(blocked_animation_list != NULL){ + g_list_foreach (blocked_animation_list, (GFunc)g_object_unref, NULL); + g_list_free(blocked_animation_list); + } + G_OBJECT_CLASS (indicator_sound_parent_class)->dispose (object); return; } @@ -218,7 +220,7 @@ static void slider_parent_changed (GtkWidget *widget, gpointer user_data) { - gtk_widget_set_size_request (widget, 200, -1); + gtk_widget_set_size_request (widget, 200, -1); } /** @@ -333,32 +335,22 @@ Only called at startup. */ static void prepare_blocked_animation() { - GError* error= NULL; - int i; - gchar* blocked_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); gchar* muted_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED)); - GtkIconTheme* theme = gtk_icon_theme_get_default(); - GdkPixbuf* mute_buf = gtk_icon_theme_load_icon(theme, - muted_name, - 22, - GTK_ICON_LOOKUP_GENERIC_FALLBACK, - &error); - if(error != NULL){ - g_error("indicator-sound : prepare_blocked_animation - %s", error->message); - g_error_free(error); - return; - } + + GtkImage* temp_image = indicator_image_helper(muted_name); + GdkPixbuf* mute_buf = gtk_image_get_pixbuf(temp_image); - GdkPixbuf* blocked_buf = gtk_icon_theme_load_icon(theme, blocked_name, - 22, - GTK_ICON_LOOKUP_GENERIC_FALLBACK, - &error); - if(error != NULL){ - g_error("indicator-sound : prepare_blocked_animation - %s", error->message); - g_error_free(error); - return; + temp_image = indicator_image_helper(blocked_name); + GdkPixbuf* blocked_buf = gtk_image_get_pixbuf(temp_image); + + int i; + + if(mute_buf == NULL || blocked_buf == NULL){ + g_debug("Don bother with the animation, the theme aint got the goods"); + return; } + // sample 22 snapshots - range : 0-256 for(i = 0; i < 23; i++) { @@ -366,7 +358,6 @@ static void prepare_blocked_animation() gdk_pixbuf_get_width(mute_buf), gdk_pixbuf_get_height(mute_buf), 0, 0, 1, 1, GDK_INTERP_BILINEAR, MIN(255, i * 11)); - g_debug("creating blocking animation - alpha value = %i", MIN(255, i * 11)); blocked_animation_list = g_list_append(blocked_animation_list, gdk_pixbuf_copy(blocked_buf)); } } @@ -491,16 +482,15 @@ static void fetch_mute_value_from_dbus() static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gboolean block_value, gpointer userdata) { g_debug("signal caught - sink input while muted with value %i", block_value); - if (block_value == 1 && animation_id == 0 ) { - // We can assume we are in the muted state ! + if (block_value == 1 && animation_id == 0 && blocked_animation_list != NULL) { gchar* image_name = g_hash_table_lookup(volume_states, GINT_TO_POINTER(STATE_MUTED_WHILE_INPUT)); GtkImage * tempimage = indicator_image_helper(image_name); gtk_image_set_from_pixbuf(speaker_image, gtk_image_get_pixbuf(tempimage)); - g_object_ref_sink(tempimage); + g_object_ref_sink(tempimage); blocked_iter = blocked_animation_list; animation_id = g_timeout_add_seconds(1, fade_back_to_mute_image, NULL); - } + } } static gboolean fade_back_to_mute_image() |