Skip to content

Commit

Permalink
Merge pull request linuxmint#5660 from claudiux/Radio3.0_1.19.0
Browse files Browse the repository at this point in the history
[Radio3.0@claudiux] v1.19.0 - New options for: OSD and sound volume magnetization
  • Loading branch information
claudiux authored Apr 2, 2024
2 parents 8fa2d0a + f2de4ac commit fcf1278
Show file tree
Hide file tree
Showing 7 changed files with 291 additions and 254 deletions.
5 changes: 5 additions & 0 deletions Radio3.0@claudiux/files/Radio3.0@claudiux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### v1.19.0~20240402
* Adds two options:
- Whether or not to show the sound volume OSD when changing radio station.
- Whether or not to magnetize all multiples of 25% of the sound volume.

### v1.18.0~20240328
* Radio3.0@claudiux can now receive commands from the sound150@claudiux applet.

Expand Down
9 changes: 5 additions & 4 deletions Radio3.0@claudiux/files/Radio3.0@claudiux/applet.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//'use strict';
// infos on use strict: https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Strict_mode
const { TextIconApplet,
AllowedLayout,
AppletPopupMenu
} = imports.ui.applet; //Applet
const { TextIconApplet, AllowedLayout, AppletPopupMenu } = imports.ui.applet; //Applet

const AppletManager = imports.ui.appletManager; //AppletManager

Expand Down Expand Up @@ -1174,6 +1171,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
this.settings.bind("show-volume-level-near-icon", "show_volume_level_near_icon", this.volume_near_icon.bind(this));
this.settings.bind("dont-check-dependencies", "dont_check_dependencies");
this.settings.bind("recentRadios", "recentRadios");
this.settings.bind("volume-magnetic-on", "magnetic25On");
this.settings.bind("volume-step", "volume_step");
this.settings.bind("volume-at-startup", "volume_at_startup");
this.settings.bind("volume-percentage", "percentage");
Expand All @@ -1184,7 +1182,9 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
this.settings.bind("show-reload", "show_reload");
this.settings.bind("show-bitrate", "show_bitrate", (...args) => this.set_show_bitrate(...args));
this.settings.bind("show-codec", "show_codec");
this.settings.bind("volume-show-osd-starting-radio","showOSDonStartup");
this.settings.bind("volume-show-osd", "volume_show_osd");
this.showOSD = this.volume_show_osd && this.showOSDonStartup;

this.settings.bind("import-list", "import_list");
this.settings.bind("import-dir", "import_dir");
Expand Down Expand Up @@ -3171,6 +3171,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
}

start_mpv_radio(id) {
this.showOSD = this.volume_show_osd && this.showOSDonStartup;
source.destroyAllNotifications();
let _id = ""+id;
//log("start_mpv_radio: " + _id);
Expand Down
40 changes: 23 additions & 17 deletions Radio3.0@claudiux/files/Radio3.0@claudiux/lib/volumeslider.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const Clutter = imports.gi.Clutter;
const St = imports.gi.St;
const PopupMenu = imports.ui.popupMenu;
Expand All @@ -7,8 +6,7 @@ const Slider = imports.ui.slider;
const Tooltips = imports.ui.tooltips;
const Gio = imports.gi.Gio;
const Main = imports.ui.main;
const {
get_home_dir,
const { get_home_dir,
file_test,
FileTest
} = imports.gi.GLib; //GLib
Expand Down Expand Up @@ -36,7 +34,11 @@ function DEBUG() {
* logError("Any error message") to log the error message regardless of the DEBUG() return.
*/
function log(message, alwaysLog=false) {
if (DEBUG() || alwaysLog) global.log("[" + UUID + "]: " + message);
if (DEBUG() || alwaysLog) Main._logInfo("[" + UUID + "]: " + message);
}

function logDebug(message) {
log(message, true)
}

function logError(error) {
Expand All @@ -49,6 +51,7 @@ function logError(error) {
*/
class VolumeSlider extends PopupMenu.PopupSliderMenuItem {
constructor(applet, stream, tooltip, app_icon = null) {

super(applet.percentage);
this.applet = applet;

Expand Down Expand Up @@ -129,7 +132,7 @@ class VolumeSlider extends PopupMenu.PopupSliderMenuItem {
if(this.stream.is_muted !== muted)
this.stream.change_is_muted(muted);

if (this.applet.volume_show_osd) {
if (this.applet.showOSD) {
let iconName = this._volumeToIcon(1.0*this.applet.percentage/100, "audio-volume-webradioreceiver-")+"-symbolic";
let icon = Gio.Icon.new_for_string(iconName);
try {
Expand All @@ -138,6 +141,7 @@ class VolumeSlider extends PopupMenu.PopupSliderMenuItem {
// Do nothing
}
}
this.applet.showOSD = this.applet.volume_show_osd;

//~ if(!this._dragging)
//~ this.applet._notifyVolumeChange(this.stream);
Expand Down Expand Up @@ -191,22 +195,24 @@ class VolumeSlider extends PopupMenu.PopupSliderMenuItem {
// visible_value: percentage of volume_norm (shown to the user)
// these only differ for the output, and only when the user changes the maximum volume
let volume = (!this.stream || this.stream.is_muted) ? 0 : this.stream.volume;
let value, visible_value;
var value, visible_value;
let delta = this.applet.volume_step/100*this.applet._volumeMax/this.applet._volumeNorm;

if (this.isOutputSink) {
value = volume / this.applet._volumeMax;
visible_value = volume / this.applet._volumeNorm;
if (visible_value != 1 && visible_value > 1 - delta/2 && visible_value < 1 + delta/2) {
visible_value = 1; // 100% is magnetic
value = this.applet._volumeNorm / this.applet._volumeMax;
this.applet._output.volume = this.applet._volumeNorm;
this.applet._output.push_volume();
visible_value = volume / this.applet._volumeNorm;
if (this.applet.magnetic25On) {
for (let i = 0.25; i <= 1; i+=0.25) {
if (visible_value != i && visible_value > (i - delta / 2) && visible_value < (i + delta / 2)) {
visible_value = i;
//~ value = i*this.applet._volumeNorm;
break;
}
}
} else {
visible_value = volume / this.applet._volumeNorm;
value = visible_value
}
if (visible_value > 1) { // This should never happen.
logDebug("Volume > 100%: "+visible_value*100+"%");
visible_value = 1;
}
value = visible_value;

this.percentage = Math.round(visible_value * 100);
if (this.percentage !== this.applet.percentage)
Expand Down
2 changes: 1 addition & 1 deletion Radio3.0@claudiux/files/Radio3.0@claudiux/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"description": "The Ultimate Internet Radio Receiver & Recorder for Cinnamon",
"max-instances": 1,
"version": "1.18.0",
"version": "1.19.0",
"uuid": "Radio3.0@claudiux",
"name": "Radio3.0",
"author": "claudiux",
Expand Down
Loading

0 comments on commit fcf1278

Please sign in to comment.