@@ -21,32 +21,26 @@ MyDesklet.prototype = {
21
21
22
22
try {
23
23
this . settings = new Settings . DeskletSettings (
24
- this , this . metadata [ "uuid" ] , this . instance_id ) ;
25
-
26
- this . settings . bindProperty ( Settings . BindingDirection . IN ,
27
- "file" ,
28
- "file" ,
29
- this . on_setting_changed ,
30
- null ) ;
31
- this . settings . bindProperty ( Settings . BindingDirection . IN ,
32
- "delay" ,
33
- "delay" ,
34
- this . on_setting_changed ,
35
- null ) ;
36
- } catch ( e ) {
24
+ this , this . metadata [ "uuid" ] , this . instance_id ) ;
25
+
26
+ this . settings . bindProperty ( Settings . BindingDirection . IN , "file" , "file" , this . on_setting_changed , null ) ;
27
+ this . settings . bindProperty ( Settings . BindingDirection . IN , "delay" , "delay" , this . on_setting_changed , null ) ;
28
+ }
29
+ catch ( e ) {
37
30
global . logError ( e ) ;
38
31
}
39
32
40
- this . sep = "%" ;
41
- this . maxSize = 7000 ; // Many more characters, and Cinnamon crashes
33
+ this . sep = "%" ; // SPACE
34
+ this . maxSize = 7000 ; // Cinnamon can crash if this int is too high
42
35
43
- this . setHeader ( _ ( "Quote" ) ) ;
44
- this . setup_display ( ) ;
36
+ this . setHeader ( _ ( "Quote of the day " ) ) ;
37
+ this . setup_display ( ) ;
45
38
} ,
46
39
47
40
on_setting_changed : function ( ) {
48
- if ( this . update_id > 0 )
41
+ if ( this . update_id > 0 ) {
49
42
Mainloop . source_remove ( this . update_id ) ;
43
+ }
50
44
this . update_id = null ;
51
45
this . setup_display ( ) ;
52
46
} ,
@@ -57,31 +51,38 @@ MyDesklet.prototype = {
57
51
58
52
setup_display : function ( ) {
59
53
this . _quoteContainer =
60
- new St . BoxLayout ( { vertical :true , style_class : 'quote-container' } ) ;
54
+ new St . BoxLayout ( { vertical :true , style_class : 'quote-container' } ) ;
61
55
this . _quote = new St . Label ( ) ;
62
56
63
- this . _quoteContainer . add ( this . _quote ) ;
57
+ this . _quoteContainer . add ( this . _quote ) ;
64
58
this . setContent ( this . _quoteContainer ) ;
65
59
66
- this . updateInProgress = false ;
60
+ this . updateInProgress = false ;
67
61
this . file = this . file . replace ( '~' , GLib . get_home_dir ( ) ) ;
68
62
69
- this . _update_loop ( ) ;
63
+ this . _update_loop ( ) ;
70
64
} ,
71
65
66
+ /**
67
+ * Updates every user set secconds?
68
+ **/
72
69
_update_loop : function ( ) {
73
70
this . _update ( ) ;
74
71
this . update_id = Mainloop . timeout_add_seconds (
75
- this . delay * 60 , Lang . bind ( this , this . _update_loop ) ) ;
72
+ this . delay * 60 , Lang . bind ( this , this . _update_loop ) ) ;
76
73
} ,
77
74
75
+ /**
76
+ * Method to update the text/reading of the file
77
+ **/
78
78
_update : function ( ) {
79
79
if ( this . updateInProgress ) {
80
- return ;
80
+ return ;
81
81
}
82
82
this . updateInProgress = true ;
83
83
84
- try {
84
+ try {
85
+
85
86
// Since we update infrequently, reread the file in case it has changed
86
87
if ( ! GLib . file_test ( this . file , GLib . FileTest . EXISTS ) )
87
88
return ;
@@ -110,7 +111,7 @@ MyDesklet.prototype = {
110
111
this . _quote . set_text ( currentQuote ) ;
111
112
112
113
} catch ( e ) {
113
- global . logError ( e ) ;
114
+ global . logError ( e ) ;
114
115
} finally {
115
116
this . updateInProgress = false ;
116
117
}
@@ -124,14 +125,15 @@ MyDesklet.prototype = {
124
125
this . separators = [ ] ;
125
126
let index = 0 ;
126
127
127
- while ( index < allQuotes . length ) {
128
- index = allQuotes . indexOf ( this . sep , index ) ;
129
- if ( index === - 1 )
130
- break ; // no more separators
131
- this . separators . push ( index ) ;
132
- index ++ ;
133
- }
134
- }
128
+ while ( index < allQuotes . length ) {
129
+ index = allQuotes . indexOf ( this . sep , index ) ;
130
+ if ( index === - 1 ) {
131
+ break ; // no more separator
132
+ }
133
+ this . separators . push ( index ) ;
134
+ index ++ ;
135
+ }
136
+ }
135
137
}
136
138
137
139
function main ( metadata , desklet_id ) {
0 commit comments