Skip to content

Commit

Permalink
sound150 v8.0.3: Improved OSD management (#6828)
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiux authored Jan 30, 2025
1 parent d10c35a commit b3bb02f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
35 changes: 24 additions & 11 deletions sound150@claudiux/files/sound150@claudiux/6.4/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ class ControlButton {
class VolumeSlider extends PopupMenu.PopupSliderMenuItem {
constructor(applet, stream, tooltip, app_icon) {
const startLevel = (tooltip == _("Microphone")) ? 1*applet.mic_level.slice(0, -1) : 1*applet.volume.slice(0, -1);
applet.showOSD = applet.showOSDonStartup;
super(startLevel);
this.oldValue = startLevel;
this.applet = applet;
Expand Down Expand Up @@ -1838,11 +1837,12 @@ class Sound150Applet extends Applet.TextIconApplet {

this.title_text = "";

this.startingUp = true;

this.settings = new Settings.AppletSettings(this, UUID, instanceId);
this.settings.bind("muteSoundOnClosing", "muteSoundOnClosing");
this.settings.bind("startupVolume", "startupVolume");
this.settings.bind("showOSDonStartup", "showOSDonStartup");
this.showOSD = this.showOSDonStartup;
this.settings.bind("showPercent", "showPercent", () => {
if (this.showPercent)
PERCENT_CHAR = _("%");
Expand Down Expand Up @@ -1921,7 +1921,6 @@ class Sound150Applet extends Applet.TextIconApplet {
this.old_volume = this.volume;
this.settings.setValue("showMediaKeysOSD", global.settings.get_boolean(SHOW_MEDIA_KEYS_OSD_KEY));
this.settings.bind("showMediaKeysOSD", "showMediaKeysOSD", () => { this.on_showMediaKeysOSD_changed() });
this.showOSD = this.showOSDonStartup && this.showMediaKeysOSD;

this.settings.bind("mic-level", "mic_level");
this.settings.bind("showVolumeLevelNearIcon", "showVolumeLevelNearIcon", () => { this.volume_near_icon() });
Expand Down Expand Up @@ -2321,6 +2320,7 @@ class Sound150Applet extends Applet.TextIconApplet {
}

on_applet_added_to_panel() {
this.startingUp = true;
if (this._playerctl)
kill_playerctld();
//~ logDebug("on_applet_added_to_panel()");
Expand Down Expand Up @@ -2353,8 +2353,6 @@ class Sound150Applet extends Applet.TextIconApplet {

this._iconLooping = true;

this.showOSD = this.showOSDonStartup && this.showMediaKeysOSD;

//~ if (this._output && this._output.is_muted) {
//~ this.old_volume = this.volume;
//~ this._toggle_out_mute();
Expand All @@ -2376,13 +2374,20 @@ class Sound150Applet extends Applet.TextIconApplet {
},
2100
);

let _to = setTimeout( () => {
this.startingUp = false;
clearTimeout(_to);
},
(this.actor.get_stage() != null) ? 2100 : 20000
);
}

on_applet_reloaded() {
//~ logDebug("on_applet_reloaded()");
this._iconLooping = false;
this._artLooping = false;
this.showOSD = this.showOSDonStartup && this.showMediaKeysOSD;
this.startingUp = true;
if (this.muteSoundOnClosing && this._output && !this._output.is_muted) {
this.old_volume = this.volume;
this._toggle_out_mute();
Expand All @@ -2400,6 +2405,7 @@ class Sound150Applet extends Applet.TextIconApplet {
}

on_applet_removed_from_panel() {
this.startingUp = true;
//~ logDebug("on_applet_removed_from_panel() BEGIN");

// REMOVED: BUG!
Expand Down Expand Up @@ -2564,22 +2570,19 @@ class Sound150Applet extends Applet.TextIconApplet {

_toggle_in_mute() {
if (!this._input) {
this.showOSD = this.showMediaKeysOSD;
this._volumeChange(null);
return;
}

let newStatus = !this._input.is_muted;
this._input.change_is_muted(newStatus);
if (this.mute_in_switch) this.mute_in_switch.setToggleState(newStatus);
this.showOSD = this.showMediaKeysOSD;
this._volumeChange(null);
}

_onScrollEvent(actor, event) {
//~ logDebug("event: "+event.originalEvent.ctrlKey);
let _event = event;
this.showOSD = this.showMediaKeysOSD;
let modifiers = Cinnamon.get_event_state(event);
let shiftPressed = (modifiers & Clutter.ModifierType.SHIFT_MASK);
let ctrlPressed = (modifiers & Clutter.ModifierType.CONTROL_MASK);
Expand Down Expand Up @@ -2726,8 +2729,6 @@ class Sound150Applet extends Applet.TextIconApplet {
this._applet_tooltip.hide();
}

this.showOSD = this.showMediaKeysOSD;

this.volume_near_icon()
}

Expand Down Expand Up @@ -3585,6 +3586,18 @@ class Sound150Applet extends Applet.TextIconApplet {
get _playerctl() {
return GLib.find_program_in_path("playerctl");
}

get showOSD() {
if (!this.showMediaKeysOSD) {
return false;
} else {
if (this.startingUp) {
return this.showOSDonStartup;
} else {
return true;
}
}
}
}

function main(metadata, orientation, panel_height, instanceId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@
},
"showOSDonStartup": {
"type": "switch",
"dependency": "showMediaKeysOSD",
"description": "Show volume level in OSD on startup",
"default": false
},
Expand All @@ -436,7 +437,7 @@
},
"showPercent": {
"type": "switch",
"dependency": "showVolumeValue",
"dependency": "showMediaKeysOSD",
"description": "Show '%' in OSD",
"default": false
},
Expand Down
4 changes: 4 additions & 0 deletions sound150@claudiux/files/sound150@claudiux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### v8.0.3~20250130
* Improved OSD management.
* Fixes #6820.

### v8.0.2~20250126
* Improved stability with Cinnamon 6.4: More tests on the existence of objects before acting on them.

Expand Down
2 changes: 1 addition & 1 deletion sound150@claudiux/files/sound150@claudiux/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"max-instances": "1",
"description": "Enhanced sound applet",
"hide-configuration": false,
"version": "8.0.2",
"version": "8.0.3",
"cinnamon-version": [
"2.8",
"3.0",
Expand Down

0 comments on commit b3bb02f

Please sign in to comment.