Merge lp:~cjcurran/indicator-sound/rogue-mute into lp:~indicator-applet-developers/indicator-sound/trunk_3

Proposed by Conor Curran on 2011-03-22
Status: Merged
Merged at revision: 228
Proposed branch: lp:~cjcurran/indicator-sound/rogue-mute
Merge into: lp:~indicator-applet-developers/indicator-sound/trunk_3
Diff against target: 288 lines (+52/-43)
6 files modified
src/playlists-menu-item.vala (+1/-1)
src/slider-menu-item.c (+9/-6)
src/sound-service.c (+2/-0)
src/voip-input-menu-item.c (+4/-1)
src/voip-input-widget.c (+5/-2)
src/volume-widget.c (+31/-33)
To merge this branch: bzr merge lp:~cjcurran/indicator-sound/rogue-mute
Reviewer Review Type Date Requested Status
Kalle Valo (community) 2011-03-22 Approve on 2011-03-23
Review via email: mp+54414@code.launchpad.net

Description of the change

Places more added protection in the slider widgets so as any irregular spam coming from dbusmenu will not find its way onto a gtk_range_set_value.

Refactored the volume widget so as the mute property is a boolean (makes sense) and updated the various handle event calls so as each source can be identified via the name param.

To post a comment you must log in.
Kalle Valo (kvalo) wrote :

Commented out code:

//this.root_item.child_delete (item);

Otherwise looks good. Approved.

review: Approve
Conor Curran (cjcurran) wrote :

Oh well spotted.

231. By Conor Curran on 2011-03-23

