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

Proposed by Conor Curran
Status: Merged
Merged at revision: 223
Proposed branch: lp:~cjcurran/indicator-sound/mute-behaviour-part2
Merge into: lp:~indicator-applet-developers/indicator-sound/trunk_3
Diff against target: 404 lines (+106/-61)
7 files modified
src/common-defs.h (+2/-1)
src/device.c (+35/-36)
src/device.h (+5/-5)
src/pulseaudio-mgr.c (+12/-12)
src/slider-menu-item.c (+18/-3)
src/voip-input-widget.c (+1/-1)
src/volume-widget.c (+33/-3)
To merge this branch: bzr merge lp:~cjcurran/indicator-sound/mute-behaviour-part2
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+53469@code.launchpad.net

Description of the change

Final part in this mute behaviour bug. Both the voip slider and volume slider now have identical behaviour.

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

The only thing that is odd to me is that the mute is being passed as an
int32 instead of a boolean. It seems that's how it's stored on both
sides, might as well match that on DBus.

Shouldn't break anything though.

  review approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/common-defs.h'
2--- src/common-defs.h 2011-03-09 14:17:12 +0000
3+++ src/common-defs.h 2011-03-15 15:53:22 +0000
4@@ -45,12 +45,13 @@
5 TRANSPORT_STATE_PAUSED
6 }TransportState;
7
8-#define NOT_ACTIVE -1
9+#define NOT_ACTIVE -1
10 #define DBUSMENU_PROPERTY_EMPTY -1
11
12 /* DBUS Custom Items */
13 #define DBUSMENU_VOLUME_MENUITEM_TYPE "x-canonical-ido-volume-type"
14 #define DBUSMENU_VOLUME_MENUITEM_LEVEL "x-canonical-ido-volume-level"
15+#define DBUSMENU_VOLUME_MENUITEM_MUTE "x-canonical-ido-volume-mute"
16
17 #define DBUSMENU_VOIP_INPUT_MENUITEM_TYPE "x-canonical-ido-voip-input-type"
18 #define DBUSMENU_VOIP_INPUT_MENUITEM_LEVEL "x-canonical-ido-voip-input-level"
19
20=== modified file 'src/device.c'
21--- src/device.c 2011-03-14 19:47:59 +0000
22+++ src/device.c 2011-03-15 15:53:22 +0000
23@@ -90,11 +90,10 @@
24 }
25
26 void
27-device_populate (Device* self,
28+device_sink_populate (Device* self,
29 const pa_sink_info* update)
30 {
31 DevicePrivate* priv = DEVICE_GET_PRIVATE(self);
32- device_mute_update (self, update->mute);
33 mute_menu_item_enable (priv->mute_menuitem, TRUE);
34 slider_menu_item_populate (priv->volume_slider_menuitem, update);
35 SoundState state = device_get_state_from_volume (self);
36@@ -103,37 +102,11 @@
37 sound_service_dbus_update_sound_state (priv->service,
38 priv->current_sound_state);
39 }
40-
41-}
42-
43-void
44-device_activate_voip_item (Device* self, gint sink_input_index, gint client_index)
45-{
46- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
47- if (voip_input_menu_item_is_interested (priv->voip_input_menu_item,
48- sink_input_index,
49- client_index)){
50- voip_input_menu_item_enable (priv->voip_input_menu_item, TRUE);
51- }
52-}
53-
54-void
55-device_deactivate_voip_source (Device* self, gboolean visible)
56-{
57- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
58- visible &= voip_input_menu_item_is_active (priv->voip_input_menu_item);
59- voip_input_menu_item_deactivate_source (priv->voip_input_menu_item, visible);
60-}
61-
62-void
63-device_deactivate_voip_client (Device* self)
64-{
65- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
66- voip_input_menu_item_deactivate_voip_client (priv->voip_input_menu_item);
67-}
68-
69-void
70-device_update (Device* self,
71+ device_mute_update (self, update->mute);
72+}
73+
74+void
75+device_sink_update (Device* self,
76 const pa_sink_info* update)
77 {
78 DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
79@@ -223,22 +196,48 @@
80 }
81
82 gint
83-device_get_index (Device* self)
84+device_get_sink_index (Device* self)
85 {
86 DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
87 return slider_menu_item_get_sink_index (priv->volume_slider_menuitem);
88 }
89
90 gboolean
91-device_is_populated (Device* self)
92+device_is_sink_populated (Device* self)
93 {
94 DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
95 return dbusmenu_menuitem_property_get_bool (DBUSMENU_MENUITEM (priv->volume_slider_menuitem),
96 DBUSMENU_MENUITEM_PROP_ENABLED);
97 }
98
99+void
100+device_activate_voip_item (Device* self, gint sink_input_index, gint client_index)
101+{
102+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
103+ if (voip_input_menu_item_is_interested (priv->voip_input_menu_item,
104+ sink_input_index,
105+ client_index)){
106+ voip_input_menu_item_enable (priv->voip_input_menu_item, TRUE);
107+ }
108+}
109+
110+void
111+device_deactivate_voip_source (Device* self, gboolean visible)
112+{
113+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
114+ visible &= voip_input_menu_item_is_active (priv->voip_input_menu_item);
115+ voip_input_menu_item_deactivate_source (priv->voip_input_menu_item, visible);
116+}
117+
118+void
119+device_deactivate_voip_client (Device* self)
120+{
121+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
122+ voip_input_menu_item_deactivate_voip_client (priv->voip_input_menu_item);
123+}
124+
125 void
126-device_deactivate (Device* self)
127+device_sink_deactivated (Device* self)
128 {
129 DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
130 priv->current_sound_state = UNAVAILABLE;
131
132=== modified file 'src/device.h'
133--- src/device.h 2011-03-14 19:47:59 +0000
134+++ src/device.h 2011-03-15 15:53:22 +0000
135@@ -58,11 +58,11 @@
136 */
137
138 // Sink related
139-void device_populate (Device* sink, const pa_sink_info* update);
140-void device_update (Device* sink, const pa_sink_info* update);
141-gboolean device_is_populated (Device* sink);
142-gint device_get_index (Device* self);
143-void device_deactivate (Device* self);
144+void device_sink_populate (Device* sink, const pa_sink_info* update);
145+void device_sink_update (Device* sink, const pa_sink_info* update);
146+gboolean device_is_sink_populated (Device* sink);
147+gint device_get_sink_index (Device* self);
148+void device_sink_deactivated (Device* self);
149 void device_update_mute (Device* self, gboolean mute_update);
150 void device_ensure_sink_is_unmuted (Device* self);
151
152
153=== modified file 'src/pulseaudio-mgr.c'
154--- src/pulseaudio-mgr.c 2011-03-14 19:47:59 +0000
155+++ src/pulseaudio-mgr.c 2011-03-15 15:53:22 +0000
156@@ -226,11 +226,11 @@
157 case PA_SUBSCRIPTION_EVENT_SINK:
158
159 // We don't care about any other sink other than the active one.
160- if (index != device_get_index (sink))
161+ if (index != device_get_sink_index (sink))
162 return;
163
164 if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
165- device_deactivate (sink);
166+ device_sink_deactivated (sink);
167
168 }
169 else{
170@@ -308,7 +308,7 @@
171 break;
172 case PA_CONTEXT_FAILED:
173 g_warning("PA_CONTEXT_FAILED - Is PulseAudio Daemon running ?");
174- device_deactivate (DEVICE (userdata));
175+ device_sink_deactivated (DEVICE (userdata));
176 if (reconnect_idle_id == 0){
177 reconnect_idle_id = g_timeout_add_seconds (RECONNECT_DELAY,
178 reconnect_to_pulse,
179@@ -362,7 +362,7 @@
180
181 if (info == NULL) {
182 g_warning("No PA server - get the hell out of here");
183- device_deactivate (DEVICE (userdata));
184+ device_sink_deactivated (DEVICE (userdata));
185 return;
186 }
187 // Go for the default sink
188@@ -373,7 +373,7 @@
189 pm_default_sink_info_callback,
190 userdata) )) {
191 g_warning("pa_context_get_sink_info_by_namet() failed");
192- device_deactivate (DEVICE (userdata));
193+ device_sink_deactivated (DEVICE (userdata));
194 pa_operation_unref(operation);
195 return;
196 }
197@@ -382,7 +382,7 @@
198 pm_sink_info_callback,
199 userdata))) {
200 g_warning("pa_context_get_sink_info_list() failed");
201- device_deactivate (DEVICE (userdata));
202+ device_sink_deactivated (DEVICE (userdata));
203 pa_operation_unref(operation);
204 return;
205 }
206@@ -426,9 +426,9 @@
207 return;
208 }
209 Device* a_sink = DEVICE (userdata);
210- if (device_is_populated (a_sink) == FALSE &&
211+ if (device_is_sink_populated (a_sink) == FALSE &&
212 g_ascii_strncasecmp("auto_null", sink->name, 9) != 0){
213- device_populate (a_sink, sink);
214+ device_sink_populate (a_sink, sink);
215 }
216 }
217 }
218@@ -448,11 +448,11 @@
219 return;
220 }
221 // Only repopulate if there is a change with regards the index
222- if (device_get_index (DEVICE (userdata)) == info->index)
223+ if (device_get_sink_index (DEVICE (userdata)) == info->index)
224 return;
225
226 g_debug ("Pulse Server has handed us a new default sink");
227- device_populate (DEVICE (userdata), info);
228+ device_sink_populate (DEVICE (userdata), info);
229 }
230 }
231
232@@ -494,7 +494,7 @@
233 }
234
235 // And finally check for the mute blocking state
236- if (device_get_index (a_sink) == info->sink){
237+ if (device_get_sink_index (a_sink) == info->sink){
238 device_determine_blocking_state (a_sink);
239 }
240 }
241@@ -514,7 +514,7 @@
242 g_warning ("update_device - our user data is not what we think it should be or the info parameter is null");
243 return;
244 }
245- device_update (DEVICE(userdata), info);
246+ device_sink_update (DEVICE(userdata), info);
247 }
248 }
249
250
251=== modified file 'src/slider-menu-item.c'
252--- src/slider-menu-item.c 2011-03-14 19:47:59 +0000
253+++ src/slider-menu-item.c 2011-03-15 15:53:22 +0000
254@@ -28,9 +28,10 @@
255 typedef struct _SliderMenuItemPrivate SliderMenuItemPrivate;
256
257 struct _SliderMenuItemPrivate {
258- Device* a_sink;
259+ Device* a_sink;
260 gint index;
261 gchar* name;
262+ gboolean mute;
263 pa_cvolume volume;
264 pa_channel_map channel_map;
265 pa_volume_t base_volume;
266@@ -75,7 +76,7 @@
267
268 SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self);
269
270- priv->index = -1;
271+ priv->index = NOT_ACTIVE;
272 priv->name = NULL;
273
274 return;
275@@ -127,6 +128,7 @@
276 priv->volume = slider_menu_item_construct_mono_volume (&update->volume);
277 priv->base_volume = update->base_volume;
278 priv->channel_map = update->channel_map;
279+ priv->mute = update->mute;
280
281 pa_volume_t vol = pa_cvolume_max (&update->volume);
282 gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
283@@ -134,6 +136,11 @@
284 dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
285 DBUSMENU_VOLUME_MENUITEM_LEVEL,
286 new_volume);
287+ GVariant* new_mute_update = g_variant_new_int32 (update->mute);
288+ dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
289+ DBUSMENU_VOLUME_MENUITEM_MUTE,
290+ new_mute_update);
291+
292 slider_menu_item_enable (self, TRUE);
293 }
294
295@@ -170,6 +177,14 @@
296 dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
297 DBUSMENU_VOLUME_MENUITEM_LEVEL,
298 new_volume);
299+ if (priv->mute != update->mute){
300+ priv->mute = update->mute;
301+ g_debug ("volume menu item - update - mute = %i", update->mute);
302+ GVariant* new_mute_update = g_variant_new_int32 (update->mute);
303+ dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
304+ DBUSMENU_VOLUME_MENUITEM_MUTE,
305+ new_mute_update);
306+ }
307 }
308
309 /*
310@@ -185,7 +200,7 @@
311 DBUSMENU_MENUITEM_PROP_ENABLED,
312 active);
313 if(active == FALSE){
314- priv->index = -1;
315+ priv->index = NOT_ACTIVE;
316 if(priv->name != NULL){
317 g_free(priv->name);
318 priv->name = NULL;
319
320=== modified file 'src/voip-input-widget.c'
321--- src/voip-input-widget.c 2011-03-09 16:38:11 +0000
322+++ src/voip-input-widget.c 2011-03-15 15:53:22 +0000
323@@ -95,7 +95,7 @@
324 g_signal_connect(priv->ido_voip_input_slider, "slider-released", G_CALLBACK(voip_input_widget_slider_released), self);
325
326 GtkWidget* primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)priv->ido_voip_input_slider);
327- GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks("audio-input-microphone-none-panel");
328+ GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks("audio-input-microphone-zero-panel");
329 gtk_image_set_from_gicon(GTK_IMAGE(primary_image), primary_gicon, GTK_ICON_SIZE_MENU);
330 g_object_unref(primary_gicon);
331
332
333=== modified file 'src/volume-widget.c'
334--- src/volume-widget.c 2011-03-10 19:48:26 +0000
335+++ src/volume-widget.c 2011-03-15 15:53:22 +0000
336@@ -128,11 +128,11 @@
337 GVariant* value, gpointer userdata)
338 {
339 g_return_if_fail (IS_VOLUME_WIDGET (userdata));
340- g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_DOUBLE) );
341 VolumeWidget* mitem = VOLUME_WIDGET(userdata);
342 VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem);
343- //g_debug("scrub-widget::property_update for prop %s", property);
344+
345 if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_LEVEL, property) == 0){
346+ g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_DOUBLE) );
347 if(priv->grabbed == FALSE){
348 GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
349 GtkRange *range = (GtkRange*)slider;
350@@ -141,6 +141,27 @@
351 update_accessible_desc(priv->indicator);
352 }
353 }
354+ if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_MUTE, property) == 0){
355+ g_debug ("volume widget - mute update ");
356+ if(priv->grabbed == FALSE){
357+ GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
358+ GtkRange *range = (GtkRange*)slider;
359+ gint update = g_variant_get_int32 (value);
360+ gdouble level;
361+
362+ g_debug ("volume widget - mute update %i", update);
363+
364+ if (update == 1){
365+ level = 0;
366+ }
367+ else{
368+ level = g_variant_get_double (dbusmenu_menuitem_property_get_variant (priv->twin_item,
369+ DBUSMENU_VOLUME_MENUITEM_LEVEL));
370+ }
371+ gtk_range_set_value(range, level);
372+ g_debug ("volume-widget - update mute with value %i", update);
373+ }
374+ }
375 }
376
377 static void
378@@ -154,9 +175,15 @@
379 G_CALLBACK(volume_widget_property_update), self);
380 gdouble initial_level = g_variant_get_double (dbusmenu_menuitem_property_get_variant(twin_item,
381 DBUSMENU_VOLUME_MENUITEM_LEVEL));
382+ gint initial_mute = g_variant_get_int32 (dbusmenu_menuitem_property_get_variant(twin_item,
383+ DBUSMENU_VOLUME_MENUITEM_MUTE));
384+
385 //g_debug("volume_widget_set_twin_item initial level = %f", initial_level);
386 GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
387 GtkRange *range = (GtkRange*)slider;
388+ if(initial_mute == 1){
389+ initial_level = 0;
390+ }
391 gtk_range_set_value(range, initial_level);
392 update_accessible_desc(priv->indicator);
393 }
394@@ -188,7 +215,10 @@
395 GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
396 gdouble current_value = CLAMP(gtk_range_get_value(GTK_RANGE(slider)), 0, 100);
397 //g_debug ("value changed %f", gtk_range_get_value(GTK_RANGE(slider)));
398- if(current_value == 0 || current_value == 100){
399+ gint mute = g_variant_get_int32 (dbusmenu_menuitem_property_get_variant (priv->twin_item,
400+ DBUSMENU_VOLUME_MENUITEM_MUTE));
401+
402+ if((current_value == 0 && mute != 1) || current_value == 100){
403 volume_widget_update(mitem, current_value);
404 }
405

Subscribers

People subscribed via source and target branches