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
1=== modified file 'src/CMakeLists.txt'
2--- src/CMakeLists.txt 2014-10-08 01:58:24 +0000
3+++ src/CMakeLists.txt 2014-10-08 01:58:24 +0000
4@@ -105,6 +105,7 @@
5 mpris2-interfaces
6 accounts-service-sound-settings
7 accounts-service-privacy-settings
8+ accounts-service-system-sound-settings
9 greeter-broadcast
10 )
11 vala_add(indicator-sound-service
12@@ -114,6 +115,9 @@
13 accounts-service-privacy-settings.vala
14 )
15 vala_add(indicator-sound-service
16+ accounts-service-system-sound-settings.vala
17+)
18+vala_add(indicator-sound-service
19 greeter-broadcast.vala
20 )
21
22
23=== added file 'src/accounts-service-system-sound-settings.vala'
24--- src/accounts-service-system-sound-settings.vala 1970-01-01 00:00:00 +0000
25+++ src/accounts-service-system-sound-settings.vala 2014-10-08 01:58:24 +0000
26@@ -0,0 +1,25 @@
27+/*
28+ * Copyright 2014 © Canonical Ltd.
29+ *
30+ * This program is free software; you can redistribute it and/or modify
31+ * it under the terms of the GNU General Public License as published by
32+ * the Free Software Foundation; version 3.
33+ *
34+ * This program is distributed in the hope that it will be useful,
35+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
36+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37+ * GNU General Public License for more details.
38+ *
39+ * You should have received a copy of the GNU General Public License
40+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
41+ *
42+ * Authors:
43+ * Ted Gould <ted@canonical.com>
44+ */
45+
46+[DBus (name = "com.ubuntu.touch.AccountsService.Sound")]
47+public interface AccountsServiceSystemSoundSettings : Object {
48+ // properties
49+ public abstract bool silent_mode {owned get; set;}
50+}
51+
52
53=== modified file 'src/accounts-service-user.vala'
54--- src/accounts-service-user.vala 2014-10-08 01:58:24 +0000
55+++ src/accounts-service-user.vala 2014-10-08 01:58:24 +0000
56@@ -22,12 +22,24 @@
57 Act.User? user = null;
58 AccountsServiceSoundSettings? proxy = null;
59 AccountsServicePrivacySettings? privacyproxy = null;
60+ AccountsServiceSystemSoundSettings? syssoundproxy = null;
61 uint timer = 0;
62 MediaPlayer? _player = null;
63 GreeterBroadcast? greeter = null;
64
65 public bool showDataOnGreeter { get; set; }
66
67+ bool _silentMode = false;
68+ public bool silentMode {
69+ get {
70+ return _silentMode;
71+ }
72+ set {
73+ if (syssoundproxy != null)
74+ syssoundproxy.silent_mode = value;
75+ }
76+ }
77+
78 public MediaPlayer? player {
79 set {
80 this._player = value;
81@@ -136,6 +148,14 @@
82 DBusProxyFlags.GET_INVALIDATED_PROPERTIES,
83 null,
84 new_privacy_proxy);
85+
86+ Bus.get_proxy.begin<AccountsServiceSystemSoundSettings> (
87+ BusType.SYSTEM,
88+ "org.freedesktop.Accounts",
89+ user.get_object_path(),
90+ DBusProxyFlags.GET_INVALIDATED_PROPERTIES,
91+ null,
92+ new_system_sound_proxy);
93 }
94 }
95
96@@ -178,6 +198,26 @@
97 }
98 }
99
100+ void new_system_sound_proxy (GLib.Object? obj, AsyncResult res) {
101+ try {
102+ this.syssoundproxy = Bus.get_proxy.end (res);
103+
104+ (this.syssoundproxy as DBusProxy).g_properties_changed.connect((proxy, changed, invalid) => {
105+ var silentvar = changed.lookup_value("SilentMode", new VariantType("b"));
106+ if (silentvar != null) {
107+ debug("Silent Mode changed");
108+ this._silentMode = silentvar.get_boolean();
109+ this.notify_property("silentMode");
110+ }
111+ });
112+
113+ this.silentMode = this.syssoundproxy.silent_mode;
114+ } catch (Error e) {
115+ this.syssoundproxy = null;
116+ warning("Unable to get proxy to system sound settings: %s", e.message);
117+ }
118+ }
119+
120 void greeter_proxy_new (GLib.Object? obj, AsyncResult res) {
121 try {
122 this.greeter = Bus.get_proxy.end (res);
123
124=== modified file 'src/service.vala'
125--- src/service.vala 2014-10-08 01:58:24 +0000
126+++ src/service.vala 2014-10-08 01:58:24 +0000
127@@ -27,38 +27,39 @@
128
129 this.volume_control = new VolumeControl ();
130
131+ /* If we're on the greeter, don't export */
132+ if (GLib.Environment.get_user_name() != "lightdm") {
133+ this.accounts_service = new AccountsServiceUser();
134+
135+ this.accounts_service.notify["showDataOnGreeter"].connect(() => {
136+ this.export_to_accounts_service = this.accounts_service.showDataOnGreeter;
137+ eventually_update_player_actions();
138+ });
139+
140+ this.export_to_accounts_service = this.accounts_service.showDataOnGreeter;
141+ }
142+
143 this.players = playerlist;
144 this.players.player_added.connect (this.player_added);
145 this.players.player_removed.connect (this.player_removed);
146
147 this.actions = new SimpleActionGroup ();
148 this.actions.add_action_entries (action_entries, this);
149+ this.actions.add_action (this.create_silent_mode_action ());
150 this.actions.add_action (this.create_mute_action ());
151 this.actions.add_action (this.create_volume_action ());
152 this.actions.add_action (this.create_mic_volume_action ());
153
154 this.menus = new HashTable<string, SoundMenu> (str_hash, str_equal);
155 this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS));
156- this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS));
157+ this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS));
158 this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE));
159- this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS));
160+ this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS));
161
162 this.menus.@foreach ( (profile, menu) => {
163 this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE);
164 });
165
166- /* If we're on the greeter, don't export */
167- if (GLib.Environment.get_user_name() != "lightdm") {
168- this.accounts_service = new AccountsServiceUser();
169-
170- this.accounts_service.notify["showDataOnGreeter"].connect(() => {
171- this.export_to_accounts_service = this.accounts_service.showDataOnGreeter;
172- eventually_update_player_actions();
173- });
174-
175- this.export_to_accounts_service = this.accounts_service.showDataOnGreeter;
176- }
177-
178 this.sync_preferred_players ();
179 this.settings.changed["interested-media-players"].connect ( () => {
180 this.sync_preferred_players ();
181@@ -257,6 +258,36 @@
182 root_action.set_state (builder.end());
183 }
184
185+ Action create_silent_mode_action () {
186+ bool silentNow = false;
187+ if (this.accounts_service != null) {
188+ silentNow = this.accounts_service.silentMode;
189+ }
190+
191+ var silent_action = new SimpleAction.stateful ("silent-mode", null, new Variant.boolean (silentNow));
192+
193+ /* If we're not dealing with accounts service, we'll just always be out
194+ of silent mode and that's cool. */
195+ if (this.accounts_service == null) {
196+ return silent_action;
197+ }
198+
199+ this.accounts_service.notify["silentMode"].connect(() => {
200+ silent_action.set_state(new Variant.boolean(this.accounts_service.silentMode));
201+ this.update_root_icon ();
202+ });
203+
204+ silent_action.activate.connect ((action, param) => {
205+ action.change_state (new Variant.boolean (!action.get_state().get_boolean()));
206+ });
207+
208+ silent_action.change_state.connect ((action, val) => {
209+ this.accounts_service.silentMode = val.get_boolean();
210+ });
211+
212+ return silent_action;
213+ }
214+
215 Action create_mute_action () {
216 var mute_action = new SimpleAction.stateful ("mute", null, new Variant.boolean (this.volume_control.mute));
217
218
219=== modified file 'src/sound-menu.vala'
220--- src/sound-menu.vala 2014-10-08 01:58:24 +0000
221+++ src/sound-menu.vala 2014-10-08 01:58:24 +0000
222@@ -24,7 +24,8 @@
223 SHOW_MUTE = 1,
224 HIDE_INACTIVE_PLAYERS = 2,
225 HIDE_PLAYERS = 4,
226- GREETER_PLAYERS = 8
227+ GREETER_PLAYERS = 8,
228+ SHOW_SILENT_MODE = 16
229 }
230
231 public SoundMenu (string? settings_action, DisplayFlags flags) {
232@@ -34,8 +35,15 @@
233 */
234
235 this.volume_section = new Menu ();
236+
237 if ((flags & DisplayFlags.SHOW_MUTE) != 0)
238 volume_section.append (_("Mute"), "indicator.mute");
239+ if ((flags & DisplayFlags.SHOW_SILENT_MODE) != 0) {
240+ var item = new MenuItem(_("Silent Mode"), "indicator.silent-mode");
241+ item.set_attribute("x-canonical-type", "s", "com.canonical.indicator.switch");
242+ volume_section.append_item(item);
243+ }
244+
245 volume_section.append_item (this.create_slider_menu_item (_("Volume"), "indicator.volume(0)", 0.0, 1.0, 0.01,
246 "audio-volume-low-zero-panel",
247 "audio-volume-high-panel"));

Subscribers

People subscribed via source and target branches