Merge lp:~3v1n0/indicator-sound/add-name-hint_fix-memleak into lp:indicator-sound/fourth

Proposed by Marco Trevisan (Treviño)
Status: Merged
Merged at revision: 283
Proposed branch: lp:~3v1n0/indicator-sound/add-name-hint_fix-memleak
Merge into: lp:indicator-sound/fourth
Diff against target: 118 lines (+36/-13)
1 file modified
src/indicator-sound.c (+36/-13)
To merge this branch: bzr merge lp:~3v1n0/indicator-sound/add-name-hint_fix-memleak
Reviewer Review Type Date Requested Status
Conor Curran (community) Approve
Review via email: mp+81653@code.launchpad.net

Description of the change

Added the name hint to the indicator, to use it on unity-panel-service.

I'm using the autoconf generated config.h PACKAGE_NAME value.

Here I also fix a memory leak caused by the accessible description string that was never free'd when updated (and so on every volume change).

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator-sound.c'
2--- src/indicator-sound.c 2011-07-21 16:12:12 +0000
3+++ src/indicator-sound.c 2011-11-08 23:01:22 +0000
4@@ -54,6 +54,7 @@
5 GList* transport_widgets_list;
6 GDBusProxy *dbus_proxy;
7 SoundStateManager* state_manager;
8+ gchar *accessible_desc;
9 };
10
11 #define INDICATOR_SOUND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_SOUND_TYPE, IndicatorSoundPrivate))
12@@ -74,6 +75,7 @@
13 static GtkImage * get_icon (IndicatorObject * io);
14 static GtkMenu * get_menu (IndicatorObject * io);
15 static const gchar * get_accessible_desc (IndicatorObject * io);
16+static const gchar * get_name_hint (IndicatorObject * io);
17 static void indicator_sound_scroll (IndicatorObject * io,
18 IndicatorObjectEntry * entry, gint delta,
19 IndicatorScrollDirection direction);
20@@ -133,6 +135,7 @@
21 io_class->get_image = get_icon;
22 io_class->get_menu = get_menu;
23 io_class->get_accessible_desc = get_accessible_desc;
24+ io_class->get_name_hint = get_name_hint;
25 io_class->entry_scrolled = indicator_sound_scroll;
26 io_class->secondary_activate = indicator_sound_middle_click;
27 }
28@@ -152,6 +155,7 @@
29 GList* t_list = NULL;
30 priv->transport_widgets_list = t_list;
31 priv->state_manager = g_object_new (SOUND_TYPE_STATE_MANAGER, NULL);
32+ priv->accessible_desc = NULL;
33
34 g_signal_connect ( G_OBJECT(self->service),
35 INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE,
36@@ -168,17 +172,23 @@
37 g_object_unref(G_OBJECT(self->service));
38 self->service = NULL;
39 }
40- g_list_free ( priv->transport_widgets_list );
41+ g_list_free (priv->transport_widgets_list);
42
43 G_OBJECT_CLASS (indicator_sound_parent_class)->dispose (object);
44- return;
45 }
46
47 static void
48 indicator_sound_finalize (GObject *object)
49 {
50+ IndicatorSound * self = INDICATOR_SOUND(object);
51+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(self);
52+
53+ if (priv->accessible_desc) {
54+ g_free (priv->accessible_desc);
55+ priv->accessible_desc = NULL;
56+ }
57+
58 G_OBJECT_CLASS (indicator_sound_parent_class)->finalize (object);
59- return;
60 }
61
62 static GtkLabel *
63@@ -233,14 +243,13 @@
64 get_accessible_desc (IndicatorObject * io)
65 {
66 IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(io);
67-
68- if (priv->volume_widget != NULL){
69- return g_strdup_printf(_("Volume (%'.0f%%)"), volume_widget_get_current_volume(priv->volume_widget));
70- }
71-
72- return NULL;
73-}
74-
75+ return priv->accessible_desc;
76+}
77+
78+static const gchar *get_name_hint (IndicatorObject * io)
79+{
80+ return PACKAGE_NAME;
81+}
82
83 static void
84 connection_changed (IndicatorServiceManager * sm,
85@@ -725,7 +734,7 @@
86 indicator_sound_middle_click (IndicatorObject * io, IndicatorObjectEntry * entry,
87 guint time, gpointer data)
88 {
89- IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(INDICATOR_SOUND (io));
90+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(io);
91 g_return_if_fail (priv);
92
93 mute_widget_toggle(priv->mute_widget);
94@@ -734,9 +743,23 @@
95 void
96 update_accessible_desc (IndicatorObject * io)
97 {
98+ IndicatorSoundPrivate* priv = INDICATOR_SOUND_GET_PRIVATE(io);
99 GList *entries = indicator_object_get_entries(io);
100 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)entries->data;
101- entry->accessible_desc = get_accessible_desc(io);
102+
103+ gchar *old_desc = priv->accessible_desc;
104+
105+ if (priv->volume_widget) {
106+ priv->accessible_desc = g_strdup_printf(_("Volume (%'.0f%%)"),
107+ volume_widget_get_current_volume (priv->volume_widget));
108+ }
109+ else {
110+ priv->accessible_desc = NULL;
111+ }
112+
113+ entry->accessible_desc = priv->accessible_desc;
114+ g_free (old_desc);
115+
116 g_signal_emit(G_OBJECT(io),
117 INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID,
118 0,

Subscribers

People subscribed via source and target branches