aboutsummaryrefslogtreecommitdiff
path: root/src/service.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/service.vala')
-rw-r--r--src/service.vala80
1 files changed, 65 insertions, 15 deletions
diff --git a/src/service.vala b/src/service.vala
index 8287b7f..fd0c08d 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -27,37 +27,43 @@ public class IndicatorSound.Service: Object {
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();
+
+ 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.players = playerlist;
this.players.player_added.connect (this.player_added);
this.players.player_removed.connect (this.player_removed);
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 ());
+ this.actions.add_action (this.create_high_volume_actions ());
this.menus = new HashTable<string, SoundMenu> (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);
});
- /* 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.menus.@foreach ( (profile, menu) => {
+ this.volume_control.bind_property ("high-volume", menu, "show-high-volume-warning", BindingFlags.SYNC_CREATE);
+ });
this.sync_preferred_players ();
this.settings.changed["interested-media-players"].connect ( () => {
@@ -68,7 +74,7 @@ public class IndicatorSound.Service: Object {
List<string> caps = Notify.get_server_caps ();
if (caps.find_custom ("x-canonical-private-synchronous", strcmp) != null) {
this.notification = new Notify.Notification ("indicator-sound", "", "");
- this.notification.set_hint_string ("x-canonical-private-synchronous", "indicator-sound");
+ this.notification.set_hint ("x-canonical-private-synchronous", "indicator-sound");
}
}
@@ -125,6 +131,9 @@ public class IndicatorSound.Service: Object {
}
set {
+ if (this.allow_amplified_volume == value)
+ return;
+
if (value) {
/* from pulse/volume.h: #define PA_VOLUME_UI_MAX (pa_sw_volume_from_dB(+11.0)) */
this.max_volume = (double)PulseAudio.Volume.sw_from_dB(11.0) / PulseAudio.Volume.NORM;
@@ -173,6 +182,8 @@ public class IndicatorSound.Service: Object {
double v = this.volume_control.get_volume () + volume_step_percentage * delta;
this.volume_control.set_volume (v.clamp (0.0, this.max_volume));
+ /* TODO: Don't want to mess up the desktop today, but we should remove this
+ scrolling change and merge that into volume control's notification */
if (this.notification != null) {
string icon;
if (v <= 0.0)
@@ -185,7 +196,7 @@ public class IndicatorSound.Service: Object {
icon = "notification-audio-volume-high";
this.notification.update ("indicator-sound", "", icon);
- this.notification.set_hint_int32 ("value", ((int32) (100 * v / this.max_volume)).clamp (-1, 101));
+ this.notification.set_hint ("value", ((int32) (100 * v / this.max_volume)).clamp (-1, 101));
try {
this.notification.show ();
}
@@ -257,6 +268,36 @@ 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));
+ this.update_root_icon ();
+ });
+
+ 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));
@@ -357,6 +398,15 @@ public class IndicatorSound.Service: Object {
return volume_action;
}
+ Action create_high_volume_actions () {
+ var high_volume_action = new SimpleAction.stateful("high-volume", null, new Variant.boolean (this.volume_control.high_volume));
+
+ this.volume_control.notify["high-volume"].connect( () =>
+ high_volume_action.set_state(new Variant.boolean (this.volume_control.high_volume)));
+
+ return high_volume_action;
+ }
+
void bus_acquired (DBusConnection connection, string name) {
try {
connection.export_action_group ("/com/canonical/indicator/sound", this.actions);