tidy up

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/playlists-menu-item.vala'
2--- src/playlists-menu-item.vala 2011-03-17 16:10:03 +0000
3+++ src/playlists-menu-item.vala 2011-03-23 10:16:44 +0000
4@@ -80,7 +80,7 @@
5 if (this.root_item.property_get (MENUITEM_PATH) == item.property_get (MENUITEM_PATH)){
6 this.root_item.property_set (MENUITEM_PROP_LABEL, _("Choose Playlist"));
7 }
8- this.root_item.child_delete (item);
9+ this.root_item.child_delete (item);
10 }
11 }
12 }
13
14=== modified file 'src/slider-menu-item.c'
15--- src/slider-menu-item.c 2011-03-21 13:04:13 +0000
16+++ src/slider-menu-item.c 2011-03-23 10:16:44 +0000
17@@ -69,9 +69,6 @@
18 static void
19 slider_menu_item_init (SliderMenuItem *self)
20 {
21-/*
22- g_debug("Building new Slider Menu Item");
23-*/
24 dbusmenu_menuitem_property_set( DBUSMENU_MENUITEM(self),
25 DBUSMENU_MENUITEM_PROP_TYPE,
26 DBUSMENU_VOLUME_MENUITEM_TYPE );
27@@ -108,11 +105,13 @@
28
29 SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (SLIDER_MENU_ITEM (mi));
30 gdouble volume_input = g_variant_get_double (value);
31+
32 /*
33 g_debug ("slider menu item handle event with value %f on name %s",
34 volume_input,
35 name);
36 */
37+
38 slider_menu_item_update_volume (SLIDER_MENU_ITEM (mi), volume_input);
39 device_ensure_sink_is_unmuted (priv->a_sink);
40 }
41@@ -135,7 +134,7 @@
42 dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
43 DBUSMENU_VOLUME_MENUITEM_LEVEL,
44 new_volume);
45- GVariant* new_mute_update = g_variant_new_int32 (update->mute);
46+ GVariant* new_mute_update = g_variant_new_boolean (update->mute == 1);
47 dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
48 DBUSMENU_VOLUME_MENUITEM_MUTE,
49 new_mute_update);
50@@ -147,6 +146,7 @@
51 static void
52 slider_menu_item_update_volume (SliderMenuItem* self, gdouble percent)
53 {
54+
55 /*
56 g_debug ("slider menu item update volume - about to set the volume to %f", percent);
57 */
58@@ -177,18 +177,21 @@
59 gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
60
61 GVariant* new_volume = g_variant_new_double (volume_percent);
62+
63 /*
64 g_debug ("slider menu item update - volume update to ui to %f", volume_percent);
65 */
66+
67 dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
68 DBUSMENU_VOLUME_MENUITEM_LEVEL,
69 new_volume);
70+
71 if (priv->mute != update->mute){
72 priv->mute = update->mute;
73 /*
74 g_debug ("volume menu item - update - mute on ui = %i", update->mute);
75 */
76- GVariant* new_mute_update = g_variant_new_int32 (update->mute);
77+ GVariant* new_mute_update = g_variant_new_boolean (update->mute == 1);
78 dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
79 DBUSMENU_VOLUME_MENUITEM_MUTE,
80 new_mute_update);
81@@ -241,4 +244,4 @@
82 SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self);
83 priv->a_sink = sink;
84 return self;
85-}
86\ No newline at end of file
87+}
88
89=== modified file 'src/sound-service.c'
90--- src/sound-service.c 2011-03-21 16:01:03 +0000
91+++ src/sound-service.c 2011-03-23 10:16:44 +0000
92@@ -22,6 +22,8 @@
93 #include "sound-service-dbus.h"
94 #include "music-player-bridge.h"
95
96+#include <locale.h>
97+
98 static GMainLoop *mainloop = NULL;
99
100 /**********************************************************************************************************************/
101
102=== modified file 'src/voip-input-menu-item.c'
103--- src/voip-input-menu-item.c 2011-03-14 19:47:59 +0000
104+++ src/voip-input-menu-item.c 2011-03-23 10:16:44 +0000
105@@ -73,7 +73,6 @@
106 static void
107 voip_input_menu_item_init (VoipInputMenuItem *self)
108 {
109- g_debug("Building new Slider Menu Item");
110 dbusmenu_menuitem_property_set( DBUSMENU_MENUITEM(self),
111 DBUSMENU_MENUITEM_PROP_TYPE,
112 DBUSMENU_VOIP_INPUT_MENUITEM_TYPE );
113@@ -117,7 +116,9 @@
114 if (value != NULL){
115 if (IS_VOIP_INPUT_MENU_ITEM (mi)) {
116 VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (VOIP_INPUT_MENU_ITEM (mi));
117+/*
118 g_debug ("Handle event in the voip input level backend instance - %f", percent);
119+*/
120 pa_cvolume new_volume;
121 pa_cvolume_init(&new_volume);
122 new_volume.channels = 1;
123@@ -167,7 +168,9 @@
124 // Only send over the mute updates if the state has changed.
125 // in this order - volume first mute last!!
126 if (priv->mute != source->mute){
127+/*
128 g_debug ("voip menu item - update - mute = %i", priv->mute);
129+*/
130 GVariant* new_mute_update = g_variant_new_int32 (source->mute);
131 dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(item),
132 DBUSMENU_VOIP_INPUT_MENUITEM_MUTE,
133
134=== modified file 'src/voip-input-widget.c'
135--- src/voip-input-widget.c 2011-03-21 13:04:13 +0000
136+++ src/voip-input-widget.c 2011-03-23 10:16:44 +0000
137@@ -141,6 +141,7 @@
138 }
139 if(g_ascii_strcasecmp(DBUSMENU_VOIP_INPUT_MENUITEM_MUTE, property) == 0){
140 if(priv->grabbed == FALSE){
141+ g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_INT32));
142 GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_voip_input_slider);
143 GtkRange *range = (GtkRange*)slider;
144 gint update = g_variant_get_int32 (value);
145@@ -149,8 +150,10 @@
146 level = 0;
147 }
148 else{
149- level = g_variant_get_double (dbusmenu_menuitem_property_get_variant (priv->twin_item,
150- DBUSMENU_VOIP_INPUT_MENUITEM_LEVEL));
151+ GVariant* variant = dbusmenu_menuitem_property_get_variant (priv->twin_item,
152+ DBUSMENU_VOIP_INPUT_MENUITEM_LEVEL);
153+ g_return_if_fail (g_variant_is_of_type (variant, G_VARIANT_TYPE_DOUBLE));
154+ level = g_variant_get_double (variant);
155 }
156 gtk_range_set_value(range, level);
157
158
159=== modified file 'src/volume-widget.c'
160--- src/volume-widget.c 2011-03-21 13:04:13 +0000
161+++ src/volume-widget.c 2011-03-23 10:16:44 +0000
162@@ -128,48 +128,48 @@
163 volume_widget_property_update( DbusmenuMenuitem* item, gchar* property,
164 GVariant* value, gpointer userdata)
165 {
166- g_return_if_fail (IS_VOLUME_WIDGET (userdata));
167+ g_return_if_fail (IS_VOLUME_WIDGET(userdata));
168 VolumeWidget* mitem = VOLUME_WIDGET(userdata);
169 VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem);
170+
171 if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_LEVEL, property) == 0){
172 g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_DOUBLE) );
173 if(priv->grabbed == FALSE){
174 GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
175 GtkRange *range = (GtkRange*)slider;
176 gdouble update = g_variant_get_double (value);
177-/*
178- g_debug ("volume widget volume prop update with %f", update);
179-*/
180 gtk_range_set_value(range, update);
181+/*
182+ g_debug ("volume-widget::volume_widget_property_update - volume - value %f", update);
183+*/
184 update_accessible_desc(priv->indicator);
185 }
186 }
187- if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_MUTE, property) == 0){
188-/*
189- g_debug ("volume widget - mute update ");
190-*/
191- g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_INT32) );
192+ else if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_MUTE, property) == 0){
193+ g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN));
194 if(priv->grabbed == FALSE){
195 GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
196 GtkRange *range = (GtkRange*)slider;
197- gint update = g_variant_get_int32 (value);
198+ gboolean update = g_variant_get_boolean (value);
199 gdouble level;
200
201-/*
202- g_debug ("volume widget - mute update %i", update);
203-*/
204-
205- if (update == 1){
206+ if (update == TRUE){
207 level = 0;
208 }
209 else{
210- level = g_variant_get_double (dbusmenu_menuitem_property_get_variant (priv->twin_item,
211- DBUSMENU_VOLUME_MENUITEM_LEVEL));
212+ GVariant* variant = dbusmenu_menuitem_property_get_variant (priv->twin_item,
213+ DBUSMENU_VOLUME_MENUITEM_LEVEL);
214+/*
215+ g_debug ("variant for the volume - is it null = %i", variant == NULL);
216+*/
217+ g_return_if_fail (g_variant_is_of_type (variant, G_VARIANT_TYPE_DOUBLE) );
218+
219+ level = g_variant_get_double (variant);
220 }
221+/*
222+ g_debug ("volume-widget::volume_widget_property_update - mute - value %i and level = %f", update, level);
223+*/
224 gtk_range_set_value(range, level);
225-/*
226- g_debug ("volume-widget - update mute with value %i", update);
227-*/
228 }
229 }
230 }
231@@ -185,13 +185,13 @@
232 G_CALLBACK(volume_widget_property_update), self);
233 gdouble initial_level = g_variant_get_double (dbusmenu_menuitem_property_get_variant(twin_item,
234 DBUSMENU_VOLUME_MENUITEM_LEVEL));
235- gint initial_mute = g_variant_get_int32 (dbusmenu_menuitem_property_get_variant(twin_item,
236- DBUSMENU_VOLUME_MENUITEM_MUTE));
237+ gboolean initial_mute = g_variant_get_boolean (dbusmenu_menuitem_property_get_variant(twin_item,
238+ DBUSMENU_VOLUME_MENUITEM_MUTE));
239
240 //g_debug("volume_widget_set_twin_item initial level = %f", initial_level);
241 GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
242 GtkRange *range = (GtkRange*)slider;
243- if(initial_mute == 1){
244+ if(initial_mute == TRUE){
245 initial_level = 0;
246 }
247 gtk_range_set_value(range, initial_level);
248@@ -206,9 +206,11 @@
249 {
250 g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE);
251 VolumeWidget* mitem = VOLUME_WIDGET(user_data);
252+
253 /*
254 g_debug ("changed value %f", new_value);
255 */
256+
257 volume_widget_update(mitem, new_value, "change-value");
258 return FALSE;
259 }
260@@ -222,22 +224,18 @@
261 {
262
263 g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE);
264- VolumeWidget* mitem = VOLUME_WIDGET(user_data);
265+ VolumeWidget* mitem = VOLUME_WIDGET (user_data);
266 VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem);
267 GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
268 gdouble current_value = CLAMP(gtk_range_get_value(GTK_RANGE(slider)), 0, 100);
269-/*
270- g_debug ("value changed %f", gtk_range_get_value(GTK_RANGE(slider)));
271-*/
272-
273- gint mute = g_variant_get_int32 (dbusmenu_menuitem_property_get_variant (priv->twin_item,
274- DBUSMENU_VOLUME_MENUITEM_MUTE));
275-
276- if((current_value == 0 && mute != 1) || current_value == 100){
277+
278+ gboolean mute = g_variant_get_boolean (dbusmenu_menuitem_property_get_variant (priv->twin_item,
279+ DBUSMENU_VOLUME_MENUITEM_MUTE));
280+ if((current_value == 0 && mute == FALSE) || current_value == 100){
281 /*
282 g_debug ("value changed - actual set %f", current_value);
283 */
284- volume_widget_update(mitem, current_value, "value-changed");
285+ volume_widget_update (mitem, current_value, "value-changed");
286 }
287
288 return FALSE;

Subscribers

People subscribed via source and target branches