Skip to content

Commit 1af2d6d

Browse files
authored
v2.6.1: Fixes desklet issue for Cinnamon 6.0 (#6745)
1 parent 7ffbae1 commit 1af2d6d

File tree

5 files changed

+166
-66
lines changed

5 files changed

+166
-66
lines changed

Radio3.0@claudiux/files/Radio3.0@claudiux/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### v2.6.1~20250106
2+
* Fixes desklet issue for Cinnamon 6.0.
3+
14
### v2.6.0~20250106
25
* Improved functioning (start-up).
36

Radio3.0@claudiux/files/Radio3.0@claudiux/applet.js

Lines changed: 81 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ function versionCompare(left, right) {
163163

164164
const APPNAME = "Radio3.0";
165165
const UUID = APPNAME + "@claudiux";
166+
const DESKLET_UUID = "AlbumArt3.0@claudiux";
166167

167168
const HOME_DIR = get_home_dir();
168169
const USER_NAME = get_user_name();
@@ -264,12 +265,17 @@ function isValidURL(str) {
264265
}
265266

266267
function spaceAvailable(path) {
268+
//~ logDebug("spaceAvailable("+path+")");
267269
try {
268-
let dir = file_new_for_path(path);
270+
let dir = file_new_for_path(""+path);
269271
let info = dir.query_filesystem_info('filesystem::free', null);
272+
if (info == null) return 0;
270273
let free = info.get_attribute_as_string('filesystem::free');
271274
return parseInt(free)
272-
} catch(e) {logError(e)}
275+
} catch(e) {
276+
logError("spaceAvailable("+path+"): "+e);
277+
return 0;
278+
}
273279
}
274280

275281
function get_nemo_size_prefixes() {
@@ -734,39 +740,37 @@ messageTray.add(source);
734740
//~ }
735741
//~ }
736742

737-
class R3WebpageMenuItem extends PopupBaseMenuItem {
738-
constructor(parent, score, params) {
739-
super(params);
740-
this.parent = parent;
743+
//~ class R3WebpageMenuItem extends PopupBaseMenuItem {
744+
//~ constructor(parent, score, params) {
745+
//~ super(params);
746+
//~ this.parent = parent;
741747

742-
let boxIconLabel = new BoxLayout({ style: 'spacing: 1em;' });
743-
//~ logDebug("boxIconLabel: "+boxIconLabel);
748+
//~ let boxIconLabel = new BoxLayout({ style: 'spacing: 1em;' });
744749

745-
let web_icon = new Icon({ icon_name: 'web-browser', icon_type: IconType.SYMBOLIC, style_class: 'popup-menu-icon' });
746-
boxIconLabel.add_actor(web_icon);
747-
let label = new Label({ text: _("Radio3.0 web page...") });
748-
boxIconLabel.add_actor(label);
749-
this.addActor(boxIconLabel);
750+
//~ let web_icon = new Icon({ icon_name: 'web-browser', icon_type: IconType.SYMBOLIC, style_class: 'popup-menu-icon' });
751+
//~ boxIconLabel.add_actor(web_icon);
752+
//~ let label = new Label({ text: _("Radio3.0 web page...") });
753+
//~ boxIconLabel.add_actor(label);
754+
//~ this.addActor(boxIconLabel);
750755

751-
let stars = new BoxLayout({ style: 'spacing: 0.25em;' });
752-
//~ logDebug("stars: "+stars);
756+
//~ let stars = new BoxLayout({ style: 'spacing: 0.25em;' });
753757

754-
let star_icon = new Icon({ icon_name: 'starred', icon_type: IconType.SYMBOLIC, style_class: 'popup-menu-icon' });
755-
let star_count = new Label({ text: score.toString() });
756-
stars.add_actor(star_icon);
757-
stars.add_actor(star_count);
758-
this.addActor(stars);
759-
}
758+
//~ let star_icon = new Icon({ icon_name: 'starred', icon_type: IconType.SYMBOLIC, style_class: 'popup-menu-icon' });
759+
//~ let star_count = new Label({ text: score.toString() });
760+
//~ stars.add_actor(star_icon);
761+
//~ stars.add_actor(star_count);
762+
//~ this.addActor(stars);
763+
//~ }
760764

761-
activate() {
762-
spawnCommandLineAsync("bash -c 'xdg-open https://cinnamon-spices.linuxmint.com/applets/view/360'");
763-
super.activate();
764-
}
765+
//~ activate() {
766+
//~ spawnCommandLineAsync("bash -c 'xdg-open https://cinnamon-spices.linuxmint.com/applets/view/360'");
767+
//~ super.activate();
768+
//~ }
765769

766-
//~ destroy() {
770+
//~ //destroy() {
767771
//~ //super.destroy();
768-
//~ }
769-
}
772+
//~ //}
773+
//~ }
770774

771775
class TitleSeparatorMenuItem extends PopupBaseMenuItem {
772776
constructor(title, icon_name, reactive=false) {
@@ -1392,7 +1396,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
13921396
this.settings.bind("yt-cookies-from", "cookies_from");
13931397

13941398
// Score:
1395-
this.settings.bind("score", "score");
1399+
//~ this.settings.bind("score", "score");
13961400

13971401
// Help TextViews:
13981402
this.populate_help_textviews()
@@ -1813,7 +1817,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
18131817
//log("UNMONITOR INTERFACES");
18141818

18151819
try {
1816-
if (this.netMonitorId) {
1820+
if (this.netMonitorId != null) {
18171821
this.netMonitor.disconnect(this.netMonitorId);
18181822
this.netMonitor = null;
18191823
this.netMonitorId = null;
@@ -1825,7 +1829,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
18251829

18261830
on_network_changed(monitor, network_available) {
18271831
//log("on_network_changed");
1828-
if (this.last_radio_listened_to.length === 0 || this.netMonitor == null) return;
1832+
if (this.last_radio_listened_to.length === 0 || this.netMonitor == null || monitor == null) return;
18291833

18301834
//let monitor = this.netMonitor;
18311835
//let network_available = monitor.get_network_available();
@@ -1856,7 +1860,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
18561860

18571861
if (file.query_exists(null)) {
18581862
try {
1859-
this.titleMonitor = file.monitor_file(0, null);
1863+
this.titleMonitor = file.monitor_file(FileMonitorFlags.NONE, null);
18601864
//this.titleMonitor.set_rate_limit(300); // 300 ms (default value: 800)
18611865

18621866
this.titleMonitorId = this.titleMonitor.connect('changed', Lang.bind(this, this._on_mpv_title_changed));
@@ -1926,7 +1930,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
19261930
if (this.titleMonitor == null) return;
19271931

19281932
try {
1929-
if (this.titleMonitorId) {
1933+
if (this.titleMonitorId != null) {
19301934
this.titleMonitor.disconnect(this.titleMonitorId);
19311935
this.titleMonitor.cancel();
19321936
this.titleMonitor = null;
@@ -2037,7 +2041,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
20372041

20382042
if (file.query_exists(null)) {
20392043
try {
2040-
this.recMonitor = file.monitor_directory(8, null);
2044+
this.recMonitor = file.monitor_directory(FileMonitorFlags.WATCH_MOVES, null);
20412045
this.recMonitorId = this.recMonitor.connect('changed', Lang.bind(this, () => this._on_rec_folder_changed()));
20422046
} catch(e) {
20432047
logError("Unable to monitor %s!".format(RADIO30_MUSIC_DIR), e)
@@ -2076,7 +2080,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
20762080
if (file.query_exists(null)) {
20772081
try {
20782082
//this.jobsMonitor = file.monitor_directory(0, null);
2079-
this.jobsMonitor = file.monitor_directory(0, null);
2083+
this.jobsMonitor = file.monitor_directory(FileMonitorFlags.WATCH_MOVES, null); //FileMonitorFlags.NONE
20802084
//this.jobsMonitor.set_rate_limit(300); // 300 ms (default value: 800)
20812085
this.jobsMonitorId = this.jobsMonitor.connect('changed', Lang.bind(this, this._on_jobs_dir_changed));
20822086
} catch(e) {
@@ -2090,7 +2094,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
20902094
if (this.jobsMonitor == null) return;
20912095

20922096
try {
2093-
if (this.jobsMonitorId) {
2097+
if (this.jobsMonitorId != null) {
20942098
this.jobsMonitor.disconnect(this.jobsMonitorId);
20952099
this.jobsMonitor.cancel();
20962100
this.jobsMonitor = null;
@@ -2189,7 +2193,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
21892193
}
21902194

21912195
set_color() {
2192-
if (this.interval != 0) return;
2196+
if (this.interval != 0 || (this.actor.get_stage() == null)) return;
21932197
if (this.mpvStatus === "PLAY") {
21942198
if (this.record_pid == null)
21952199
this.actor.style = "color: %s".format(this.settings.getValue("color-on"));
@@ -2201,6 +2205,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
22012205
}
22022206

22032207
change_symbolic_icon(name='webradioreceiver') {
2208+
if (this.actor.get_stage() == null) return;
22042209
this.do_rotation = (name === 'animated');
22052210
this.set_applet_icon_symbolic_name(name);
22062211
this.set_color();
@@ -3961,6 +3966,8 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
39613966
* only if the reload of the applet is requested.
39623967
**/
39633968
on_applet_reloaded() {
3969+
if (this.menu.isOpen) this.menu.close();
3970+
if (this._applet_context_menu.isOpen) this._applet_context_menu.close();
39643971
//log("on_applet_reloaded", true);
39653972
this.songTitle = "";
39663973
// Register recent Radios:
@@ -4012,14 +4019,16 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
40124019
spawnCommandLineAsync("bash -c '"+DEL_SONG_ARTS_SCRIPT+"'");
40134020
spawnCommandLineAsync("bash -c '%s/fix-desklet-translations.sh'".format(SCRIPTS_DIR));
40144021

4015-
let subProcess = spawnCommandLineAsyncIO(SCRIPTS_DIR+"/get-score.sh", Lang.bind(this, (stdout, err, exitCode) => {
4016-
try {
4017-
this.settings.setValue("score", 1*stdout);
4018-
} catch(e) {
4019-
logError("Reading score error: "+e)
4020-
}
4021-
subProcess.send_signal(9);
4022-
}));
4022+
this.change_symbolic_icon();
4023+
4024+
//~ let subProcess = spawnCommandLineAsyncIO(SCRIPTS_DIR+"/get-score.sh", Lang.bind(this, (stdout, err, exitCode) => {
4025+
//~ try {
4026+
//~ this.settings.setValue("score", 1*stdout);
4027+
//~ } catch(e) {
4028+
//~ logError("Reading score error: "+e)
4029+
//~ }
4030+
//~ subProcess.send_signal(9);
4031+
//~ }));
40234032

40244033
// Check about dependencies:
40254034
this.checkDepInterval = undefined;
@@ -4103,11 +4112,13 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
41034112
);
41044113

41054114
if (this.desklet_is_activated)
4106-
reloadExtension("AlbumArt3.0@claudiux", Type.DESKLET);
4115+
reloadExtension(DESKLET_UUID, Type.DESKLET);
41074116
}
41084117

41094118
on_applet_removed_from_panel() {
41104119
//log("on_applet_removed_from_panel", true);
4120+
if (this.menu.isOpen) this.menu.close();
4121+
if (this._applet_context_menu.isOpen) this._applet_context_menu.close();
41114122

41124123
// Stop looping:
41134124
this.appletRunning = false;
@@ -5541,28 +5552,41 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
55415552
for (let i = 0; i < enabledDesklets.length; i++){
55425553
let name = enabledDesklets[i].split(":")[0];
55435554
//~ logDebug("Desklet name: "+name);
5544-
if (name == "AlbumArt3.0@claudiux") {
5555+
if (name == DESKLET_UUID) {
55455556
deskletEDKline = ""+enabledDesklets[i];
55465557
enabledDesklets.splice(i, 1);
55475558
break;
55485559
}
55495560
}
55505561

55515562

5552-
const desklet_source_path = APPLET_DIR + "/desklet/AlbumArt3.0@claudiux";
5563+
const desklet_source_path = APPLET_DIR + "/desklet/" + DESKLET_UUID;
55535564
if (find_program_in_path("cinnamon-install-spice")) {
55545565
spawnCommandLineAsync("cinnamon-install-spice desklet "+desklet_source_path);
55555566
} else {
55565567
const desklet_target_path = HOME_DIR+"/.local/share/cinnamon/desklets/"
55575568
spawnCommandLineAsync("cp -a -f "+desklet_source_path+" "+desklet_target_path);
55585569
}
55595570

5571+
var spices_config_path = HOME_DIR+"/.config/cinnamon/spices";
5572+
var desklet_config_path = spices_config_path+"/"+DESKLET_UUID+"/"+DESKLET_UUID+".json";
5573+
if (!file_test(spices_config_path, FileTest.EXISTS)) {
5574+
spices_config_path = HOME_DIR+".cinnamon/configs";
5575+
desklet_config_path = spices_config_path+"/"+DESKLET_UUID+"/"+DESKLET_UUID+".json";
5576+
}
5577+
if (file_test(spices_config_path, FileTest.EXISTS)) {
5578+
if (!file_test(desklet_config_path, FileTest.EXISTS)) {
5579+
mkdir_with_parents(spices_config_path+"/"+DESKLET_UUID, 0o755)
5580+
spawnCommandLineAsync("cp -a -f " + APPLET_DIR + "/desklet/" + DESKLET_UUID+".json " + desklet_config_path);
5581+
}
5582+
}
5583+
55605584
var found = false;
55615585
if (deskletEDKline.length > 0) {
55625586
for (let i = 0; i < enabledDesklets.length; i++){
55635587
let name = enabledDesklets[i].split(":")[0];
55645588
//~ logDebug("Desklet name: "+name);
5565-
if (name == "AlbumArt3.0@claudiux") {
5589+
if (name == DESKLET_UUID) {
55665590
enabledDesklets[i] = deskletEDKline;
55675591
found = true;
55685592
break;
@@ -5575,7 +5599,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
55755599
for (let i = 0; i < enabledDesklets.length; i++){
55765600
let name = enabledDesklets[i].split(":")[0];
55775601
//~ logDebug("Desklet name: "+name);
5578-
if (name == "AlbumArt3.0@claudiux") {
5602+
if (name == DESKLET_UUID) {
55795603
found = true;
55805604
pos = i;
55815605
break;
@@ -5586,7 +5610,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
55865610
if (this.desklet_y < 0)
55875611
this.desklet_y = global.screen_height - 500;
55885612
let next_desklet_id = global.settings.get_int("next-desklet-id");
5589-
deskletEDKline = `AlbumArt3.0@claudiux:${next_desklet_id}:${this.desklet_x}:${this.desklet_y}`;
5613+
deskletEDKline = `${DESKLET_UUID}:${next_desklet_id}:${this.desklet_x}:${this.desklet_y}`;
55905614
if (found)
55915615
enabledDesklets[pos] = deskletEDKline;
55925616
else
@@ -5604,7 +5628,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
56045628
for (let i = 0; i < enabledDesklets.length; i++){
56055629
let [name, num, x, y] = enabledDesklets[i].split(":");
56065630
//~ logDebug("Desklet name: "+name);
5607-
if (name == "AlbumArt3.0@claudiux") {
5631+
if (name == DESKLET_UUID) {
56085632
this.desklet_x = x;
56095633
this.desklet_y = y;
56105634
enabledDesklets.splice(i, 1);
@@ -5616,12 +5640,12 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
56165640
global.settings.set_strv(ENABLED_DESKLETS_KEY, enabledDesklets);
56175641
this.show_desklet = false;
56185642
this.desklet_is_activated = false;
5619-
//~ const desklet_path = HOME_DIR+"/.local/share/cinnamon/desklets/AlbumArt3.0@claudiux"
5643+
//~ const desklet_path = HOME_DIR+"/.local/share/cinnamon/desklets/"+DESKLET_UUID;
56205644
//~ spawnCommandLineAsync("rm -rf "+desklet_path);
56215645
}
56225646

56235647
setup_desklet() {
5624-
//~ const desklet_path = HOME_DIR+"/.local/share/cinnamon/desklets/AlbumArt3.0@claudiux";
5648+
//~ const desklet_path = HOME_DIR+"/.local/share/cinnamon/desklets/"+DESKLET_UUID;
56255649
//~ const HIDDEN_file_path = desklet_path+"/HIDDEN";
56265650
//~ const HIDDEN_EXISTS = file_test(HIDDEN_file_path, FileTest.EXISTS);
56275651

@@ -6489,7 +6513,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
64896513
let next_desklet_id = global.settings.get_int("next-desklet-id");
64906514
let x_pos = global.screen_width - 600;
64916515
let y_pos = global.screen_height - 500;
6492-
enabledDesklets.push('AlbumArt3.0@claudiux:'+next_desklet_id+':'+x_pos+':'+y_pos);
6516+
enabledDesklets.push(DESKLET_UUID+':'+next_desklet_id+':'+x_pos+':'+y_pos);
64936517
global.settings.set_int("next-desklet-id", next_desklet_id + 1);
64946518
global.settings.set_strv(ENABLED_DESKLETS_KEY, enabledDesklets);
64956519
//~ this.desklet_is_activated = this._is_desklet_activated();
@@ -6506,7 +6530,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
65066530
}
65076531

65086532
on_desklet_open_settings_button_clicked() {
6509-
spawnCommandLineAsync("cinnamon-settings desklets AlbumArt3.0@claudiux");
6533+
spawnCommandLineAsync("cinnamon-settings desklets "+DESKLET_UUID);
65106534
}
65116535

65126536
_is_desklet_activated() {
@@ -6515,7 +6539,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
65156539
for (let i = 0; i < enabledDesklets.length; i++){
65166540
let name = enabledDesklets[i].split(":")[0];
65176541
//~ logDebug("Desklet name: "+name);
6518-
if (name == "AlbumArt3.0@claudiux") {
6542+
if (name == DESKLET_UUID) {
65196543
ret = true;
65206544
break;
65216545
}

0 commit comments

Comments
 (0)