Merge lp:~charlesk/indicator-sound/visibility into lp:indicator-sound/fifth

Proposed by Charles Kerr
Status: Merged
Merged at revision: 291
Proposed branch: lp:~charlesk/indicator-sound/visibility
Merge into: lp:indicator-sound/fifth
Diff against target: 184 lines (+87/-3)
4 files modified
data/com.canonical.indicator.sound.gschema.xml (+7/-0)
src/indicator-sound.c (+65/-1)
src/metadata-widget.c (+8/-2)
src/transport-widget.c (+7/-0)
To merge this branch: bzr merge lp:~charlesk/indicator-sound/visibility
Reviewer Review Type Date Requested Status
Conor Curran (community) Approve
Review via email: mp+90038@code.launchpad.net

Description of the change

This branch contains a new patch for bug #829648 and fixes a small handful of memory issues reported by valgrind.

To post a comment you must log in.
Revision history for this message
Conor Curran (cjcurran) wrote :

Thanks Charles, looking good !

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/com.canonical.indicator.sound.gschema.xml'
2--- data/com.canonical.indicator.sound.gschema.xml 2012-01-17 10:09:27 +0000
3+++ data/com.canonical.indicator.sound.gschema.xml 2012-01-25 03:12:24 +0000
4@@ -34,5 +34,12 @@
5 updated volume value will be shown (if supported by your notification daemon).
6 </description>
7 </key>
8+ <key name="visible" type="b">
9+ <default>true</default>
10+ <summary>Whether or not to show the sound indicator in the menu bar.</summary>
11+ <description>
12+ Whether or not to show the sound indicator in the menu bar.
13+ </description>
14+ </key>
15 </schema>
16 </schemalist>
17
18=== modified file 'src/indicator-sound.c'
19--- src/indicator-sound.c 2011-12-01 17:19:30 +0000
20+++ src/indicator-sound.c 2012-01-25 03:12:24 +0000
21@@ -55,10 +55,13 @@
22 GDBusProxy *dbus_proxy;
23 SoundStateManager* state_manager;
24 gchar *accessible_desc;
25+ GSettings *settings;
26 };
27
28 #define INDICATOR_SOUND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_SOUND_TYPE, IndicatorSoundPrivate))
29
30+#define SOUND_INDICATOR_GSETTINGS_SCHEMA_ID "com.canonical.indicator.sound"
31+
32 // GObject Boiler plate
33 INDICATOR_SET_VERSION
34 INDICATOR_SET_TYPE(INDICATOR_SOUND_TYPE)
35@@ -119,6 +122,10 @@
36 gboolean connected,
37 gpointer userdata);
38
39+// Visiblity
40+static void settings_init (IndicatorSound * self);
41+
42+
43 static void
44 indicator_sound_class_init (IndicatorSoundClass *klass)
45 {
46@@ -156,6 +163,9 @@
47 priv->transport_widgets_list = t_list;
48 priv->state_manager = g_object_new (SOUND_TYPE_STATE_MANAGER, NULL);
49 priv->accessible_desc = NULL;
50+ priv->settings = NULL;
51+
52+ settings_init (self);
53
54 g_signal_connect ( G_OBJECT(self->service),
55 INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE,
56@@ -168,6 +178,11 @@
57 IndicatorSound * self = INDICATOR_SOUND(object);
58 IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
59
60+ if (priv->settings != NULL) {
61+ g_object_unref (G_OBJECT(priv->settings));
62+ priv->settings = NULL;
63+ }
64+
65 if (self->service != NULL) {
66 g_object_unref(G_OBJECT(self->service));
67 self->service = NULL;
68@@ -747,10 +762,12 @@
69 void
70 update_accessible_desc (IndicatorObject * io)
71 {
72- IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(io);
73 GList *entries = indicator_object_get_entries(io);
74+ if (!entries)
75+ return;
76 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)entries->data;
77
78+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(io);
79 gchar *old_desc = priv->accessible_desc;
80
81 if (priv->volume_widget) {
82@@ -770,3 +787,50 @@
83 TRUE);
84 g_list_free(entries);
85 }
86+
87+/***
88+****
89+***/
90+
91+#define VISIBLE_KEY "visible"
92+
93+static void
94+on_visible_changed (GSettings * settings, gchar * key, gpointer user_data)
95+{
96+ g_return_if_fail (!g_strcmp0 (key, VISIBLE_KEY));
97+
98+ IndicatorObject * io = INDICATOR_OBJECT(user_data);
99+ const gboolean visible = g_settings_get_boolean (settings, key);
100+ indicator_object_set_visible (io, visible);
101+ if (visible)
102+ update_accessible_desc (io); // requires an entry
103+}
104+
105+static void
106+settings_init (IndicatorSound *self)
107+{
108+ const char * schema = SOUND_INDICATOR_GSETTINGS_SCHEMA_ID;
109+
110+ gint i;
111+ gboolean schema_exists = FALSE;
112+ const char * const * schemas = g_settings_list_schemas ();
113+ for (i=0; !schema_exists && schemas && schemas[i]; i++)
114+ if (!g_strcmp0 (schema, schemas[i]))
115+ schema_exists = TRUE;
116+
117+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
118+ if (schema_exists) {
119+ priv->settings = g_settings_new (schema);
120+ } else {
121+ priv->settings = NULL;
122+ }
123+
124+ if (priv->settings != NULL) {
125+ g_signal_connect (G_OBJECT(priv->settings), "changed::" VISIBLE_KEY,
126+ G_CALLBACK(on_visible_changed), self);
127+ const gboolean b = g_settings_get_boolean (priv->settings, VISIBLE_KEY);
128+ g_object_set (G_OBJECT(self),
129+ "indicator-object-default-visibility", b,
130+ NULL);
131+ }
132+}
133
134=== modified file 'src/metadata-widget.c'
135--- src/metadata-widget.c 2012-01-13 10:07:05 +0000
136+++ src/metadata-widget.c 2012-01-25 03:12:24 +0000
137@@ -256,6 +256,7 @@
138 #else
139 gdk_pixbuf_unref(priv->icon_buf);
140 #endif
141+ priv->icon_buf = NULL;
142 }
143 G_OBJECT_CLASS (metadata_widget_parent_class)->dispose (object);
144 }
145@@ -263,6 +264,10 @@
146 static void
147 metadata_widget_finalize (GObject *object)
148 {
149+ MetadataWidgetPrivate * priv = METADATA_WIDGET_GET_PRIVATE(METADATA_WIDGET(object));
150+ g_string_free (priv->image_path, TRUE);
151+ g_string_free (priv->old_image_path, TRUE);
152+
153 G_OBJECT_CLASS (metadata_widget_parent_class)->finalize (object);
154 }
155
156@@ -790,8 +795,9 @@
157 gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height);
158
159 GString* banshee_string = g_string_new ( "banshee" );
160- GString* app_panel = g_string_new ( g_utf8_strdown (dbusmenu_menuitem_property_get(priv->twin_item, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME),
161- -1));
162+ gchar * tmp = g_utf8_strdown (dbusmenu_menuitem_property_get(priv->twin_item, DBUSMENU_METADATA_MENUITEM_PLAYER_NAME), -1);
163+ GString* app_panel = g_string_new (tmp);
164+ g_free (tmp);
165 GdkPixbuf* icon_buf;
166
167 // Banshee Special case!
168
169=== modified file 'src/transport-widget.c'
170--- src/transport-widget.c 2011-11-16 18:11:20 +0000
171+++ src/transport-widget.c 2012-01-25 03:12:24 +0000
172@@ -269,6 +269,13 @@
173 }
174 }
175 #endif
176+
177+ TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(object);
178+ if (priv->command_coordinates != NULL) {
179+ g_hash_table_destroy (priv->command_coordinates);
180+ priv->command_coordinates = NULL;
181+ }
182+
183 G_OBJECT_CLASS (transport_widget_parent_class)->dispose (object);
184 }
185

Subscribers

People subscribed via source and target branches