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
1=== modified file 'src/Indicator.vala'
2--- src/Indicator.vala 2016-01-16 16:15:16 +0000
3+++ src/Indicator.vala 2016-04-06 04:26:58 +0000
4@@ -33,12 +33,16 @@
5
6 private Wingpanel.Widgets.Separator first_seperator;
7
8+ private Wingpanel.Widgets.Separator volume_seperator;
9+
10 private Wingpanel.Widgets.Separator mic_seperator;
11
12 private Notify.Notification notification;
13
14 private Services.Settings settings;
15
16+ private Wingpanel.IndicatorManager.ServerType server_type;
17+
18 bool open = false;
19 bool mute_blocks_sound = false;
20 uint sound_was_blocked_timeout_id;
21@@ -48,7 +52,7 @@
22
23 unowned Canberra.Context? ca_context = null;
24
25- public Indicator () {
26+ public Indicator (Wingpanel.IndicatorManager.ServerType server_type) {
27 Object (code_name: Wingpanel.Indicator.SOUND,
28 display_name: _("Indicator Sound"),
29 description:_("The sound indicator"));
30@@ -66,6 +70,8 @@
31
32 this.settings = new Services.Settings ();
33 settings.notify["max-volume"].connect (set_max_volume);
34+
35+ this.server_type = server_type;
36 }
37
38 construct {
39@@ -157,6 +163,15 @@
40 mic_seperator.no_show_all = false;
41 mic_seperator.show ();
42 } else {
43+
44+ if (this.server_type == Wingpanel.IndicatorManager.ServerType.SESSION) {
45+ volume_seperator.no_show_all = false;
46+ volume_seperator.show ();
47+ } else {
48+ volume_seperator.no_show_all = true;
49+ volume_seperator.hide ();
50+ }
51+
52 mic_scale.no_show_all = true;
53 mic_scale.hide();
54 mic_seperator.no_show_all = true;
55@@ -266,9 +281,13 @@
56 }
57
58 public override Gtk.Widget? get_widget () {
59- if (main_grid == null) {
60- int position = 0;
61- main_grid = new Gtk.Grid ();
62+ if (main_grid != null)
63+ return main_grid;
64+
65+ int position = 0;
66+ main_grid = new Gtk.Grid ();
67+
68+ if (this.server_type == Wingpanel.IndicatorManager.ServerType.SESSION) {
69
70 var mpris = new Widgets.MprisWidget (settings);
71
72@@ -276,8 +295,8 @@
73 close ();
74 });
75 volume_control.notify["headphone-plugged"].connect(() => {
76- if (!volume_control.headphone_plugged)
77- mpris.pause_all ();
78+ if (!volume_control.headphone_plugged)
79+ mpris.pause_all ();
80 });
81
82 main_grid.attach (mpris, 0, position++, 1, 1);
83@@ -285,66 +304,70 @@
84 first_seperator = new Wingpanel.Widgets.Separator ();
85
86 main_grid.attach (first_seperator, 0, position++, 1, 1);
87-
88- volume_scale.margin_start = 6;
89- volume_scale.get_switch ().active = !volume_control.mute;
90- volume_scale.get_switch ().notify["active"].connect (on_volume_switch_change);
91-
92- volume_scale.get_scale ().value_changed.connect (() => {
93- var vol = new Services.VolumeControl.Volume();
94- var v = volume_scale.get_scale ().get_value () * this.max_volume;
95- vol.volume = v.clamp (0.0, this.max_volume);
96- vol.reason = Services.VolumeControl.VolumeReasons.USER_KEYPRESS;
97- this.volume_control.volume = vol;
98- update_volume_icon ();
99- });
100-
101- volume_scale.get_scale ().set_value (volume_control.volume.volume);
102- volume_scale.get_scale ().button_release_event.connect ((e) => {
103+ }
104+
105+
106+ volume_scale.margin_start = 6;
107+ volume_scale.get_switch ().active = !volume_control.mute;
108+ volume_scale.get_switch ().notify["active"].connect (on_volume_switch_change);
109+
110+ volume_scale.get_scale ().value_changed.connect (() => {
111+ var vol = new Services.VolumeControl.Volume();
112+ var v = volume_scale.get_scale ().get_value () * this.max_volume;
113+ vol.volume = v.clamp (0.0, this.max_volume);
114+ vol.reason = Services.VolumeControl.VolumeReasons.USER_KEYPRESS;
115+ this.volume_control.volume = vol;
116+ update_volume_icon ();
117+ });
118+
119+ volume_scale.get_scale ().set_value (volume_control.volume.volume);
120+ volume_scale.get_scale ().button_release_event.connect ((e) => {
121+ play_sound_blubble ();
122+ return false;
123+ });
124+ volume_scale.get_scale ().scroll_event.connect ((e) => {
125+ int dir = 0;
126+ if (e.direction == Gdk.ScrollDirection.UP || e.direction == Gdk.ScrollDirection.RIGHT ||
127+ (e.direction == Gdk.ScrollDirection.SMOOTH && e.delta_y < 0)) {
128+ dir = 1;
129+ } else if (e.direction == Gdk.ScrollDirection.DOWN || e.direction == Gdk.ScrollDirection.LEFT ||
130+ (e.direction == Gdk.ScrollDirection.SMOOTH && e.delta_y > 0)) {
131+ dir = -1;
132+ }
133+
134+ double v = volume_scale.get_scale ().get_value ();
135+ v = v + volume_step_percentage * dir;
136+
137+ if (v >= -0.05 && v <= 1.05) {
138+ volume_scale.get_scale ().set_value (v);
139 play_sound_blubble ();
140- return false;
141- });
142- volume_scale.get_scale ().scroll_event.connect ((e) => {
143- int dir = 0;
144- if (e.direction == Gdk.ScrollDirection.UP || e.direction == Gdk.ScrollDirection.RIGHT ||
145- (e.direction == Gdk.ScrollDirection.SMOOTH && e.delta_y < 0)) {
146- dir = 1;
147- } else if (e.direction == Gdk.ScrollDirection.DOWN || e.direction == Gdk.ScrollDirection.LEFT ||
148- (e.direction == Gdk.ScrollDirection.SMOOTH && e.delta_y > 0)) {
149- dir = -1;
150- }
151-
152- double v = volume_scale.get_scale ().get_value ();
153- v = v + volume_step_percentage * dir;
154-
155- if (v >= -0.05 && v <= 1.05) {
156- volume_scale.get_scale ().set_value (v);
157- play_sound_blubble ();
158- }
159- return true;
160- });
161-
162- update_volume_icon ();
163- set_max_volume ();
164-
165- main_grid.attach (volume_scale, 0, position++, 1, 1);
166-
167- main_grid.attach (new Wingpanel.Widgets.Separator (), 0, position++, 1, 1);
168-
169- mic_scale.margin_start = 6;
170- mic_scale.get_switch ().active = !volume_control.micMute;
171- mic_scale.get_switch ().notify["active"].connect (on_mic_switch_change);
172-
173- mic_scale.get_scale ().value_changed.connect (() => {
174- volume_control.mic_volume = mic_scale.get_scale ().get_value ();
175- });
176-
177- main_grid.attach (mic_scale, 0, position++, 1, 1);
178-
179- mic_seperator = new Wingpanel.Widgets.Separator ();
180-
181- update_mic_visibility ();
182-
183+ }
184+ return true;
185+ });
186+
187+ update_volume_icon ();
188+ set_max_volume ();
189+
190+ main_grid.attach (volume_scale, 0, position++, 1, 1);
191+
192+ volume_seperator = new Wingpanel.Widgets.Separator ();
193+ main_grid.attach (volume_seperator, 0, position++, 1, 1);
194+
195+ mic_scale.margin_start = 6;
196+ mic_scale.get_switch ().active = !volume_control.micMute;
197+ mic_scale.get_switch ().notify["active"].connect (on_mic_switch_change);
198+
199+ mic_scale.get_scale ().value_changed.connect (() => {
200+ volume_control.mic_volume = mic_scale.get_scale ().get_value ();
201+ });
202+
203+ main_grid.attach (mic_scale, 0, position++, 1, 1);
204+
205+ mic_seperator = new Wingpanel.Widgets.Separator ();
206+
207+ update_mic_visibility ();
208+
209+ if (this.server_type == Wingpanel.IndicatorManager.ServerType.SESSION) {
210 main_grid.attach (mic_seperator, 0, position++, 1, 1);
211
212 settings_button = new Wingpanel.Widgets.Button (_("Sound Settingsā€¦"));
213@@ -389,10 +412,6 @@
214 public Wingpanel.Indicator? get_indicator (Module module, Wingpanel.IndicatorManager.ServerType server_type) {
215 debug ("Activating Sound Indicator");
216
217- if (server_type != Wingpanel.IndicatorManager.ServerType.SESSION) {
218- return null;
219- }
220-
221- var indicator = new Sound.Indicator ();
222+ var indicator = new Sound.Indicator (server_type);
223 return indicator;
224 }

Subscribers

People subscribed via source and target branches

to all changes: