Merge lp:~gero-bare/wingpanel-indicator-sound/fix-1078143 into lp:~wingpanel-devs/wingpanel-indicator-sound/trunk

Proposed by Gero.Bare
Status: Work in progress
Proposed branch: lp:~gero-bare/wingpanel-indicator-sound/fix-1078143
Merge into: lp:~wingpanel-devs/wingpanel-indicator-sound/trunk
Diff against target: 224 lines (+89/-70)
1 file modified
src/Indicator.vala (+89/-70)
To merge this branch: bzr merge lp:~gero-bare/wingpanel-indicator-sound/fix-1078143
Reviewer Review Type Date Requested Status
WingPanel Devs Pending
Review via email: mp+291072@code.launchpad.net

Description of the change

Enable the indicator to change sound level for the Greeter/lock-screen

first you should whitelist it

Edit:
    /etc/wingpanel.d/pantheon-greeter.whitelist

add the line:

libsound.so

To post a comment you must log in.
83. By Gero.Bare

Enable indicator for non-SESSION server type displays. Greeter.

Revision history for this message
Zisu Andrei (matzipan) wrote :

I'm failing to see the use of this as long as sound is disabled while locked.

Unmerged revisions

83. By Gero.Bare

Enable indicator for non-SESSION server type displays. Greeter.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Indicator.vala'
--- src/Indicator.vala 2016-01-16 16:15:16 +0000
+++ src/Indicator.vala 2016-04-06 04:26:58 +0000
@@ -33,12 +33,16 @@
3333
34 private Wingpanel.Widgets.Separator first_seperator;34 private Wingpanel.Widgets.Separator first_seperator;
3535
36 private Wingpanel.Widgets.Separator volume_seperator;
37
36 private Wingpanel.Widgets.Separator mic_seperator;38 private Wingpanel.Widgets.Separator mic_seperator;
3739
38 private Notify.Notification notification;40 private Notify.Notification notification;
3941
40 private Services.Settings settings;42 private Services.Settings settings;
4143
44 private Wingpanel.IndicatorManager.ServerType server_type;
45
42 bool open = false;46 bool open = false;
43 bool mute_blocks_sound = false;47 bool mute_blocks_sound = false;
44 uint sound_was_blocked_timeout_id;48 uint sound_was_blocked_timeout_id;
@@ -48,7 +52,7 @@
4852
49 unowned Canberra.Context? ca_context = null;53 unowned Canberra.Context? ca_context = null;
5054
51 public Indicator () {55 public Indicator (Wingpanel.IndicatorManager.ServerType server_type) {
52 Object (code_name: Wingpanel.Indicator.SOUND,56 Object (code_name: Wingpanel.Indicator.SOUND,
53 display_name: _("Indicator Sound"),57 display_name: _("Indicator Sound"),
54 description:_("The sound indicator"));58 description:_("The sound indicator"));
@@ -66,6 +70,8 @@
6670
67 this.settings = new Services.Settings ();71 this.settings = new Services.Settings ();
68 settings.notify["max-volume"].connect (set_max_volume);72 settings.notify["max-volume"].connect (set_max_volume);
73
74 this.server_type = server_type;
69 }75 }
7076
71 construct {77 construct {
@@ -157,6 +163,15 @@
157 mic_seperator.no_show_all = false;163 mic_seperator.no_show_all = false;
158 mic_seperator.show ();164 mic_seperator.show ();
159 } else {165 } else {
166
167 if (this.server_type == Wingpanel.IndicatorManager.ServerType.SESSION) {
168 volume_seperator.no_show_all = false;
169 volume_seperator.show ();
170 } else {
171 volume_seperator.no_show_all = true;
172 volume_seperator.hide ();
173 }
174
160 mic_scale.no_show_all = true;175 mic_scale.no_show_all = true;
161 mic_scale.hide();176 mic_scale.hide();
162 mic_seperator.no_show_all = true;177 mic_seperator.no_show_all = true;
@@ -266,9 +281,13 @@
266 }281 }
267282
268 public override Gtk.Widget? get_widget () {283 public override Gtk.Widget? get_widget () {
269 if (main_grid == null) {284 if (main_grid != null)
270 int position = 0;285 return main_grid;
271 main_grid = new Gtk.Grid ();286
287 int position = 0;
288 main_grid = new Gtk.Grid ();
289
290 if (this.server_type == Wingpanel.IndicatorManager.ServerType.SESSION) {
272291
273 var mpris = new Widgets.MprisWidget (settings);292 var mpris = new Widgets.MprisWidget (settings);
274293
@@ -276,8 +295,8 @@
276 close ();295 close ();
277 });296 });
278 volume_control.notify["headphone-plugged"].connect(() => {297 volume_control.notify["headphone-plugged"].connect(() => {
279 if (!volume_control.headphone_plugged)298 if (!volume_control.headphone_plugged)
280 mpris.pause_all ();299 mpris.pause_all ();
281 });300 });
282301
283 main_grid.attach (mpris, 0, position++, 1, 1);302 main_grid.attach (mpris, 0, position++, 1, 1);
@@ -285,66 +304,70 @@
285 first_seperator = new Wingpanel.Widgets.Separator ();304 first_seperator = new Wingpanel.Widgets.Separator ();
286305
287 main_grid.attach (first_seperator, 0, position++, 1, 1);306 main_grid.attach (first_seperator, 0, position++, 1, 1);
288307 }
289 volume_scale.margin_start = 6;308
290 volume_scale.get_switch ().active = !volume_control.mute;309
291 volume_scale.get_switch ().notify["active"].connect (on_volume_switch_change);310 volume_scale.margin_start = 6;
292311 volume_scale.get_switch ().active = !volume_control.mute;
293 volume_scale.get_scale ().value_changed.connect (() => {312 volume_scale.get_switch ().notify["active"].connect (on_volume_switch_change);
294 var vol = new Services.VolumeControl.Volume();313
295 var v = volume_scale.get_scale ().get_value () * this.max_volume;314 volume_scale.get_scale ().value_changed.connect (() => {
296 vol.volume = v.clamp (0.0, this.max_volume);315 var vol = new Services.VolumeControl.Volume();
297 vol.reason = Services.VolumeControl.VolumeReasons.USER_KEYPRESS;316 var v = volume_scale.get_scale ().get_value () * this.max_volume;
298 this.volume_control.volume = vol;317 vol.volume = v.clamp (0.0, this.max_volume);
299 update_volume_icon ();318 vol.reason = Services.VolumeControl.VolumeReasons.USER_KEYPRESS;
300 });319 this.volume_control.volume = vol;
301320 update_volume_icon ();
302 volume_scale.get_scale ().set_value (volume_control.volume.volume);321 });
303 volume_scale.get_scale ().button_release_event.connect ((e) => {322
323 volume_scale.get_scale ().set_value (volume_control.volume.volume);
324 volume_scale.get_scale ().button_release_event.connect ((e) => {
325 play_sound_blubble ();
326 return false;
327 });
328 volume_scale.get_scale ().scroll_event.connect ((e) => {
329 int dir = 0;
330 if (e.direction == Gdk.ScrollDirection.UP || e.direction == Gdk.ScrollDirection.RIGHT ||
331 (e.direction == Gdk.ScrollDirection.SMOOTH && e.delta_y < 0)) {
332 dir = 1;
333 } else if (e.direction == Gdk.ScrollDirection.DOWN || e.direction == Gdk.ScrollDirection.LEFT ||
334 (e.direction == Gdk.ScrollDirection.SMOOTH && e.delta_y > 0)) {
335 dir = -1;
336 }
337
338 double v = volume_scale.get_scale ().get_value ();
339 v = v + volume_step_percentage * dir;
340
341 if (v >= -0.05 && v <= 1.05) {
342 volume_scale.get_scale ().set_value (v);
304 play_sound_blubble ();343 play_sound_blubble ();
305 return false;344 }
306 });345 return true;
307 volume_scale.get_scale ().scroll_event.connect ((e) => {346 });
308 int dir = 0;347
309 if (e.direction == Gdk.ScrollDirection.UP || e.direction == Gdk.ScrollDirection.RIGHT ||348 update_volume_icon ();
310 (e.direction == Gdk.ScrollDirection.SMOOTH && e.delta_y < 0)) {349 set_max_volume ();
311 dir = 1;350
312 } else if (e.direction == Gdk.ScrollDirection.DOWN || e.direction == Gdk.ScrollDirection.LEFT ||351 main_grid.attach (volume_scale, 0, position++, 1, 1);
313 (e.direction == Gdk.ScrollDirection.SMOOTH && e.delta_y > 0)) {352
314 dir = -1;353 volume_seperator = new Wingpanel.Widgets.Separator ();
315 }354 main_grid.attach (volume_seperator, 0, position++, 1, 1);
316355
317 double v = volume_scale.get_scale ().get_value ();356 mic_scale.margin_start = 6;
318 v = v + volume_step_percentage * dir;357 mic_scale.get_switch ().active = !volume_control.micMute;
319358 mic_scale.get_switch ().notify["active"].connect (on_mic_switch_change);
320 if (v >= -0.05 && v <= 1.05) {359
321 volume_scale.get_scale ().set_value (v);360 mic_scale.get_scale ().value_changed.connect (() => {
322 play_sound_blubble ();361 volume_control.mic_volume = mic_scale.get_scale ().get_value ();
323 }362 });
324 return true;363
325 });364 main_grid.attach (mic_scale, 0, position++, 1, 1);
326365
327 update_volume_icon ();366 mic_seperator = new Wingpanel.Widgets.Separator ();
328 set_max_volume ();367
329368 update_mic_visibility ();
330 main_grid.attach (volume_scale, 0, position++, 1, 1);369
331370 if (this.server_type == Wingpanel.IndicatorManager.ServerType.SESSION) {
332 main_grid.attach (new Wingpanel.Widgets.Separator (), 0, position++, 1, 1);
333
334 mic_scale.margin_start = 6;
335 mic_scale.get_switch ().active = !volume_control.micMute;
336 mic_scale.get_switch ().notify["active"].connect (on_mic_switch_change);
337
338 mic_scale.get_scale ().value_changed.connect (() => {
339 volume_control.mic_volume = mic_scale.get_scale ().get_value ();
340 });
341
342 main_grid.attach (mic_scale, 0, position++, 1, 1);
343
344 mic_seperator = new Wingpanel.Widgets.Separator ();
345
346 update_mic_visibility ();
347
348 main_grid.attach (mic_seperator, 0, position++, 1, 1);371 main_grid.attach (mic_seperator, 0, position++, 1, 1);
349372
350 settings_button = new Wingpanel.Widgets.Button (_("Sound Settingsā€¦"));373 settings_button = new Wingpanel.Widgets.Button (_("Sound Settingsā€¦"));
@@ -389,10 +412,6 @@
389public Wingpanel.Indicator? get_indicator (Module module, Wingpanel.IndicatorManager.ServerType server_type) {412public Wingpanel.Indicator? get_indicator (Module module, Wingpanel.IndicatorManager.ServerType server_type) {
390 debug ("Activating Sound Indicator");413 debug ("Activating Sound Indicator");
391414
392 if (server_type != Wingpanel.IndicatorManager.ServerType.SESSION) {415 var indicator = new Sound.Indicator (server_type);
393 return null;
394 }
395
396 var indicator = new Sound.Indicator ();
397 return indicator;416 return indicator;
398}417}

Subscribers

People subscribed via source and target branches

to all changes: