@@ -21,7 +21,7 @@ const {
2121const { HttpLib } = require ( "./lib/httpLib" ) ;
2222const { to_string } = require ( "./lib/to-string" ) ;
2323//mainloopTools:
24- const { _sourceIds , timeout_add_seconds, timeout_add , setTimeout, clearTimeout, setInterval , clearInterval , source_exists , source_remove, remove_all_sources } = require ( "./lib/mainloopTools" ) ;
24+ const { timeout_add_seconds, setTimeout, clearTimeout, source_remove, remove_all_sources } = require ( "./lib/mainloopTools" ) ;
2525
2626const UUID = "SpiceSpy@claudiux" ;
2727
@@ -340,6 +340,8 @@ class SpiceSpy extends Applet.TextIconApplet {
340340 this . jobsLoopId = null ;
341341 this . issuesLoopId = null ;
342342 this . is_looping = true ;
343+
344+ this . iconColorLoopId = null ;
343345
344346 this . settings = new Settings . AppletSettings ( this , UUID , instance_id ) ;
345347
@@ -352,6 +354,9 @@ class SpiceSpy extends Applet.TextIconApplet {
352354 this . update_interval = 0.5 * Math . round ( this . settings . getValue ( "update-interval" ) / 30 ) ;
353355 this . settings . setValue ( "update-interval" , - 1 ) ;
354356 }
357+ this . settings . bind ( "update-interruptible" , "updateIsInterruptible" ) ;
358+ this . settings . bind ( "coloredIcon" , "coloredIcon" ) ;
359+ this . settings . bind ( "colorWhileRefreshing" , "colorWhileRefreshing" ) ;
355360 this . settings . bind ( "standard-opacity" , "standard_opacity" ) ;
356361 this . settings . bind ( "color-on-change" , "color_on_change" , ( ) => { this . make_menu ( ) } ) ;
357362 this . show_icon_in_menu = true ;
@@ -369,6 +374,18 @@ class SpiceSpy extends Applet.TextIconApplet {
369374 this . settings . bind ( "spices_to_spy" , "spices_to_spy" ) ;
370375 this . settings . bind ( "old_spices_to_spy" , "old_spices_to_spy" ) ;
371376 } // End of get_user_settings
377+
378+ setIconColor ( ) {
379+ if ( ! this . coloredIcon ) {
380+ this . actor . style = null ;
381+ return
382+ }
383+ if ( this . commentsJobsList . length > 0 || this . issuesJobsList . length > 0 ) {
384+ this . actor . style = `color: ${ this . colorWhileRefreshing } ;`
385+ } else {
386+ this . actor . style = null
387+ }
388+ } // End of setIconColor
372389
373390 update_interval_value ( ) {
374391 const sec = Math . round ( this . update_interval * 3600 ) ; // From hours to seconds.
@@ -449,7 +466,10 @@ class SpiceSpy extends Applet.TextIconApplet {
449466 this . settings . setValue ( "uuid-list" , _uuid_list ) ;
450467
451468 // Loop next tick (value 0) to ensure that this.actor is on stage:
452- setTimeout ( ( ) => this . loop ( ) , 0 ) ;
469+ let _to = setTimeout ( ( ) => {
470+ clearTimeout ( _to ) ;
471+ this . loop ( )
472+ } , 0 ) ;
453473 }
454474 } // End of _add_user_Spices
455475
@@ -570,7 +590,8 @@ class SpiceSpy extends Applet.TextIconApplet {
570590 if ( this . spices_to_spy [ type ] [ uuid ] )
571591 this . spices_to_spy [ type ] [ uuid ] [ "issues" ] = issuesNumber ;
572592 GLib . free ( jsonFileContents ) ;
573- this . make_menu ( ) ;
593+ if ( ! this . menu . isOpen )
594+ this . make_menu ( ) ;
574595 } // End of do_issuesJob
575596
576597 do_issuesJob_OLD ( type , spice , command ) {
@@ -663,7 +684,10 @@ class SpiceSpy extends Applet.TextIconApplet {
663684 source_remove ( id ) ;
664685 }
665686 this . issuesLoopId = null ;
666- this . issuesLoopId = timeout_add_seconds ( 5 , ( ) => { this . issuesJobs_loop ( ) ; return ( this . issuesJobsList . length > 0 && this . is_looping ) ; } ) ;
687+ this . issuesLoopId = timeout_add_seconds ( 5 , ( ) => {
688+ this . issuesJobs_loop ( ) ;
689+ return ( this . issuesJobsList . length > 0 && this . is_looping ) ;
690+ } ) ;
667691
668692 return this . is_looping ;
669693 } // End of loop
@@ -790,18 +814,6 @@ class SpiceSpy extends Applet.TextIconApplet {
790814 }
791815 } // End of update_issues
792816
793- update_issues_OLD ( ) {
794- const GET_ISSUES_SCRIPT = SCRIPTS_DIR + "/get-issues.sh"
795- const interval = 5000 ; //ms = 5 seconds.
796- for ( let type of TYPES ) {
797- let spices = this . spices_to_spy [ type ] ;
798- for ( let spice of Object . keys ( spices ) ) {
799- let command = "" + GET_ISSUES_SCRIPT + " " + type + " " + spices [ spice ] [ 'uuid' ] ;
800- this . issuesJobsList . push ( type , spice , command ) ;
801- }
802- }
803- } // End of update_issues_OLD
804-
805817 make_menu ( ) {
806818 var total_diff_score = 0 ;
807819 var total_diff_comments = 0 ;
@@ -915,7 +927,7 @@ class SpiceSpy extends Applet.TextIconApplet {
915927 }
916928
917929 if ( this . issuesJobsList . length === 0 ) {
918- let refresh = new PopupMenu . PopupIconMenuItem ( _ ( "Refresh" ) , "" , St . IconType . SYMBOLIC ) ;
930+ let refresh = new PopupMenu . PopupIconMenuItem ( _ ( "Refresh" ) , "view-refresh-symbolic " , St . IconType . SYMBOLIC ) ;
919931 refresh . connect ( "activate" ,
920932 ( ) => {
921933 if ( this . menu ) this . menu . toggle ( true ) ;
@@ -926,12 +938,40 @@ class SpiceSpy extends Applet.TextIconApplet {
926938 ) ;
927939 this . menu . addMenuItem ( refresh ) ;
928940 } else {
929- let refresh_in_progress = new PopupMenu . PopupIconMenuItem (
930- _ ( "Refreshing in progress" ) ,
931- "view-refresh" ,
932- St . IconType . SYMBOLIC ,
933- { reactive : false }
941+ let refresh_in_progress ;
942+ if ( this . updateIsInterruptible ) {
943+ refresh_in_progress = new PopupMenu . PopupIconMenuItem (
944+ _ ( "Refreshing in progress - Click to stop" ) ,
945+ "hand-open-symbolic" ,
946+ St . IconType . SYMBOLIC ,
947+ { reactive : true }
948+ ) ;
949+ refresh_in_progress . connect ( "activate" ,
950+ ( ) => {
951+ if ( this . menu ) this . menu . toggle ( true ) ;
952+ if ( this . issuesLoopId != null ) {
953+ source_remove ( this . issuesLoopId ) ;
954+ }
955+ this . issuesLoopId = null ;
956+ this . issuesJobsList = [ ] ;
957+
958+ if ( this . jobsLoopId != null ) {
959+ source_remove ( this . jobsLoopId ) ;
960+ }
961+ this . jobsLoopId = null ;
962+ this . commentsJobsList = [ ] ;
963+ //~ this.is_looping = true;
964+ //~ this.fistTime = false;
965+ }
934966 ) ;
967+ } else {
968+ refresh_in_progress = new PopupMenu . PopupIconMenuItem (
969+ _ ( "Refreshing in progress" ) ,
970+ "hand-open-symbolic" ,
971+ St . IconType . SYMBOLIC ,
972+ { reactive : false }
973+ ) ;
974+ }
935975 this . menu . addMenuItem ( refresh_in_progress ) ;
936976 }
937977
@@ -972,6 +1012,7 @@ class SpiceSpy extends Applet.TextIconApplet {
9721012
9731013 this . loopId = timeout_add_seconds ( 60 , ( ) => { this . loop ( ) } ) ;
9741014 this . jobsLoopId = timeout_add_seconds ( 15 , ( ) => { this . commentsJobs_loop ( ) ; return this . is_looping ; } ) ;
1015+ this . iconColorLoopId = timeout_add_seconds ( 1 , ( ) => { this . setIconColor ( ) ; return this . is_looping ; } ) ;
9751016
9761017 this . update_issues_json ( ) ;
9771018 this . updateUI ( ) ;
0 commit comments