Skip to content

Commit fad255f

Browse files
authored
v2.5.10: Better monitoring of files and directories (#6725)
1 parent 76fa9a8 commit fad255f

File tree

4 files changed

+45
-99
lines changed

4 files changed

+45
-99
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
### v2.5.8~20241231
1+
### v2.5.10~20250101
2+
* Better monitoring of files and directories.
3+
4+
### v2.5.9~20241231
25
* Album Art 3.0 becomes faster.
36
* Bugfixes.
47

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,12 @@ var R3PopupMenu = class R3PopupMenu extends PopupMenu {
10461046
if (!sourceActor._applet_context_menu.isOpen)
10471047
sourceActor.actor.change_style_pseudo_class("checked", open);
10481048
}
1049+
1050+
destroy() {
1051+
this._signals.disconnectAllSignals();
1052+
//~ this.actor.destroy();
1053+
this.emit('destroy');
1054+
}
10491055
}
10501056

10511057
class WebRadioReceiverAndRecorder extends TextIconApplet {
@@ -1269,6 +1275,14 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
12691275
this.recMonitor = null;
12701276
this.recMonitorId = null;
12711277

1278+
// Other monitors:
1279+
this.r30stopMonitor = null;
1280+
this.r30stopMonitorId = null;
1281+
this.r30nextMonitor = null;
1282+
this.r30nextMonitorId = null;
1283+
this.r30previousMonitor = null;
1284+
this.r30previousMonitorId = null;
1285+
12721286
// Run all monitors:
12731287
this.on_network_monitoring_changed();
12741288
this.monitor_mpv_title();
@@ -1927,11 +1941,11 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
19271941
if (this.r30stopMonitor == null) return;
19281942

19291943
try {
1930-
if (this.r30stopMonitorId > 0) {
1944+
if (this.r30stopMonitorId != null) {
19311945
//this.r30stopMonitor.cancel();
19321946
this.r30stopMonitor.disconnect(this.r30stopMonitorId);
19331947
this.r30stopMonitor = null;
1934-
this.r30stopMonitorId = 0;
1948+
this.r30stopMonitorId = null;
19351949
}
19361950
} catch(e) {
19371951
logError("Unable to unmonitor %s!".format(R30STOP), e)
@@ -1942,11 +1956,11 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
19421956
if (this.r30previousMonitor == null) return;
19431957

19441958
try {
1945-
if (this.r30previousMonitorId > 0) {
1959+
if (this.r30previousMonitorId != null) {
19461960
//this.r30previousMonitor.cancel();
19471961
this.r30previousMonitor.disconnect(this.r30previousMonitorId);
19481962
this.r30previousMonitor = null;
1949-
this.r30previousMonitorId = 0;
1963+
this.r30previousMonitorId = null;
19501964
}
19511965
} catch(e) {
19521966
logError("Unable to unmonitor %s!".format(R30PREVIOUS), e)
@@ -1957,25 +1971,27 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
19571971
if (this.r30nextMonitor == null) return;
19581972

19591973
try {
1960-
if (this.r30nextMonitorId > 0) {
1974+
if (this.r30nextMonitorId != null) {
19611975
//this.r30nextMonitor.cancel();
19621976
this.r30nextMonitor.disconnect(this.r30nextMonitorId);
19631977
this.r30nextMonitor = null;
1964-
this.r30nextMonitorId = 0;
1978+
this.r30nextMonitorId = null;
19651979
}
19661980
} catch(e) {
19671981
logError("Unable to unmonitor %s!".format(R30NEXT), e)
19681982
}
19691983
}
19701984

19711985
_on_r30stop_changed() {
1986+
if (this.actor.get_stage() == null) return;
19721987
let file = file_new_for_path(R30STOP);
19731988
if (file.query_exists(null)) {
19741989
this.stop_mpv();
19751990
}
19761991
}
19771992

19781993
_on_mpv_title_changed() {
1994+
if (this.actor.get_stage() == null) return;
19791995
//log("_on_mpv_title_changed: " + MPV_TITLE_FILE);
19801996

19811997
let title = to_string(file_get_contents(MPV_TITLE_FILE)[1]).trim();
@@ -2086,6 +2102,7 @@ class WebRadioReceiverAndRecorder extends TextIconApplet {
20862102
}
20872103

20882104
_on_jobs_dir_changed() {
2105+
if (this.actor.get_stage() == null) return;
20892106
//log("_on_jobs_dir_changed: " + JOBS_DIR);
20902107

20912108
let dir = file_new_for_path(JOBS_DIR);

Radio3.0@claudiux/files/Radio3.0@claudiux/desklet/AlbumArt3.0@claudiux/desklet.js

Lines changed: 17 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//"use strict";
2+
const Main = imports.ui.main;
23
const Gio = imports.gi.Gio;
34
const St = imports.gi.St;
45
const Desklet = imports.ui.desklet;
@@ -22,6 +23,7 @@ class AlbumArtRadio30 extends Desklet.Desklet {
2223
this.update_id = null;
2324
this.old_image_path = null;
2425
this.isLooping = true;
26+
this.dir_monitor_loop_is_active = true;
2527

2628
this.dir = "file://"+GLib.get_home_dir()+"/.config/Radio3.0/song-art";
2729
this.shuffle = false;
@@ -45,16 +47,6 @@ class AlbumArtRadio30 extends Desklet.Desklet {
4547

4648
on_setting_changed() {
4749
this.isLooping = false;
48-
//~ if (this.update_id) {
49-
//~ try {
50-
//~ if (Mainloop.source_remove(this.update_id)) this.update_id = null;
51-
//~ }
52-
//~ catch(e) {
53-
//~ this.update_id = null;
54-
//~ } finally {
55-
//~ this.update_id = null;
56-
//~ }
57-
//~ }
5850

5951
this._setup_dir_monitor();
6052
if (this.currentPicture) {
@@ -68,54 +60,32 @@ class AlbumArtRadio30 extends Desklet.Desklet {
6860
}
6961

7062
_setup_dir_monitor() {
71-
if (this.dir_monitor_id && this.dir_monitor) {
72-
this.dir_monitor.disconnect(this.dir_monitor_id);
73-
this.dir_monitor_id = null;
74-
}
75-
76-
/* The widget used to choose the folder the images are drawn from
77-
was changed to use a URI instead of a path. This check is just
78-
to ensure that people upgrading cinnamon versions will get the
79-
existing path converted to a proper URI */
80-
if (this.dir.indexOf('://') === -1) {
81-
let file = Gio.file_new_for_path(this.dir);
82-
this.dir = file.get_uri();
83-
}
84-
85-
if (this.dir === ' ') {
86-
let file = Gio.file_new_for_path(GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES));
87-
this.dir = file.get_uri();
88-
}
63+
if (this.dir_monitor_id != null) return;
8964

9065
this.dir_file = Gio.file_new_for_uri(this.dir);
9166
this.dir_monitor = this.dir_file.monitor_directory(0, null);
92-
this.dir_monitor_id = this.dir_monitor.connect('changed', Lang.bind(this, this.on_setting_changed));
67+
this.dir_monitor_id = this.dir_monitor.connect('changed', Lang.bind(this, this.dir_monitor_loop));
9368
}
9469

95-
//~ on_desklet_added_to_desktop(userEnabled) {
96-
//~ this.actor.reactive = true;
97-
//~ }
70+
dir_monitor_loop() {
71+
if (!this.dir_monitor_loop_is_active) {
72+
this.dir_monitor_id = null;
73+
return false;
74+
}
75+
this.on_setting_changed();
76+
return true;
77+
}
9878

9979
on_desklet_removed() {
100-
if (this.dir_monitor) {
80+
//~ if (this.dir_monitor) {
10181
//~ this.dir_monitor.disconnectAllSignals();
102-
this.dir_monitor.disconnect(this.dir_monitor_id);
82+
//~ this.dir_monitor.disconnect(this.dir_monitor_id);
10383
//~ this.dir_monitor_id = null;
104-
}
105-
this.dir_monitor_id = null;
84+
//~ }
85+
//~ this.dir_monitor_id = null;
10686

10787
this.isLooping = false;
108-
109-
//~ if (this.update_id) {
110-
//~ try {
111-
//~ if (Mainloop.source_remove(this.update_id)) this.update_id = null;
112-
//~ }
113-
//~ catch(e) {
114-
//~ this.update_id = null;
115-
//~ } finally {
116-
//~ this.update_id = null;
117-
//~ }
118-
//~ }
88+
this.dir_monitor_loop_is_active = false;
11989
}
12090

12191
_scan_dir(dir) {
@@ -152,23 +122,6 @@ class AlbumArtRadio30 extends Desklet.Desklet {
152122
this.setContent(this._photoFrame);
153123
}
154124

155-
//~ if (this.effect == 'black-and-white') {
156-
//~ let effect = new Clutter.DesaturateEffect();
157-
//~ this._bin.add_effect(effect);
158-
//~ } else if (this.effect == 'sepia') {
159-
//~ let color = new Clutter.Color();
160-
//~ color.from_hls(17.0, 0.59, 0.4);
161-
//~ let colorize_effect = new Clutter.ColorizeEffect(color);
162-
//~ let contrast_effect = new Clutter.BrightnessContrastEffect();
163-
//~ let desaturate_effect = new Clutter.DesaturateEffect();
164-
//~ desaturate_effect.set_factor(0.41);
165-
//~ contrast_effect.set_brightness_full(0.1, 0.1, 0.1);
166-
//~ contrast_effect.set_contrast_full(0.1, 0.1, 0.1);
167-
//~ this._bin.add_effect(colorize_effect);
168-
//~ this._bin.add_effect(contrast_effect);
169-
//~ this._bin.add_effect(desaturate_effect);
170-
//~ }
171-
172125
if (this.dir_file.query_exists(null)) {
173126
this._scan_dir(this.dir);
174127

@@ -183,21 +136,6 @@ class AlbumArtRadio30 extends Desklet.Desklet {
183136
_update_loop() {
184137
if (!this.isLooping) return false;
185138
this._update();
186-
//~ if (this.update_id) {
187-
//~ try {
188-
//~ if (Mainloop.source_remove(this.update_id)) this.update_id = null;
189-
//~ }
190-
//~ catch(e) {
191-
//~ // Nothing to do.
192-
//~ } finally {
193-
//~ this.update_id = Mainloop.timeout_add_seconds(this.delay, Lang.bind(this, this._update_loop));
194-
//~ }
195-
//~ }
196-
//~ if (this.update_id) {
197-
//~ return true
198-
//~ } else {
199-
//~ this.update_id = Mainloop.timeout_add_seconds(this.delay, Lang.bind(this, this._update_loop));
200-
//~ }
201139
if (this.isLooping)
202140
this.update_id = Mainloop.timeout_add_seconds(this.delay, Lang.bind(this, this._update_loop));
203141
else
@@ -223,8 +161,6 @@ class AlbumArtRadio30 extends Desklet.Desklet {
223161
}
224162

225163
_update() {
226-
//~ this._show_or_hide();
227-
228164
if (this.updateInProgress) {
229165
return;
230166
}
@@ -294,7 +230,6 @@ class AlbumArtRadio30 extends Desklet.Desklet {
294230
on_desklet_clicked(event) {
295231
try {
296232
if (event.get_button() == 1) {
297-
//~ this._update();
298233
this.on_setting_changed();
299234
} else if (event.get_button() == 2) {
300235
Util.spawn(['xdg-open', this.currentPicture.path]);
@@ -316,15 +251,6 @@ class AlbumArtRadio30 extends Desklet.Desklet {
316251
return null;
317252
}
318253
}
319-
320-
//~ _show_or_hide() {
321-
//~ if (GLib.file_test(GLib.get_home_dir()+"/.local/share/cinnamon/desklets/AlbumArt3.0@claudiux/HIDDEN", GLib.FileTest.EXISTS)) {
322-
//~ if (this.actor) this.actor.hide();
323-
//~ }
324-
//~ else {
325-
//~ if (this.actor) this.actor.show();
326-
//~ }
327-
//~ }
328254
}
329255

330256
function main(metadata, desklet_id) {

Radio3.0@claudiux/files/Radio3.0@claudiux/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"description": "The Ultimate Internet Radio Receiver & Recorder for Cinnamon",
33
"max-instances": 1,
4-
"version": "2.5.9",
4+
"version": "2.5.10",
55
"uuid": "Radio3.0@claudiux",
66
"name": "Radio3.0",
77
"author": "claudiux",

0 commit comments

Comments
 (0)