11//"use strict";
2+ const Main = imports . ui . main ;
23const Gio = imports . gi . Gio ;
34const St = imports . gi . St ;
45const 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
330256function main ( metadata , desklet_id ) {
0 commit comments