From 68207ed12f5df6eb81b7d3565aed7acc15f82f54 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Sep 2014 10:14:54 -0500 Subject: Build in a way to stop the track information for getting into the player action --- src/service.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index 4e02769..ae1840a 100644 --- a/src/service.vala +++ b/src/service.vala @@ -379,11 +379,11 @@ public class IndicatorSound.Service: Object { this.loop.quit (); } - Variant action_state_for_player (MediaPlayer player) { + Variant action_state_for_player (MediaPlayer player, bool show_track = true) { var builder = new VariantBuilder (new VariantType ("a{sv}")); builder.add ("{sv}", "running", new Variant ("b", player.is_running)); builder.add ("{sv}", "state", new Variant ("s", player.state)); - if (player.current_track != null) { + if (player.current_track != null && show_track) { builder.add ("{sv}", "title", new Variant ("s", player.current_track.title)); builder.add ("{sv}", "artist", new Variant ("s", player.current_track.artist)); builder.add ("{sv}", "album", new Variant ("s", player.current_track.album)); -- cgit v1.2.3 From 2776b58639225be50bdc3c7961f60b1fd571df29 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Sep 2014 10:19:55 -0500 Subject: Adding in an additional action that is the greeter state --- src/service.vala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index ae1840a..d715ff5 100644 --- a/src/service.vala +++ b/src/service.vala @@ -74,6 +74,10 @@ public class IndicatorSound.Service: Object { } } + bool greeter_show_track () { + return false; + } + void build_accountsservice () { clear_acts_player(); this.accounts_service = null; @@ -402,6 +406,12 @@ public class IndicatorSound.Service: Object { action.set_enabled (player.can_raise); } + SimpleAction? greeter_action = this.actions.lookup_action (player.id + ".greeter") as SimpleAction; + if (greeter_action != null) { + greeter_action.set_state (this.action_state_for_player (player, greeter_show_track())); + greeter_action.set_enabled (player.can_raise); + } + /* If we're playing then put that data in accounts service */ if (player.is_running && accounts_service != null) { accounts_service.player = player; @@ -446,6 +456,11 @@ public class IndicatorSound.Service: Object { action.activate.connect ( () => { player.activate (); }); this.actions.add_action (action); + SimpleAction greeter_action = new SimpleAction.stateful (player.id + ".greeter", null, this.action_state_for_player (player, greeter_show_track())); + greeter_action.set_enabled (player.can_raise); + greeter_action.activate.connect ( () => { player.activate (); }); + this.actions.add_action (greeter_action); + var play_action = new SimpleAction.stateful ("play." + player.id, null, player.state); play_action.activate.connect ( () => player.play_pause () ); this.actions.add_action (play_action); -- cgit v1.2.3 From e87459657220f1cdc46e38c0b39f498ce6beac40 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Sep 2014 10:31:16 -0500 Subject: Adding support for selecting the base action to be a different player action --- src/sound-menu.vala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sound-menu.vala b/src/sound-menu.vala index e37c4e9..f5e2627 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -23,7 +23,8 @@ public class SoundMenu: Object NONE = 0, SHOW_MUTE = 1, HIDE_INACTIVE_PLAYERS = 2, - HIDE_PLAYERS = 4 + HIDE_PLAYERS = 4, + GREETER_PLAYERS = 8 } public SoundMenu (string? settings_action, DisplayFlags flags) { @@ -59,6 +60,8 @@ public class SoundMenu: Object this.hide_players = (flags & DisplayFlags.HIDE_PLAYERS) != 0; this.hide_inactive = (flags & DisplayFlags.HIDE_INACTIVE_PLAYERS) != 0; this.notify_handlers = new HashTable (direct_hash, direct_equal); + + this.greeter_players = (flags & DisplayFlags.GREETER_PLAYERS) != 0; } public void export (DBusConnection connection, string object_path) { @@ -133,6 +136,7 @@ public class SoundMenu: Object bool hide_inactive; bool hide_players = false; HashTable notify_handlers; + bool greeter_players = false; /* returns the position in this.menu of the section that's associated with @player */ int find_player_section (MediaPlayer player) { @@ -166,7 +170,11 @@ public class SoundMenu: Object if (icon == null) icon = new ThemedIcon.with_default_fallbacks ("application-default-icon"); - var player_item = new MenuItem (player.name, "indicator." + player.id); + var base_action = "indicator." + player.id; + if (this.greeter_players) + base_action += ".greeter"; + + var player_item = new MenuItem (player.name, base_action); player_item.set_attribute ("x-canonical-type", "s", "com.canonical.unity.media-player"); if (icon != null) player_item.set_attribute_value ("icon", icon.serialize ()); -- cgit v1.2.3 From 4b0ce78d9b66ae752d55d3ba7405d6bd3e87408c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Sep 2014 10:32:07 -0500 Subject: Selecting the greeter players for the greeter menus --- src/service.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index d715ff5..af65b33 100644 --- a/src/service.vala +++ b/src/service.vala @@ -38,8 +38,8 @@ public class IndicatorSound.Service: Object { this.actions.add_action (this.create_mic_volume_action ()); this.menus = new HashTable (str_hash, str_equal); - this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS)); - this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS)); + this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS)); + this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS)); this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE)); this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS)); -- cgit v1.2.3 From 92f7e3b4b41ff61742e42485ff1b7fd27c4ed449 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Sep 2014 11:05:43 -0500 Subject: Drop the GSettings key and change the way we're interacting with the accounts service setting --- src/service.vala | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index af65b33..059724a 100644 --- a/src/service.vala +++ b/src/service.vala @@ -47,9 +47,11 @@ public class IndicatorSound.Service: Object { this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE); }); - /* Setup handling for the greeter-export setting */ - this.settings.changed["greeter-export"].connect( () => this.build_accountsservice() ); - build_accountsservice(); + /* If we're on the greeter, don't export */ + if (GLib.Environment.get_user_name() != "lightdm") { + this.accounts_service = new AccountsServiceUser(); + /* TODO: Watch for setting */ + } this.sync_preferred_players (); this.settings.changed["interested-media-players"].connect ( () => { @@ -75,28 +77,7 @@ public class IndicatorSound.Service: Object { } bool greeter_show_track () { - return false; - } - - void build_accountsservice () { - clear_acts_player(); - this.accounts_service = null; - - /* If we're not exporting, don't build anything */ - if (!this.settings.get_boolean("greeter-export")) { - debug("Accounts service export disabled due to user setting"); - return; - } - - /* If we're on the greeter, don't export */ - if (GLib.Environment.get_user_name() == "lightdm") { - debug("Accounts service export disabled due to being used on the greeter"); - return; - } - - this.accounts_service = new AccountsServiceUser(); - - this.eventually_update_player_actions(); + return export_to_accounts_service; } void clear_acts_player () { @@ -171,6 +152,7 @@ public class IndicatorSound.Service: Object { Notify.Notification notification; bool syncing_preferred_players = false; AccountsServiceUser? accounts_service = null; + bool export_to_accounts_service = false; /* Maximum volume as a scaling factor between the volume action's state and the value in * this.volume_control. See create_volume_action(). @@ -413,7 +395,7 @@ public class IndicatorSound.Service: Object { } /* If we're playing then put that data in accounts service */ - if (player.is_running && accounts_service != null) { + if (player.is_running && export_to_accounts_service && accounts_service != null) { accounts_service.player = player; clear_accounts_player = false; } -- cgit v1.2.3 From 494c5dd4e52319a923402dcf338a31cccb4c9204 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Sep 2014 11:18:17 -0500 Subject: Adding in a privacy settings proxy --- src/CMakeLists.txt | 4 ++++ src/accounts-service-privacy-settings.vala | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/accounts-service-privacy-settings.vala (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 98bc7c4..00d53ae 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -103,11 +103,15 @@ vala_add(indicator-sound-service media-player mpris2-interfaces accounts-service-sound-settings + accounts-service-privacy-settings greeter-broadcast ) vala_add(indicator-sound-service accounts-service-sound-settings.vala ) +vala_add(indicator-sound-service + accounts-service-privacy-settings.vala +) vala_add(indicator-sound-service greeter-broadcast.vala ) diff --git a/src/accounts-service-privacy-settings.vala b/src/accounts-service-privacy-settings.vala new file mode 100644 index 0000000..ef5c309 --- /dev/null +++ b/src/accounts-service-privacy-settings.vala @@ -0,0 +1,26 @@ +/* + * Copyright 2014 © Canonical Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authors: + * Ted Gould + */ + +[DBus (name = "com.ubuntu.touch.AccountsService.SecurityPrivacy")] +public interface AccountsServicePrivacySettings : Object { + // properties + public abstract bool stats_welcome_screen {owned get; set;} + public abstract bool messages_welcome_screen {owned get; set;} +} + -- cgit v1.2.3 From 7a446003a31252ed8211f593a413d7c206e2b0fd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 26 Sep 2014 14:22:31 -0500 Subject: Setup a proxy to get the property out of accounts service --- src/accounts-service-user.vala | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/accounts-service-user.vala b/src/accounts-service-user.vala index 04c38cc..14d129d 100644 --- a/src/accounts-service-user.vala +++ b/src/accounts-service-user.vala @@ -21,10 +21,13 @@ public class AccountsServiceUser : Object { Act.UserManager accounts_manager = Act.UserManager.get_default(); Act.User? user = null; AccountsServiceSoundSettings? proxy = null; + AccountsServicePrivacySettings? privacyproxy = null; uint timer = 0; MediaPlayer? _player = null; GreeterBroadcast? greeter = null; + public bool showDataOnGreeter = false; + public MediaPlayer? player { set { this._player = value; @@ -124,7 +127,15 @@ public class AccountsServiceUser : Object { user.get_object_path(), DBusProxyFlags.GET_INVALIDATED_PROPERTIES, null, - new_proxy); + new_sound_proxy); + + Bus.get_proxy.begin ( + BusType.SYSTEM, + "org.freedesktop.Accounts", + user.get_object_path(), + DBusProxyFlags.GET_INVALIDATED_PROPERTIES, + null, + new_privacy_proxy); } } @@ -138,7 +149,7 @@ public class AccountsServiceUser : Object { } } - void new_proxy (GLib.Object? obj, AsyncResult res) { + void new_sound_proxy (GLib.Object? obj, AsyncResult res) { try { this.proxy = Bus.get_proxy.end (res); this.player = _player; @@ -148,6 +159,24 @@ public class AccountsServiceUser : Object { } } + void new_privacy_proxy (GLib.Object? obj, AsyncResult res) { + try { + this.privacyproxy = Bus.get_proxy.end (res); + + (this.privacyproxy as DBusProxy).g_properties_changed.connect((proxy, changed, invalid) => { + var welcomeval = changed.lookup("MessagesWelcomeScreen", "b", null); + if (welcomeval) { + this.showDataOnGreeter = welcomeval; + } + }); + + this.showDataOnGreeter = this.privacyproxy.messages_welcome_screen; + } catch (Error e) { + this.privacyproxy = null; + warning("Unable to get proxy to user privacy settings: %s", e.message); + } + } + void greeter_proxy_new (GLib.Object? obj, AsyncResult res) { try { this.greeter = Bus.get_proxy.end (res); -- cgit v1.2.3 From bbc0cff3994b65371d2224c6322f04c2fac01556 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 26 Sep 2014 14:25:25 -0500 Subject: Connect to the value in accounts service and update the player if appropriate --- src/service.vala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index 059724a..8287b7f 100644 --- a/src/service.vala +++ b/src/service.vala @@ -50,7 +50,13 @@ public class IndicatorSound.Service: Object { /* If we're on the greeter, don't export */ if (GLib.Environment.get_user_name() != "lightdm") { this.accounts_service = new AccountsServiceUser(); - /* TODO: Watch for setting */ + + this.accounts_service.notify["showDataOnGreeter"].connect(() => { + this.export_to_accounts_service = this.accounts_service.showDataOnGreeter; + eventually_update_player_actions(); + }); + + this.export_to_accounts_service = this.accounts_service.showDataOnGreeter; } this.sync_preferred_players (); -- cgit v1.2.3 From 6f911c1d1ea7caa5031271eb9f2a3d295c492edc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Oct 2014 11:02:29 -0500 Subject: Make it so that metadata can be NULL and handle it. --- src/media-player-mpris.vala | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/media-player-mpris.vala b/src/media-player-mpris.vala index 25ddac4..80b9ac1 100644 --- a/src/media-player-mpris.vala +++ b/src/media-player-mpris.vala @@ -274,8 +274,7 @@ public class MediaPlayerMpris: MediaPlayer { } var metadata = changed_properties.lookup_value ("Metadata", new VariantType ("a{sv}")); - if (metadata != null) - this.update_current_track (metadata); + this.update_current_track (metadata); } void playlists_proxy_properties_changed (DBusProxy proxy, Variant changed_properties, string[] invalidated_properties) { @@ -283,7 +282,7 @@ public class MediaPlayerMpris: MediaPlayer { this.fetch_playlists (); } - void update_current_track (Variant metadata) { + void update_current_track (Variant? metadata) { if (metadata != null) { this.current_track = new Track ( sanitize_metadata_value (metadata.lookup_value ("xesam:artist", null)), -- cgit v1.2.3 From 06367d1c8d9f2238f23b29210bb2434917d2c7c2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Oct 2014 11:20:51 -0500 Subject: Can get set at startup before we have a PA connection, shouldn't be a critical in that case, should just fail --- src/volume-control.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/volume-control.vala b/src/volume-control.vala index 2efa186..afcca15 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -327,7 +327,8 @@ public class VolumeControl : Object bool set_volume_internal (double volume) { - return_val_if_fail (context.get_state () == Context.State.READY, false); + if (context.get_state () != Context.State.READY) + return false; if (_volume != volume) { _volume = volume; -- cgit v1.2.3 From 722ce01234bb3d5e5f99f206da20d402b3e337c6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Oct 2014 11:42:52 -0500 Subject: Turn show data on greeter into a property, which it was always intended to be. --- src/accounts-service-user.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/accounts-service-user.vala b/src/accounts-service-user.vala index 14d129d..8187d73 100644 --- a/src/accounts-service-user.vala +++ b/src/accounts-service-user.vala @@ -26,7 +26,7 @@ public class AccountsServiceUser : Object { MediaPlayer? _player = null; GreeterBroadcast? greeter = null; - public bool showDataOnGreeter = false; + public bool showDataOnGreeter { get; set; } public MediaPlayer? player { set { @@ -166,6 +166,7 @@ public class AccountsServiceUser : Object { (this.privacyproxy as DBusProxy).g_properties_changed.connect((proxy, changed, invalid) => { var welcomeval = changed.lookup("MessagesWelcomeScreen", "b", null); if (welcomeval) { + debug("Messages on welcome screen changed"); this.showDataOnGreeter = welcomeval; } }); -- cgit v1.2.3 From 84fea70d4383d30bbfe640ef9a8123475f93ded8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Oct 2014 13:57:36 -0500 Subject: Check for null because otherwise we clear the metadata on each update of any value --- src/media-player-mpris.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/media-player-mpris.vala b/src/media-player-mpris.vala index 80b9ac1..bf25e21 100644 --- a/src/media-player-mpris.vala +++ b/src/media-player-mpris.vala @@ -274,7 +274,8 @@ public class MediaPlayerMpris: MediaPlayer { } var metadata = changed_properties.lookup_value ("Metadata", new VariantType ("a{sv}")); - this.update_current_track (metadata); + if (metadata != null) + this.update_current_track (metadata); } void playlists_proxy_properties_changed (DBusProxy proxy, Variant changed_properties, string[] invalidated_properties) { -- cgit v1.2.3 From a1043d02d1f75d86d059b1fe716ca6ac9d548ddd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Oct 2014 16:53:31 -0500 Subject: Have welcome value actually be a variant pointer. --- src/accounts-service-user.vala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/accounts-service-user.vala b/src/accounts-service-user.vala index 8187d73..2e59db3 100644 --- a/src/accounts-service-user.vala +++ b/src/accounts-service-user.vala @@ -164,10 +164,10 @@ public class AccountsServiceUser : Object { this.privacyproxy = Bus.get_proxy.end (res); (this.privacyproxy as DBusProxy).g_properties_changed.connect((proxy, changed, invalid) => { - var welcomeval = changed.lookup("MessagesWelcomeScreen", "b", null); - if (welcomeval) { + var welcomeval = changed.lookup_value("MessagesWelcomeScreen", new VariantType("b")); + if (welcomeval != null) { debug("Messages on welcome screen changed"); - this.showDataOnGreeter = welcomeval; + this.showDataOnGreeter = welcomeval.get_boolean(); } }); -- cgit v1.2.3 From 9df51f4ad93a7d69d526610a6817d428003de4d3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Oct 2014 09:13:38 -0500 Subject: Adding in a system sound settings proxy --- src/CMakeLists.txt | 4 ++++ src/accounts-service-system-sound-settings.vala | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/accounts-service-system-sound-settings.vala (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 00d53ae..4a4443f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -104,6 +104,7 @@ vala_add(indicator-sound-service mpris2-interfaces accounts-service-sound-settings accounts-service-privacy-settings + accounts-service-system-sound-settings greeter-broadcast ) vala_add(indicator-sound-service @@ -112,6 +113,9 @@ vala_add(indicator-sound-service vala_add(indicator-sound-service accounts-service-privacy-settings.vala ) +vala_add(indicator-sound-service + accounts-service-system-sound-settings.vala +) vala_add(indicator-sound-service greeter-broadcast.vala ) diff --git a/src/accounts-service-system-sound-settings.vala b/src/accounts-service-system-sound-settings.vala new file mode 100644 index 0000000..283a606 --- /dev/null +++ b/src/accounts-service-system-sound-settings.vala @@ -0,0 +1,25 @@ +/* + * Copyright 2014 © Canonical Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authors: + * Ted Gould + */ + +[DBus (name = "com.ubuntu.touch.AccountsService.Sound")] +public interface AccountsServiceSystemSoundSettings : Object { + // properties + public abstract bool silent_mode {owned get; set;} +} + -- cgit v1.2.3 From 0c348ae6792e65c95983d784207b81740d09abb9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Oct 2014 09:40:53 -0500 Subject: Turn the system sound proxy into a silent mode property --- src/accounts-service-user.vala | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src') diff --git a/src/accounts-service-user.vala b/src/accounts-service-user.vala index 2e59db3..08d5221 100644 --- a/src/accounts-service-user.vala +++ b/src/accounts-service-user.vala @@ -22,11 +22,13 @@ public class AccountsServiceUser : Object { Act.User? user = null; AccountsServiceSoundSettings? proxy = null; AccountsServicePrivacySettings? privacyproxy = null; + AccountsServiceSystemSoundSettings? syssoundproxy = null; uint timer = 0; MediaPlayer? _player = null; GreeterBroadcast? greeter = null; public bool showDataOnGreeter { get; set; } + public bool silentMode { get; set; } public MediaPlayer? player { set { @@ -136,6 +138,14 @@ public class AccountsServiceUser : Object { DBusProxyFlags.GET_INVALIDATED_PROPERTIES, null, new_privacy_proxy); + + Bus.get_proxy.begin ( + BusType.SYSTEM, + "org.freedesktop.Accounts", + user.get_object_path(), + DBusProxyFlags.GET_INVALIDATED_PROPERTIES, + null, + new_system_sound_proxy); } } @@ -178,6 +188,25 @@ public class AccountsServiceUser : Object { } } + void new_system_sound_proxy (GLib.Object? obj, AsyncResult res) { + try { + this.syssoundproxy = Bus.get_proxy.end (res); + + (this.syssoundproxy as DBusProxy).g_properties_changed.connect((proxy, changed, invalid) => { + var silentvar = changed.lookup_value("SilentMode", new VariantType("b")); + if (silentvar != null) { + debug("Silent Mode changed"); + this.silentMode = silentvar.get_boolean(); + } + }); + + this.silentMode = this.syssoundproxy.silent_mode; + } catch (Error e) { + this.syssoundproxy = null; + warning("Unable to get proxy to system sound settings: %s", e.message); + } + } + void greeter_proxy_new (GLib.Object? obj, AsyncResult res) { try { this.greeter = Bus.get_proxy.end (res); -- cgit v1.2.3 From ef4ba155bcb9361e4a856ea35566bbaab8ecf6f1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Oct 2014 09:43:37 -0500 Subject: Use silent mode to determine the icon on the panel --- src/service.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index 8287b7f..280c12d 100644 --- a/src/service.vala +++ b/src/service.vala @@ -229,7 +229,7 @@ public class IndicatorSound.Service: Object { void update_root_icon () { double volume = this.volume_control.get_volume (); string icon; - if (this.volume_control.mute) + if (this.volume_control.mute || (this.accounts_service != null && this.accounts_service.silentMode)) icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; else if (volume <= 0.0) icon = "audio-volume-low-zero-panel"; -- cgit v1.2.3 From 1feb02e715bcb4f201e85c012acfe6196c657930 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Oct 2014 10:00:02 -0500 Subject: Backup the properties with a local value and set the proxy --- src/accounts-service-user.vala | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/accounts-service-user.vala b/src/accounts-service-user.vala index 08d5221..ec52730 100644 --- a/src/accounts-service-user.vala +++ b/src/accounts-service-user.vala @@ -28,7 +28,17 @@ public class AccountsServiceUser : Object { GreeterBroadcast? greeter = null; public bool showDataOnGreeter { get; set; } - public bool silentMode { get; set; } + + bool _silentMode = false; + public bool silentMode { + get { + return _silentMode; + } + set { + if (syssoundproxy != null) + syssoundproxy.silent_mode = value; + } + } public MediaPlayer? player { set { @@ -196,7 +206,8 @@ public class AccountsServiceUser : Object { var silentvar = changed.lookup_value("SilentMode", new VariantType("b")); if (silentvar != null) { debug("Silent Mode changed"); - this.silentMode = silentvar.get_boolean(); + this._silentMode = silentvar.get_boolean(); + this.notify_property("silentMode"); } }); -- cgit v1.2.3 From dab455206972c36d086ae97da776ddd00795899a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Oct 2014 11:12:39 -0500 Subject: Create a silent mode action --- src/service.vala | 54 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index 280c12d..d869053 100644 --- a/src/service.vala +++ b/src/service.vala @@ -25,6 +25,18 @@ public class IndicatorSound.Service: Object { this.settings.bind ("visible", this, "visible", SettingsBindFlags.GET); this.notify["visible"].connect ( () => this.update_root_icon () ); + /* If we're on the greeter, don't export */ + if (GLib.Environment.get_user_name() != "lightdm") { + this.accounts_service = new AccountsServiceUser(); + + this.accounts_service.notify["showDataOnGreeter"].connect(() => { + this.export_to_accounts_service = this.accounts_service.showDataOnGreeter; + eventually_update_player_actions(); + }); + + this.export_to_accounts_service = this.accounts_service.showDataOnGreeter; + } + this.volume_control = new VolumeControl (); this.players = playerlist; @@ -33,6 +45,7 @@ public class IndicatorSound.Service: Object { this.actions = new SimpleActionGroup (); this.actions.add_action_entries (action_entries, this); + this.actions.add_action (this.create_silent_mode_action ()); this.actions.add_action (this.create_mute_action ()); this.actions.add_action (this.create_volume_action ()); this.actions.add_action (this.create_mic_volume_action ()); @@ -47,18 +60,6 @@ public class IndicatorSound.Service: Object { this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE); }); - /* If we're on the greeter, don't export */ - if (GLib.Environment.get_user_name() != "lightdm") { - this.accounts_service = new AccountsServiceUser(); - - this.accounts_service.notify["showDataOnGreeter"].connect(() => { - this.export_to_accounts_service = this.accounts_service.showDataOnGreeter; - eventually_update_player_actions(); - }); - - this.export_to_accounts_service = this.accounts_service.showDataOnGreeter; - } - this.sync_preferred_players (); this.settings.changed["interested-media-players"].connect ( () => { this.sync_preferred_players (); @@ -257,6 +258,35 @@ public class IndicatorSound.Service: Object { root_action.set_state (builder.end()); } + Action create_silent_mode_action () { + bool silentNow = false; + if (this.accounts_service != null) { + silentNow = this.accounts_service.silentMode; + } + + var silent_action = new SimpleAction.stateful ("silent-mode", null, new Variant.boolean (silentNow)); + + /* If we're not dealing with accounts service, we'll just always be out + of silent mode and that's cool. */ + if (this.accounts_service == null) { + return silent_action; + } + + this.accounts_service.notify["silentMode"].connect(() => { + silent_action.set_state(new Variant.boolean(this.accounts_service.silentMode)); + }); + + silent_action.activate.connect ((action, param) => { + action.change_state (new Variant.boolean (!action.get_state().get_boolean())); + }); + + silent_action.change_state.connect ((action, val) => { + this.accounts_service.silentMode = val.get_boolean(); + }); + + return silent_action; + } + Action create_mute_action () { var mute_action = new SimpleAction.stateful ("mute", null, new Variant.boolean (this.volume_control.mute)); -- cgit v1.2.3 From 4f500f48301cbc7140b87034d3e1326a0a3b917a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Oct 2014 11:22:20 -0500 Subject: Pull complex logic into its own function --- src/service.vala | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index d869053..a78519d 100644 --- a/src/service.vala +++ b/src/service.vala @@ -227,10 +227,26 @@ public class IndicatorSound.Service: Object { return icon.serialize (); } + /* This kinda got complex with both mute and silent mode. So we're + gonna put it into a function */ + bool user_sound_output () { + if (this.volume_control.mute) { + return false; + } + + if (this.accounts_service != null) { + if (this.accounts_service.silentMode) { + return false; + } + } + + return true; + } + void update_root_icon () { double volume = this.volume_control.get_volume (); string icon; - if (this.volume_control.mute || (this.accounts_service != null && this.accounts_service.silentMode)) + if (!user_sound_output()) icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; else if (volume <= 0.0) icon = "audio-volume-low-zero-panel"; @@ -242,7 +258,7 @@ public class IndicatorSound.Service: Object { icon = "audio-volume-high-panel"; string accessible_name; - if (this.volume_control.mute) { + if (!user_sound_output()) { accessible_name = _("Volume (muted)"); } else { int volume_int = (int)(volume * 100); @@ -274,6 +290,7 @@ public class IndicatorSound.Service: Object { this.accounts_service.notify["silentMode"].connect(() => { silent_action.set_state(new Variant.boolean(this.accounts_service.silentMode)); + this.update_root_icon (); }); silent_action.activate.connect ((action, param) => { -- cgit v1.2.3 From 4b6d204d6cc5d193d6400b14acb520296dfb7d96 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Oct 2014 11:24:54 -0500 Subject: Add a silent mode menu item --- src/service.vala | 4 ++-- src/sound-menu.vala | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index a78519d..8711b6a 100644 --- a/src/service.vala +++ b/src/service.vala @@ -52,9 +52,9 @@ public class IndicatorSound.Service: Object { this.menus = new HashTable (str_hash, str_equal); this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS)); - this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS)); + this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS)); this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE)); - this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS)); + this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS)); this.menus.@foreach ( (profile, menu) => { this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE); diff --git a/src/sound-menu.vala b/src/sound-menu.vala index f5e2627..1247e0a 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -24,7 +24,8 @@ public class SoundMenu: Object SHOW_MUTE = 1, HIDE_INACTIVE_PLAYERS = 2, HIDE_PLAYERS = 4, - GREETER_PLAYERS = 8 + GREETER_PLAYERS = 8, + SHOW_SILENT_MODE = 16 } public SoundMenu (string? settings_action, DisplayFlags flags) { @@ -34,8 +35,12 @@ public class SoundMenu: Object */ this.volume_section = new Menu (); + if ((flags & DisplayFlags.SHOW_MUTE) != 0) volume_section.append (_("Mute"), "indicator.mute"); + if ((flags & DisplayFlags.SHOW_SILENT_MODE) != 0) + volume_section.append (_("Silent Mode"), "indicator.silent-mode"); + volume_section.append_item (this.create_slider_menu_item ("indicator.volume(0)", 0.0, 1.0, 0.01, "audio-volume-low-zero-panel", "audio-volume-high-panel")); -- cgit v1.2.3 From 095353472e881855bff8f5d16ea9c13fe978a623 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Oct 2014 16:18:12 -0500 Subject: Make it a switch --- src/sound-menu.vala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sound-menu.vala b/src/sound-menu.vala index 1247e0a..6cbbf67 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -38,8 +38,11 @@ public class SoundMenu: Object if ((flags & DisplayFlags.SHOW_MUTE) != 0) volume_section.append (_("Mute"), "indicator.mute"); - if ((flags & DisplayFlags.SHOW_SILENT_MODE) != 0) - volume_section.append (_("Silent Mode"), "indicator.silent-mode"); + if ((flags & DisplayFlags.SHOW_SILENT_MODE) != 0) { + var item = new MenuItem(_("Silent Mode"), "indicator.silent-mode"); + item.set_attribute("x-canonical-type", "s", "com.canonical.indicator.switch"); + volume_section.append_item(item); + } volume_section.append_item (this.create_slider_menu_item ("indicator.volume(0)", 0.0, 1.0, 0.01, "audio-volume-low-zero-panel", -- cgit v1.2.3 From af38d9e73aeca412a11b6b8e59039042375ed335 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 2 Oct 2014 16:18:21 -0500 Subject: Build the volume control first --- src/service.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index 8711b6a..18f283b 100644 --- a/src/service.vala +++ b/src/service.vala @@ -25,6 +25,8 @@ public class IndicatorSound.Service: Object { this.settings.bind ("visible", this, "visible", SettingsBindFlags.GET); this.notify["visible"].connect ( () => this.update_root_icon () ); + this.volume_control = new VolumeControl (); + /* If we're on the greeter, don't export */ if (GLib.Environment.get_user_name() != "lightdm") { this.accounts_service = new AccountsServiceUser(); @@ -37,8 +39,6 @@ public class IndicatorSound.Service: Object { this.export_to_accounts_service = this.accounts_service.showDataOnGreeter; } - this.volume_control = new VolumeControl (); - this.players = playerlist; this.players.player_added.connect (this.player_added); this.players.player_removed.connect (this.player_removed); -- cgit v1.2.3 From 9e1ec4502a70a6e91a9de96a96e26388b99e811b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Oct 2014 09:27:38 -0500 Subject: Don't represent silent mode in the indicator --- src/service.vala | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index 18f283b..2a65492 100644 --- a/src/service.vala +++ b/src/service.vala @@ -227,26 +227,10 @@ public class IndicatorSound.Service: Object { return icon.serialize (); } - /* This kinda got complex with both mute and silent mode. So we're - gonna put it into a function */ - bool user_sound_output () { - if (this.volume_control.mute) { - return false; - } - - if (this.accounts_service != null) { - if (this.accounts_service.silentMode) { - return false; - } - } - - return true; - } - void update_root_icon () { double volume = this.volume_control.get_volume (); string icon; - if (!user_sound_output()) + if (this.volume_control.mute) icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; else if (volume <= 0.0) icon = "audio-volume-low-zero-panel"; @@ -258,7 +242,7 @@ public class IndicatorSound.Service: Object { icon = "audio-volume-high-panel"; string accessible_name; - if (!user_sound_output()) { + if (this.volume_control.mute) { accessible_name = _("Volume (muted)"); } else { int volume_int = (int)(volume * 100); -- cgit v1.2.3