From f079f5a27a70a377b8787610f1bef62d8af7fe7c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 10 Oct 2014 12:43:29 -0500 Subject: Make notifications check for high volumes and change based on that --- src/volume-control.vala | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/volume-control.vala b/src/volume-control.vala index f9db556..0e5abbb 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -580,22 +580,42 @@ public class VolumeControl : Object { /* Using this to detect whether we're on the phone or not */ if (_pulse_use_stream_restore) { - if (volume == 0.0) - _notification.update (_("Volume"), "", "audio-volume-muted"); + /* Watch for extreme */ + bool extreme_volume = false; + if (volume > 0.75) /* TODO: Also if headphones */ + extreme_volume = true; + + /* Determine Label */ + string volume_label = _("Volume"); + if (extreme_volume) + volume_label = _("High volume"); + + /* Choose an icon */ + string icon = "audio-volume-muted"; if (volume > 0.0 && volume <= 0.33) - _notification.update (_("Volume"), "", "audio-volume-low"); + icon = "audio-volume-low"; if (volume > 0.33 && volume <= 0.66) - _notification.update (_("Volume"), "", "audio-volume-medium"); + icon = "audio-volume-medium"; if (volume > 0.66 && volume <= 1.0) - _notification.update (_("Volume"), "", "audio-volume-high"); + icon = "audio-volume-high"; + + /* Choose a sound */ + string? sound = null; + if (_active_sink_input == -1 || _valid_roles[_active_sink_input] != "multimedia") + sound = "/usr/share/sounds/ubuntu/stereo/message.ogg"; + + /* Check tint */ + string tint = "false"; + if (extreme_volume) + tint = "true"; + + /* Put it all into the notification */ + _notification.update (volume_label, "", icon); _notification.set_hint ("value", (int32)(volume * 100.0)); - if (_active_sink_input == -1 || _valid_roles[_active_sink_input] != "multimedia") { - /* No audio ping if we're playing multimedia */ - _notification.set_hint ("sound-file", "/usr/share/sounds/ubuntu/stereo/message.ogg"); - } else { - _notification.set_hint ("sound-file", null); - } + _notification.set_hint ("sound-file", sound); + _notification.set_hint ("x-canonical-value-bar-tint", tint); + /* Show it */ try { _notification.show (); } catch (GLib.Error e) { -- cgit v1.2.3 From 53edccc48b6b1999457aaa4241bfc8eee413f16c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 10 Oct 2014 16:10:15 -0500 Subject: Turn high volume into a property --- src/volume-control.vala | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/volume-control.vala b/src/volume-control.vala index 0e5abbb..e09f212 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -79,6 +79,9 @@ public class VolumeControl : Object /** true when a microphone is active **/ public bool active_mic { get; private set; default = false; } + /** true when high volume warnings should be shown */ + public bool high_volume { get; set; } + public VolumeControl () { if (loop == null) @@ -581,13 +584,14 @@ public class VolumeControl : Object /* Using this to detect whether we're on the phone or not */ if (_pulse_use_stream_restore) { /* Watch for extreme */ - bool extreme_volume = false; if (volume > 0.75) /* TODO: Also if headphones */ - extreme_volume = true; + high_volume = true; + else + high_volume = false; /* Determine Label */ string volume_label = _("Volume"); - if (extreme_volume) + if (high_volume) volume_label = _("High volume"); /* Choose an icon */ @@ -606,7 +610,7 @@ public class VolumeControl : Object /* Check tint */ string tint = "false"; - if (extreme_volume) + if (high_volume) tint = "true"; /* Put it all into the notification */ -- cgit v1.2.3 From 88956a3657cc0f0f8f76b2935a7ae46033d5c200 Mon Sep 17 00:00:00 2001 From: Ricardo Salveti Date: Mon, 13 Oct 2014 20:48:06 -0500 Subject: Headphone detection --- src/volume-control.vala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/volume-control.vala b/src/volume-control.vala index e09f212..c9ba42c 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -70,6 +70,8 @@ public class VolumeControl : Object private double _account_service_volume = 0.0; private Notify.Notification _notification; + private bool _active_port_headphone = false; + public signal void volume_changed (double v); public signal void mic_volume_changed (double v); @@ -177,6 +179,19 @@ public class VolumeControl : Object this.notify_property ("is-playing"); } + /* Check if the current active port is headset/headphone */ + /* There is not easy way to check if the port is a headset/headphone besides + * checking for the port name. On touch (with the pulseaudio droid element) + * the headset/headphone port is called 'output-headset' and 'output-headphone'. + * On the desktop this is usually called 'analog-output-headphones' */ + if (i.active_port.name == "output-wired_headset" || + i.active_port.name == "output-wired_headphone" || + i.active_port.name == "analog-output-headphones") { + _active_port_headphone = true; + } else { + _active_port_headphone = false; + } + if (_pulse_use_stream_restore == false && _volume != volume_to_double (i.volume.max ())) { -- cgit v1.2.3 From 9c8f845b511cf8a8a02cb90df5546ff852978ed6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 13 Oct 2014 20:49:19 -0500 Subject: Use the headphone detection --- src/volume-control.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/volume-control.vala b/src/volume-control.vala index c9ba42c..b32146f 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -599,7 +599,7 @@ public class VolumeControl : Object /* Using this to detect whether we're on the phone or not */ if (_pulse_use_stream_restore) { /* Watch for extreme */ - if (volume > 0.75) /* TODO: Also if headphones */ + if (volume > 0.75 && _active_port_headphone) high_volume = true; else high_volume = false; -- cgit v1.2.3 From 7ec3795022cbfff0e1c0c094309a4b67d1dd3b04 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 13 Oct 2014 20:51:07 -0500 Subject: Create actions based on the high volume status --- src/service.vala | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index 2a65492..92523aa 100644 --- a/src/service.vala +++ b/src/service.vala @@ -49,6 +49,7 @@ public class IndicatorSound.Service: Object { 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 (str_hash, str_equal); this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS)); @@ -388,6 +389,36 @@ 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))); + + /* So this is a bit confusing, putting it here because everywhere else + sucks too. It might create an action and put it into the action group. + Which is sneaky. Better to have the code not duplicated, but no good + place to put code like that. */ + setup_high_volume_menu_action(); + + return high_volume_action; + } + + void setup_high_volume_menu_action () { + this.volume_control.notify["high_volume"].connect(update_high_volume_menu_action); + update_high_volume_menu_action(); + } + + void update_high_volume_menu_action () { + if (this.volume_control.high_volume) { + var menu_action = new SimpleAction("high-volume-menu", null); + menu_action.set_enabled(false); + this.actions.add_action(menu_action); + } else { + this.actions.remove_action("high-volume-menu"); + } + } + void bus_acquired (DBusConnection connection, string name) { try { connection.export_action_group ("/com/canonical/indicator/sound", this.actions); -- cgit v1.2.3 From 9e39fba127c95aee79b26d2b88cb80dc279a5011 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 13 Oct 2014 21:32:30 -0500 Subject: Ensure we reevaluate the high volume warning when we switch from headphones or not --- src/volume-control.vala | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/volume-control.vala b/src/volume-control.vala index b32146f..ea8e3ac 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -163,6 +163,8 @@ public class VolumeControl : Object private void sink_info_cb_for_props (Context c, SinkInfo? i, int eol) { + bool old_active_port_headphone = this._active_port_headphone; + if (i == null) return; @@ -197,6 +199,8 @@ public class VolumeControl : Object { _volume = volume_to_double (i.volume.max ()); volume_changed (_volume); + } else if (this._active_port_headphone != old_active_port_headphone) { + volume_changed (_volume); } } -- cgit v1.2.3 From 973b4eb057f466ad88e62d25f733ed1700e1ac38 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Oct 2014 07:59:43 -0500 Subject: Use title for the a11y info and the body for the message on sync notifications --- src/volume-control.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/volume-control.vala b/src/volume-control.vala index ea8e3ac..b65cbc8 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -633,7 +633,7 @@ public class VolumeControl : Object tint = "true"; /* Put it all into the notification */ - _notification.update (volume_label, "", icon); + _notification.update (_("Volume"), volume_label, icon); _notification.set_hint ("value", (int32)(volume * 100.0)); _notification.set_hint ("sound-file", sound); _notification.set_hint ("x-canonical-value-bar-tint", tint); -- cgit v1.2.3 From 29576aceb257c868e5871972a1440b8602f2880b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Oct 2014 08:06:55 -0500 Subject: Adding a high volume warning menu item --- src/sound-menu.vala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/sound-menu.vala b/src/sound-menu.vala index f245a1f..0094c22 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -25,7 +25,9 @@ public class SoundMenu: Object HIDE_INACTIVE_PLAYERS = 2, HIDE_PLAYERS = 4, GREETER_PLAYERS = 8, - SHOW_SILENT_MODE = 16 + SHOW_SILENT_MODE = 16, + HIGH_VOLUME_WARNING = 32 /* Everyone should get this eventually, but we don't + want it in the desktop initially because of freezes */ } public SoundMenu (string? settings_action, DisplayFlags flags) { @@ -48,6 +50,9 @@ public class SoundMenu: Object "audio-volume-low-zero-panel", "audio-volume-high-panel")); + if ((flags & DisplayFlags.HIGH_VOLUME_WARNING) != 0) + volume_section.append (_("High volume can damage your hearing."), "indicator.high-volume-menu"); + this.menu = new Menu (); this.menu.append_section (null, volume_section); -- cgit v1.2.3 From a2de8d1b337113ced7854683aad0183a841917f1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Oct 2014 08:12:58 -0500 Subject: Add high volume warnings to the phone menu --- 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 92523aa..3edcba0 100644 --- a/src/service.vala +++ b/src/service.vala @@ -53,9 +53,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.SHOW_SILENT_MODE | 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 | SoundMenu.DisplayFlags.HIGH_VOLUME_WARNING)); this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE)); - this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS)); + this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.HIGH_VOLUME_WARNING)); this.menus.@foreach ( (profile, menu) => { this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE); -- cgit v1.2.3 From 52e2c2d3dce6ded517f9666d5d0412d56054d9d9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Oct 2014 09:45:40 -0500 Subject: Ensure that we're always getting a vlue in the list --- src/volume-control.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/volume-control.vala b/src/volume-control.vala index b65cbc8..cf2dacf 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -624,7 +624,7 @@ public class VolumeControl : Object /* Choose a sound */ string? sound = null; - if (_active_sink_input == -1 || _valid_roles[_active_sink_input] != "multimedia") + if (!((_active_sink_input in _sink_input_list) && (_valid_roles[_active_sink_input] == "multimedia"))) sound = "/usr/share/sounds/ubuntu/stereo/message.ogg"; /* Check tint */ -- cgit v1.2.3 From 23b3fd431a312f2b02504b998c697241c30caa0b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Oct 2014 10:00:32 -0500 Subject: Drop the high volume menu action as that wasn't working --- src/service.vala | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index 3edcba0..93e6a51 100644 --- a/src/service.vala +++ b/src/service.vala @@ -395,30 +395,9 @@ public class IndicatorSound.Service: Object { this.volume_control.notify["high_volume"].connect( () => high_volume_action.set_state(new Variant.boolean (this.volume_control.high_volume))); - /* So this is a bit confusing, putting it here because everywhere else - sucks too. It might create an action and put it into the action group. - Which is sneaky. Better to have the code not duplicated, but no good - place to put code like that. */ - setup_high_volume_menu_action(); - return high_volume_action; } - void setup_high_volume_menu_action () { - this.volume_control.notify["high_volume"].connect(update_high_volume_menu_action); - update_high_volume_menu_action(); - } - - void update_high_volume_menu_action () { - if (this.volume_control.high_volume) { - var menu_action = new SimpleAction("high-volume-menu", null); - menu_action.set_enabled(false); - this.actions.add_action(menu_action); - } else { - this.actions.remove_action("high-volume-menu"); - } - } - void bus_acquired (DBusConnection connection, string name) { try { connection.export_action_group ("/com/canonical/indicator/sound", this.actions); -- cgit v1.2.3 From 16828d0102efae82bf760097988474e434b884fd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Oct 2014 10:07:30 -0500 Subject: Changing tact to change the menu when we want to show the warning --- src/service.vala | 4 ++-- src/sound-menu.vala | 27 +++++++++++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index 93e6a51..51060d4 100644 --- a/src/service.vala +++ b/src/service.vala @@ -53,9 +53,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.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS | SoundMenu.DisplayFlags.HIGH_VOLUME_WARNING)); + 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.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.HIGH_VOLUME_WARNING)); + 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 0094c22..e1c4e98 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -25,9 +25,7 @@ public class SoundMenu: Object HIDE_INACTIVE_PLAYERS = 2, HIDE_PLAYERS = 4, GREETER_PLAYERS = 8, - SHOW_SILENT_MODE = 16, - HIGH_VOLUME_WARNING = 32 /* Everyone should get this eventually, but we don't - want it in the desktop initially because of freezes */ + SHOW_SILENT_MODE = 16 } public SoundMenu (string? settings_action, DisplayFlags flags) { @@ -50,9 +48,6 @@ public class SoundMenu: Object "audio-volume-low-zero-panel", "audio-volume-high-panel")); - if ((flags & DisplayFlags.HIGH_VOLUME_WARNING) != 0) - volume_section.append (_("High volume can damage your hearing."), "indicator.high-volume-menu"); - this.menu = new Menu (); this.menu.append_section (null, volume_section); @@ -98,12 +93,31 @@ public class SoundMenu: Object this.mic_volume_shown = true; } else if (!value && this.mic_volume_shown) { + /* TODO: Make smarter */ this.volume_section.remove (this.volume_section.get_n_items () -1); this.mic_volume_shown = false; } } } + public bool show_high_volume_warning { + get { + return this.high_volume_warning_shown; + } + set { + if (value && !this.high_volume_warning_shown) { + var item = new MenuItem(_("High volume can damage your hearing."), null); + volume_section.append_item (item); + this.high_volume_warning_shown = true; + } + else if (!value && this.high_volume_warning_shown) { + /* TODO: Make smarter */ + this.volume_section.remove (this.volume_section.get_n_items () -1); + this.high_volume_warning_shown = false; + } + } + } + public void add_player (MediaPlayer player) { if (this.notify_handlers.contains (player)) return; @@ -146,6 +160,7 @@ public class SoundMenu: Object Menu volume_section; bool mic_volume_shown; bool settings_shown = false; + bool high_volume_warning_shown = false; bool hide_inactive; bool hide_players = false; HashTable notify_handlers; -- cgit v1.2.3 From 8e7cbaadfed452063b2d659bc679746cad5cbb14 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Oct 2014 10:16:15 -0500 Subject: Linking volume control and the menu visibility --- src/service.vala | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index 51060d4..8f58110 100644 --- a/src/service.vala +++ b/src/service.vala @@ -61,6 +61,10 @@ public class IndicatorSound.Service: Object { this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE); }); + 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 ( () => { this.sync_preferred_players (); -- cgit v1.2.3 From a3de59a992980727e05c58e052be53a8adc5bf08 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Oct 2014 16:02:23 -0500 Subject: Making the removal of items smarter --- src/sound-menu.vala | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/sound-menu.vala b/src/sound-menu.vala index e1c4e98..a9efd74 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -93,8 +93,10 @@ public class SoundMenu: Object this.mic_volume_shown = true; } else if (!value && this.mic_volume_shown) { - /* TODO: Make smarter */ - this.volume_section.remove (this.volume_section.get_n_items () -1); + int location = -1; + while ((location = find_action(this.volume_section, "indicator.mic-volume")) != -1) { + this.volume_section.remove (location); + } this.mic_volume_shown = false; } } @@ -106,18 +108,35 @@ public class SoundMenu: Object } set { if (value && !this.high_volume_warning_shown) { - var item = new MenuItem(_("High volume can damage your hearing."), null); + /* NOTE: Action doesn't really exist, just used to find below when removing */ + var item = new MenuItem(_("High volume can damage your hearing."), "indicator.high-volume-warning-item"); volume_section.append_item (item); this.high_volume_warning_shown = true; } else if (!value && this.high_volume_warning_shown) { - /* TODO: Make smarter */ + int location = -1; + while ((location = find_action(this.volume_section, "indicator.high-volume-warning-item")) != -1) { + this.volume_section.remove (location); + } this.volume_section.remove (this.volume_section.get_n_items () -1); this.high_volume_warning_shown = false; } } } + int find_action (Menu menu, string in_action) { + int n = menu.get_n_items (); + for (int i = 0; i < n; i++) { + string action; + menu.get_item_attribute (0, "action", "s", out action); + if (in_action == action) + return i; + } + + return -1; + } + + public void add_player (MediaPlayer player) { if (this.notify_handlers.contains (player)) return; -- cgit v1.2.3 From d7fbfc4d0babbcd54a3951f5da721153cc194d9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mirco=20M=C3=BCller?= Date: Tue, 14 Oct 2014 18:27:46 -0500 Subject: Make High-volume text work correctly --- src/volume-control.vala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/volume-control.vala b/src/volume-control.vala index 8245c50..5a7e66d 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -612,7 +612,7 @@ public class VolumeControl : Object high_volume = false; /* Determine Label */ - string volume_label = _("Volume"); + string volume_label = ""; if (high_volume) volume_label = _("High volume"); @@ -636,10 +636,13 @@ public class VolumeControl : Object tint = "true"; /* Put it all into the notification */ + _notification.clear_hints (); _notification.update (_("Volume"), volume_label, icon); _notification.set_hint ("value", (int32)(volume * 100.0)); _notification.set_hint ("sound-file", sound); _notification.set_hint ("x-canonical-value-bar-tint", tint); + _notification.set_hint ("x-canonical-private-synchronous", "true"); + _notification.set_hint ("x-canonical-non-shaped-icon", "true"); /* Show it */ try { -- cgit v1.2.3 From 69b9c090d86e46a0af7e74e68ded1d0f5b4c52cd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Oct 2014 22:12:13 -0500 Subject: Check more precisely the valid roles --- 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 5a7e66d..d666708 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -627,7 +627,8 @@ public class VolumeControl : Object /* Choose a sound */ string? sound = null; - if (!((_active_sink_input in _sink_input_list) && (_valid_roles[_active_sink_input] == "multimedia"))) + if (!((_active_sink_input >= 0) && (_active_sink_input < _valid_roles.length) + && (_valid_roles[_active_sink_input] == "multimedia"))) sound = "/usr/share/sounds/ubuntu/stereo/message.ogg"; /* Check tint */ -- cgit v1.2.3 From 0414b149396497e4c837a126d1945905ceb2623c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Oct 2014 23:38:00 -0500 Subject: Get propery property name --- 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 8f58110..b4c7c44 100644 --- a/src/service.vala +++ b/src/service.vala @@ -396,7 +396,7 @@ public class IndicatorSound.Service: Object { 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( () => + this.volume_control.notify["high-volume"].connect( () => high_volume_action.set_state(new Variant.boolean (this.volume_control.high_volume))); return high_volume_action; -- cgit v1.2.3 From 33998ab08618bb6d513f91b2d49685ede072432b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 15 Oct 2014 08:35:54 -0500 Subject: Found other notification --- src/service.vala | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index b4c7c44..d9a2dd3 100644 --- a/src/service.vala +++ b/src/service.vala @@ -179,6 +179,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) -- cgit v1.2.3 From 46c7d4c1cb1a6552ba205beaf233d66dcd4fc8a7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 15 Oct 2014 08:38:43 -0500 Subject: Make volume icons match the panel icons --- src/volume-control.vala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/volume-control.vala b/src/volume-control.vala index d666708..f6f54d2 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -618,11 +618,13 @@ public class VolumeControl : Object /* Choose an icon */ string icon = "audio-volume-muted"; - if (volume > 0.0 && volume <= 0.33) + if (volume <= 0.0) + icon = "audio-volume-muted"; + else if (volume <= 0.3) icon = "audio-volume-low"; - if (volume > 0.33 && volume <= 0.66) + else if (volume <= 0.7) icon = "audio-volume-medium"; - if (volume > 0.66 && volume <= 1.0) + else icon = "audio-volume-high"; /* Choose a sound */ -- cgit v1.2.3 From 0b6434da43e5a5dd280df9014a182fc51cb05423 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 15 Oct 2014 09:43:24 -0500 Subject: Commenting out the sound for now --- src/volume-control.vala | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/volume-control.vala b/src/volume-control.vala index f6f54d2..6f48c5d 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -642,7 +642,10 @@ public class VolumeControl : Object _notification.clear_hints (); _notification.update (_("Volume"), volume_label, icon); _notification.set_hint ("value", (int32)(volume * 100.0)); + /* TODO: Removing sound until we can get all the roles cleaned up for + when to play it. We expect this to come back, but in another landing. _notification.set_hint ("sound-file", sound); + */ _notification.set_hint ("x-canonical-value-bar-tint", tint); _notification.set_hint ("x-canonical-private-synchronous", "true"); _notification.set_hint ("x-canonical-non-shaped-icon", "true"); -- cgit v1.2.3 From 5dd9bda0ea449024dbc97e26f92631401048bc57 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 15 Oct 2014 13:24:48 -0500 Subject: Removing the remove code that was supposed to be removed earlier --- src/sound-menu.vala | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/sound-menu.vala b/src/sound-menu.vala index a9efd74..05570b9 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -118,7 +118,6 @@ public class SoundMenu: Object while ((location = find_action(this.volume_section, "indicator.high-volume-warning-item")) != -1) { this.volume_section.remove (location); } - this.volume_section.remove (this.volume_section.get_n_items () -1); this.high_volume_warning_shown = false; } } -- cgit v1.2.3 From 1e193a4b99e62b52fb759d00a8745f1c477d965f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 15 Oct 2014 13:52:31 -0500 Subject: Make sure to check the item in the loop --- src/sound-menu.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sound-menu.vala b/src/sound-menu.vala index 05570b9..3881faf 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -127,7 +127,7 @@ public class SoundMenu: Object int n = menu.get_n_items (); for (int i = 0; i < n; i++) { string action; - menu.get_item_attribute (0, "action", "s", out action); + menu.get_item_attribute (i, "action", "s", out action); if (in_action == action) return i; } -- cgit v1.2.3