diff --git a/data/indicator.css b/data/indicator.css index ed3405b2..a20f6a91 100644 --- a/data/indicator.css +++ b/data/indicator.css @@ -17,6 +17,16 @@ * Boston, MA 02110-1301 USA. */ +.volume-icon { + transition: cubic-bezier(0.4, 0.0, 0.2, 1) 3s; +} + +.blocking .volume-icon { + animation: volume-blocking 0.4s ease-in-out 1; + color: @warning_color; + transition: cubic-bezier(0.4, 0.0, 0.2, 1) 200ms; +} + .mic-icon { animation: none; min-width: 24px; @@ -30,6 +40,14 @@ -gtk-icon-source: -gtk-icontheme("microphone-sensitivity-muted-symbolic"); } +@keyframes volume-blocking { + 0% { -gtk-icon-transform: rotate(20deg); } + 25% { -gtk-icon-transform: rotate(-20deg); } + 50% { -gtk-icon-transform: rotate(10deg); } + 75% { -gtk-icon-transform: rotate(-10deg); } + 100% { -gtk-icon-transform: rotate(5deg); } +} + @keyframes microphone-disabled { 0% { -gtk-icon-source: -gtk-icontheme("audio-input-microphone-symbolic"); } 10% { -gtk-icon-source: -gtk-icontheme("microphone-sensitivity-muted-10-symbolic"); opacity: 0.94; } diff --git a/src/Indicator.vala b/src/Indicator.vala index 8199ecf7..6071d98a 100644 --- a/src/Indicator.vala +++ b/src/Indicator.vala @@ -31,7 +31,6 @@ public class Sound.Indicator : Wingpanel.Indicator { private Services.VolumeControlPulse volume_control; private bool open = false; - private bool mute_blocks_sound = false; private uint sound_was_blocked_timeout_id; private double max_volume = 1.0; @@ -68,7 +67,7 @@ public class Sound.Indicator : Wingpanel.Indicator { volume_control.notify["mic-volume"].connect (on_mic_volume_change); volume_control.notify["mute"].connect (on_mute_change); volume_control.notify["micMute"].connect (on_mic_mute_change); - volume_control.notify["is-playing"].connect (on_is_playing_change); + volume_control.notify["is-playing"].connect (style_blocking); volume_control.notify["is-listening"].connect (update_mic_visibility); // Tooltip-related @@ -146,6 +145,8 @@ public class Sound.Indicator : Wingpanel.Indicator { volume_scale.scale_widget.set_value (volume); display_widget.icon_name = get_volume_icon (volume); } + + style_blocking (); } private void on_mic_volume_change () { @@ -161,12 +162,9 @@ public class Sound.Indicator : Wingpanel.Indicator { string volume_icon = get_volume_icon (volume_control.volume.volume); display_widget.icon_name = volume_icon; + volume_scale.icon = volume_icon; - if (volume_control.mute) { - volume_scale.icon = "audio-volume-muted-symbolic"; - } else { - volume_scale.icon = volume_icon; - } + style_blocking (); } private void on_mic_mute_change () { @@ -180,28 +178,12 @@ public class Sound.Indicator : Wingpanel.Indicator { } } - private void on_is_playing_change () { - if (!volume_control.mute) { - mute_blocks_sound = false; - return; - } - if (volume_control.is_playing) { - mute_blocks_sound = true; - } else if (mute_blocks_sound) { - /* Continue to show the blocking icon five seconds after a player has tried to play something */ - if (sound_was_blocked_timeout_id > 0) { - Source.remove (sound_was_blocked_timeout_id); - } - - sound_was_blocked_timeout_id = Timeout.add_seconds (5, () => { - mute_blocks_sound = false; - sound_was_blocked_timeout_id = 0; - display_widget.icon_name = get_volume_icon (volume_control.volume.volume); - return false; - }); + private void style_blocking () { + if (volume_control.is_playing && volume_control.mute) { + display_widget.get_style_context ().add_class ("blocking"); + } else { + display_widget.get_style_context ().remove_class ("blocking"); } - - display_widget.icon_name = get_volume_icon (volume_control.volume.volume); } private void on_volume_icon_scroll_event (Gdk.EventScroll e) { @@ -240,7 +222,7 @@ public class Sound.Indicator : Wingpanel.Indicator { private unowned string get_volume_icon (double volume) { if (volume <= 0 || this.volume_control.mute) { - return this.mute_blocks_sound ? "audio-volume-muted-blocking-symbolic" : "audio-volume-muted-symbolic"; + return "audio-volume-muted-symbolic"; } else if (volume <= 0.3) { return "audio-volume-low-symbolic"; } else if (volume <= 0.7) { diff --git a/src/Widgets/DisplayWidget.vala b/src/Widgets/DisplayWidget.vala index b910e11a..79f35526 100644 --- a/src/Widgets/DisplayWidget.vala +++ b/src/Widgets/DisplayWidget.vala @@ -33,6 +33,10 @@ public class DisplayWidget : Gtk.Grid { var volume_icon = new Gtk.Image (); volume_icon.pixel_size = 24; + var volume_style_context = volume_icon.get_style_context (); + volume_style_context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + volume_style_context.add_class ("volume-icon"); + var mic_icon = new Gtk.Spinner (); mic_icon.margin_end = 18;