Merge lp:~ted/indicator-sound/silent-mode into lp:indicator-sound/14.10

Proposed by Ted Gould
Status: Merged
Merged at revision: 457
Proposed branch: lp:~ted/indicator-sound/silent-mode
Merge into: lp:indicator-sound/14.10
Prerequisite: lp:~ted/indicator-sound/lp1358340-greeter-data
Diff against target: 247 lines (+123/-15)
5 files modified
src/CMakeLists.txt (+4/-0)
src/accounts-service-system-sound-settings.vala (+25/-0)
src/accounts-service-user.vala (+40/-0)
src/service.vala (+45/-14)
src/sound-menu.vala (+9/-1)
To merge this branch: bzr merge lp:~ted/indicator-sound/silent-mode
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Ted Gould Pending
Review via email: mp+236971@code.launchpad.net

This proposal supersedes a proposal from 2014-10-02.

Commit message

Show a silent mode checkbox

Description of the change

Silent mode doesn't appear to actually do anything, and I can't figure out who should be doing something about that. But now it shows in the indicator.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~ted/indicator-sound/silent-mode updated
459. By Ted Gould

Update to current trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

There was a small CI Train wreck. The only casualty was that indicator-sound was pushed manually to the archives, which will mean this single branch needs to be merged to trunk manually when the new package has landed (currently in unapproved queue).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2014-10-08 01:58:24 +0000
+++ src/CMakeLists.txt 2014-10-08 01:58:24 +0000
@@ -105,6 +105,7 @@
105 mpris2-interfaces105 mpris2-interfaces
106 accounts-service-sound-settings106 accounts-service-sound-settings
107 accounts-service-privacy-settings107 accounts-service-privacy-settings
108 accounts-service-system-sound-settings
108 greeter-broadcast109 greeter-broadcast
109)110)
110vala_add(indicator-sound-service111vala_add(indicator-sound-service
@@ -114,6 +115,9 @@
114 accounts-service-privacy-settings.vala115 accounts-service-privacy-settings.vala
115)116)
116vala_add(indicator-sound-service117vala_add(indicator-sound-service
118 accounts-service-system-sound-settings.vala
119)
120vala_add(indicator-sound-service
117 greeter-broadcast.vala121 greeter-broadcast.vala
118)122)
119123
120124
=== added file 'src/accounts-service-system-sound-settings.vala'
--- src/accounts-service-system-sound-settings.vala 1970-01-01 00:00:00 +0000
+++ src/accounts-service-system-sound-settings.vala 2014-10-08 01:58:24 +0000
@@ -0,0 +1,25 @@
1/*
2 * Copyright 2014 © Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Ted Gould <ted@canonical.com>
18 */
19
20[DBus (name = "com.ubuntu.touch.AccountsService.Sound")]
21public interface AccountsServiceSystemSoundSettings : Object {
22 // properties
23 public abstract bool silent_mode {owned get; set;}
24}
25
026
=== modified file 'src/accounts-service-user.vala'
--- src/accounts-service-user.vala 2014-10-08 01:58:24 +0000
+++ src/accounts-service-user.vala 2014-10-08 01:58:24 +0000
@@ -22,12 +22,24 @@
22 Act.User? user = null;22 Act.User? user = null;
23 AccountsServiceSoundSettings? proxy = null;23 AccountsServiceSoundSettings? proxy = null;
24 AccountsServicePrivacySettings? privacyproxy = null;24 AccountsServicePrivacySettings? privacyproxy = null;
25 AccountsServiceSystemSoundSettings? syssoundproxy = null;
25 uint timer = 0;26 uint timer = 0;
26 MediaPlayer? _player = null;27 MediaPlayer? _player = null;
27 GreeterBroadcast? greeter = null;28 GreeterBroadcast? greeter = null;
2829
29 public bool showDataOnGreeter { get; set; }30 public bool showDataOnGreeter { get; set; }
3031
32 bool _silentMode = false;
33 public bool silentMode {
34 get {
35 return _silentMode;
36 }
37 set {
38 if (syssoundproxy != null)
39 syssoundproxy.silent_mode = value;
40 }
41 }
42
31 public MediaPlayer? player {43 public MediaPlayer? player {
32 set {44 set {
33 this._player = value;45 this._player = value;
@@ -136,6 +148,14 @@
136 DBusProxyFlags.GET_INVALIDATED_PROPERTIES,148 DBusProxyFlags.GET_INVALIDATED_PROPERTIES,
137 null,149 null,
138 new_privacy_proxy);150 new_privacy_proxy);
151
152 Bus.get_proxy.begin<AccountsServiceSystemSoundSettings> (
153 BusType.SYSTEM,
154 "org.freedesktop.Accounts",
155 user.get_object_path(),
156 DBusProxyFlags.GET_INVALIDATED_PROPERTIES,
157 null,
158 new_system_sound_proxy);
139 }159 }
140 }160 }
141161
@@ -178,6 +198,26 @@
178 }198 }
179 }199 }
180200
201 void new_system_sound_proxy (GLib.Object? obj, AsyncResult res) {
202 try {
203 this.syssoundproxy = Bus.get_proxy.end (res);
204
205 (this.syssoundproxy as DBusProxy).g_properties_changed.connect((proxy, changed, invalid) => {
206 var silentvar = changed.lookup_value("SilentMode", new VariantType("b"));
207 if (silentvar != null) {
208 debug("Silent Mode changed");
209 this._silentMode = silentvar.get_boolean();
210 this.notify_property("silentMode");
211 }
212 });
213
214 this.silentMode = this.syssoundproxy.silent_mode;
215 } catch (Error e) {
216 this.syssoundproxy = null;
217 warning("Unable to get proxy to system sound settings: %s", e.message);
218 }
219 }
220
181 void greeter_proxy_new (GLib.Object? obj, AsyncResult res) {221 void greeter_proxy_new (GLib.Object? obj, AsyncResult res) {
182 try {222 try {
183 this.greeter = Bus.get_proxy.end (res);223 this.greeter = Bus.get_proxy.end (res);
184224
=== modified file 'src/service.vala'
--- src/service.vala 2014-10-08 01:58:24 +0000
+++ src/service.vala 2014-10-08 01:58:24 +0000
@@ -27,38 +27,39 @@
2727
28 this.volume_control = new VolumeControl ();28 this.volume_control = new VolumeControl ();
2929
30 /* If we're on the greeter, don't export */
31 if (GLib.Environment.get_user_name() != "lightdm") {
32 this.accounts_service = new AccountsServiceUser();
33
34 this.accounts_service.notify["showDataOnGreeter"].connect(() => {
35 this.export_to_accounts_service = this.accounts_service.showDataOnGreeter;
36 eventually_update_player_actions();
37 });
38
39 this.export_to_accounts_service = this.accounts_service.showDataOnGreeter;
40 }
41
30 this.players = playerlist;42 this.players = playerlist;
31 this.players.player_added.connect (this.player_added);43 this.players.player_added.connect (this.player_added);
32 this.players.player_removed.connect (this.player_removed);44 this.players.player_removed.connect (this.player_removed);
3345
34 this.actions = new SimpleActionGroup ();46 this.actions = new SimpleActionGroup ();
35 this.actions.add_action_entries (action_entries, this);47 this.actions.add_action_entries (action_entries, this);
48 this.actions.add_action (this.create_silent_mode_action ());
36 this.actions.add_action (this.create_mute_action ());49 this.actions.add_action (this.create_mute_action ());
37 this.actions.add_action (this.create_volume_action ());50 this.actions.add_action (this.create_volume_action ());
38 this.actions.add_action (this.create_mic_volume_action ());51 this.actions.add_action (this.create_mic_volume_action ());
3952
40 this.menus = new HashTable<string, SoundMenu> (str_hash, str_equal);53 this.menus = new HashTable<string, SoundMenu> (str_hash, str_equal);
41 this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS));54 this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS));
42 this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS));55 this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS));
43 this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE));56 this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE));
44 this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS));57 this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS));
4558
46 this.menus.@foreach ( (profile, menu) => {59 this.menus.@foreach ( (profile, menu) => {
47 this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE);60 this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE);
48 });61 });
4962
50 /* If we're on the greeter, don't export */
51 if (GLib.Environment.get_user_name() != "lightdm") {
52 this.accounts_service = new AccountsServiceUser();
53
54 this.accounts_service.notify["showDataOnGreeter"].connect(() => {
55 this.export_to_accounts_service = this.accounts_service.showDataOnGreeter;
56 eventually_update_player_actions();
57 });
58
59 this.export_to_accounts_service = this.accounts_service.showDataOnGreeter;
60 }
61
62 this.sync_preferred_players ();63 this.sync_preferred_players ();
63 this.settings.changed["interested-media-players"].connect ( () => {64 this.settings.changed["interested-media-players"].connect ( () => {
64 this.sync_preferred_players ();65 this.sync_preferred_players ();
@@ -257,6 +258,36 @@
257 root_action.set_state (builder.end());258 root_action.set_state (builder.end());
258 }259 }
259260
261 Action create_silent_mode_action () {
262 bool silentNow = false;
263 if (this.accounts_service != null) {
264 silentNow = this.accounts_service.silentMode;
265 }
266
267 var silent_action = new SimpleAction.stateful ("silent-mode", null, new Variant.boolean (silentNow));
268
269 /* If we're not dealing with accounts service, we'll just always be out
270 of silent mode and that's cool. */
271 if (this.accounts_service == null) {
272 return silent_action;
273 }
274
275 this.accounts_service.notify["silentMode"].connect(() => {
276 silent_action.set_state(new Variant.boolean(this.accounts_service.silentMode));
277 this.update_root_icon ();
278 });
279
280 silent_action.activate.connect ((action, param) => {
281 action.change_state (new Variant.boolean (!action.get_state().get_boolean()));
282 });
283
284 silent_action.change_state.connect ((action, val) => {
285 this.accounts_service.silentMode = val.get_boolean();
286 });
287
288 return silent_action;
289 }
290
260 Action create_mute_action () {291 Action create_mute_action () {
261 var mute_action = new SimpleAction.stateful ("mute", null, new Variant.boolean (this.volume_control.mute));292 var mute_action = new SimpleAction.stateful ("mute", null, new Variant.boolean (this.volume_control.mute));
262293
263294
=== modified file 'src/sound-menu.vala'
--- src/sound-menu.vala 2014-10-08 01:58:24 +0000
+++ src/sound-menu.vala 2014-10-08 01:58:24 +0000
@@ -24,7 +24,8 @@
24 SHOW_MUTE = 1,24 SHOW_MUTE = 1,
25 HIDE_INACTIVE_PLAYERS = 2,25 HIDE_INACTIVE_PLAYERS = 2,
26 HIDE_PLAYERS = 4,26 HIDE_PLAYERS = 4,
27 GREETER_PLAYERS = 827 GREETER_PLAYERS = 8,
28 SHOW_SILENT_MODE = 16
28 }29 }
2930
30 public SoundMenu (string? settings_action, DisplayFlags flags) {31 public SoundMenu (string? settings_action, DisplayFlags flags) {
@@ -34,8 +35,15 @@
34 */35 */
3536
36 this.volume_section = new Menu ();37 this.volume_section = new Menu ();
38
37 if ((flags & DisplayFlags.SHOW_MUTE) != 0)39 if ((flags & DisplayFlags.SHOW_MUTE) != 0)
38 volume_section.append (_("Mute"), "indicator.mute");40 volume_section.append (_("Mute"), "indicator.mute");
41 if ((flags & DisplayFlags.SHOW_SILENT_MODE) != 0) {
42 var item = new MenuItem(_("Silent Mode"), "indicator.silent-mode");
43 item.set_attribute("x-canonical-type", "s", "com.canonical.indicator.switch");
44 volume_section.append_item(item);
45 }
46
39 volume_section.append_item (this.create_slider_menu_item (_("Volume"), "indicator.volume(0)", 0.0, 1.0, 0.01,47 volume_section.append_item (this.create_slider_menu_item (_("Volume"), "indicator.volume(0)", 0.0, 1.0, 0.01,
40 "audio-volume-low-zero-panel",48 "audio-volume-low-zero-panel",
41 "audio-volume-high-panel"));49 "audio-volume-high-panel"));

Subscribers

People subscribed via source and target branches