Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You'll need the following dependencies:

libgranite-7-dev >= 7.7.0
libglib2.0-dev
libgtk-4-dev
libgtk-4-dev >= 4.22
libnotify-dev
libpulse-dev
libwingpanel-9-dev
Expand Down
294 changes: 294 additions & 0 deletions data/24/volume.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/io/elementary/wingpanel/sound">
<file alias="indicator.css" compressed="true">indicator.css</file>
<file compressed="true">24/volume.svg</file>
</gresource>
<gresource prefix="/org/elementary/wingpanel/icons">
<file alias="16x16/devices/audio-subwoofer-symbolic.svg" compressed="true" preprocess="xml-stripblanks">16/audio-subwoofer-symbolic.svg</file>
Expand Down
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ shared_module(
'src/Widgets/PlayerList.vala',
'src/Widgets/DeviceManagerWidget.vala',
'src/Widgets/DeviceItem.vala',
'src/Widgets/Symbol.vala',
'src/Services/PulseAudioManager.vala',
'src/Services/MprisClient.vala',
'src/Services/Volume-control.vala',
Expand All @@ -65,7 +66,7 @@ shared_module(
dependency('gio-2.0'),
dependency('gobject-2.0'),
dependency('granite-7', version: '>=7.7.0'),
dependency('gtk4'),
dependency('gtk4', version: '>=4.22'),
dependency('gtk4-wayland'),
dependency('libpulse'),
dependency('libpulse-mainloop-glib'),
Expand Down
25 changes: 18 additions & 7 deletions src/Indicator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public class Sound.Indicator : Wingpanel.Indicator {
display_widget.volume_press_event.connect (volume_control.toggle_mute);
display_widget.mic_press_event.connect (volume_control.toggle_mic_mute);

display_widget.icon_name = get_volume_icon (volume_control.volume.volume);
display_widget.volume_state = get_volume_state (volume_control.volume.volume);

display_widget.volume_scroll_event.connect_after (on_volume_icon_scroll_event);
display_widget.mic_scroll_event.connect_after (on_mic_icon_scroll_event);
Expand Down Expand Up @@ -268,7 +268,7 @@ public class Sound.Indicator : Wingpanel.Indicator {
double volume = volume_control.volume.volume / max_volume;
if (volume != volume_adjustment.get_value ()) {
volume_adjustment.set_value (volume);
display_widget.icon_name = get_volume_icon (volume);
display_widget.volume_state = get_volume_state (volume);
}
}

Expand All @@ -283,13 +283,12 @@ public class Sound.Indicator : Wingpanel.Indicator {
private void on_mute_change () {
volume_scale.active = !volume_control.mute;

string volume_icon = get_volume_icon (volume_control.volume.volume);
display_widget.icon_name = volume_icon;
display_widget.volume_state = get_volume_state (volume_control.volume.volume);

if (volume_control.mute) {
volume_scale.icon = "audio-volume-muted-symbolic";
} else {
volume_scale.icon = volume_icon;
volume_scale.icon = get_volume_icon (volume_control.volume.volume);
}
}

Expand Down Expand Up @@ -320,12 +319,12 @@ public class Sound.Indicator : Wingpanel.Indicator {
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);
display_widget.volume_state = get_volume_state (volume_control.volume.volume);
return false;
});
}

display_widget.icon_name = get_volume_icon (volume_control.volume.volume);
display_widget.volume_state = get_volume_state (volume_control.volume.volume);
}

private void on_volume_icon_scroll_event (Value event_value) {
Expand Down Expand Up @@ -356,6 +355,18 @@ public class Sound.Indicator : Wingpanel.Indicator {
}
}

private unowned string get_volume_state (double volume) {
if (volume <= 0 || this.volume_control.mute) {
return this.mute_blocks_sound ? "disabled-blocking" : SoundIndicator.SymbolState.DISABLED;
} else if (volume <= 0.3) {
return "low";
} else if (volume <= 0.7) {
return SoundIndicator.SymbolState.NORMAL;
} else {
return "high";
}
}

private void on_volume_switch_change () {
if (volume_scale.active) {
volume_control.set_mute (false);
Expand Down
Loading
Loading