From 1bdef61d49c35e1476117ae80c99610296bab68c Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 24 Jan 2012 20:11:12 -0600 Subject: fix minor memory leak detected by valgrind --- src/metadata-widget.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 8d816de..8304438 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -790,8 +790,9 @@ metadata_widget_set_icon (MetadataWidget *self) 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_METADATA_MENUITEM_PLAYER_NAME), - -1)); + gchar * tmp = g_utf8_strdown (dbusmenu_menuitem_property_get(priv->twin_item, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME), -1); + GString* app_panel = g_string_new (tmp); + g_free (tmp); GdkPixbuf* icon_buf; // Banshee Special case! -- cgit v1.2.3 From f1fd627d976f56bd47e5b8226c229eaf8cc64158 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 24 Jan 2012 20:21:21 -0600 Subject: fix Free Memory Read error found by valgrind --- src/metadata-widget.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 8304438..16e30e5 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -256,6 +256,7 @@ metadata_widget_dispose (GObject *object) #else gdk_pixbuf_unref(priv->icon_buf); #endif + priv->icon_buf = NULL; } G_OBJECT_CLASS (metadata_widget_parent_class)->dispose (object); } -- cgit v1.2.3 From f174071dd8f98b298509d11f45b67dac77924599 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 24 Jan 2012 20:52:57 -0600 Subject: fix a minor memory leak reported by valigrind --- src/metadata-widget.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/metadata-widget.c b/src/metadata-widget.c index 16e30e5..a3383df 100644 --- a/src/metadata-widget.c +++ b/src/metadata-widget.c @@ -264,6 +264,10 @@ metadata_widget_dispose (GObject *object) static void metadata_widget_finalize (GObject *object) { + MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(METADATA_WIDGET(object)); + g_string_free (priv->image_path, TRUE); + g_string_free (priv->old_image_path, TRUE); + G_OBJECT_CLASS (metadata_widget_parent_class)->finalize (object); } -- cgit v1.2.3 From 1e03cbb25bb86df7325d4909d9b3d5397b48e4cc Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 24 Jan 2012 20:54:05 -0600 Subject: fix hashtable leak reported by valgrind --- src/transport-widget.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/transport-widget.c b/src/transport-widget.c index 2d1a7f2..08e4ba9 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -269,6 +269,13 @@ transport_widget_dispose (GObject *object) } } #endif + + TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(object); + if (priv->command_coordinates != NULL) { + g_hash_table_destroy (priv->command_coordinates); + priv->command_coordinates = NULL; + } + G_OBJECT_CLASS (transport_widget_parent_class)->dispose (object); } -- cgit v1.2.3 From 6101f59b28f94ebe2ac819c4af61928a0ff17844 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 24 Jan 2012 20:57:50 -0600 Subject: add visibility toggle support for (lp:#829648) --- src/indicator-sound.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-sound.c b/src/indicator-sound.c index b953449..c87f850 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -55,10 +55,13 @@ struct _IndicatorSoundPrivate GDBusProxy *dbus_proxy; SoundStateManager* state_manager; gchar *accessible_desc; + GSettings *settings; }; #define INDICATOR_SOUND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_SOUND_TYPE, IndicatorSoundPrivate)) +#define SOUND_INDICATOR_GSETTINGS_SCHEMA_ID "com.canonical.indicator.sound" + // GObject Boiler plate INDICATOR_SET_VERSION INDICATOR_SET_TYPE(INDICATOR_SOUND_TYPE) @@ -119,6 +122,10 @@ static void connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer userdata); +// Visiblity +static void settings_init (IndicatorSound * self); + + static void indicator_sound_class_init (IndicatorSoundClass *klass) { @@ -156,6 +163,9 @@ indicator_sound_init (IndicatorSound *self) priv->transport_widgets_list = t_list; priv->state_manager = g_object_new (SOUND_TYPE_STATE_MANAGER, NULL); priv->accessible_desc = NULL; + priv->settings = NULL; + + settings_init (self); g_signal_connect ( G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, @@ -168,6 +178,11 @@ indicator_sound_dispose (GObject *object) IndicatorSound * self = INDICATOR_SOUND(object); IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); + if (priv->settings != NULL) { + g_object_unref (G_OBJECT(priv->settings)); + priv->settings = NULL; + } + if (self->service != NULL) { g_object_unref(G_OBJECT(self->service)); self->service = NULL; @@ -747,10 +762,12 @@ indicator_sound_middle_click (IndicatorObject * io, IndicatorObjectEntry * entry void update_accessible_desc (IndicatorObject * io) { - IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(io); GList *entries = indicator_object_get_entries(io); + if (!entries) + return; IndicatorObjectEntry * entry = (IndicatorObjectEntry *)entries->data; + IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(io); gchar *old_desc = priv->accessible_desc; if (priv->volume_widget) { @@ -770,3 +787,50 @@ update_accessible_desc (IndicatorObject * io) TRUE); g_list_free(entries); } + +/*** +**** +***/ + +#define VISIBLE_KEY "visible" + +static void +on_visible_changed (GSettings * settings, gchar * key, gpointer user_data) +{ + g_return_if_fail (!g_strcmp0 (key, VISIBLE_KEY)); + + IndicatorObject * io = INDICATOR_OBJECT(user_data); + const gboolean visible = g_settings_get_boolean (settings, key); + indicator_object_set_visible (io, visible); + if (visible) + update_accessible_desc (io); // requires an entry +} + +static void +settings_init (IndicatorSound *self) +{ + const char * schema = SOUND_INDICATOR_GSETTINGS_SCHEMA_ID; + + gint i; + gboolean schema_exists = FALSE; + const char * const * schemas = g_settings_list_schemas (); + for (i=0; !schema_exists && schemas && schemas[i]; i++) + if (!g_strcmp0 (schema, schemas[i])) + schema_exists = TRUE; + + IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self); + if (schema_exists) { + priv->settings = g_settings_new (schema); + } else { + priv->settings = NULL; + } + + if (priv->settings != NULL) { + g_signal_connect (G_OBJECT(priv->settings), "changed::" VISIBLE_KEY, + G_CALLBACK(on_visible_changed), self); + const gboolean b = g_settings_get_boolean (priv->settings, VISIBLE_KEY); + g_object_set (G_OBJECT(self), + "indicator-object-default-visibility", b, + NULL); + } +} -- cgit v1.2.3