@@ -338,8 +338,6 @@ class SpiceSpy extends Applet.TextIconApplet {
338338 this . set_applet_label ( "" ) ;
339339 this . setAllowedLayout ( Applet . AllowedLayout . BOTH ) ;
340340
341- //~ this.updateUI();
342-
343341 this . menuManager = new PopupMenu . PopupMenuManager ( this ) ;
344342 this . menu = new Applet . AppletPopupMenu ( this , orientation ) ;
345343 //~ this.menu = new PopupMenu.PopupMenu(this, orientation);
@@ -385,7 +383,7 @@ class SpiceSpy extends Applet.TextIconApplet {
385383 //~ this.settings.bind("display-on-panel", "display_on_panel", this.make_menu.bind(this));
386384 this . settings . bind ( "display-on-panel" , "display_on_panel" ) ;
387385 //~ this.settings.bind("useful-only", "useful_only", this.make_menu.bind(this));
388- this . settings . bind ( "useful-only" , "useful_only" ) ;
386+ this . settings . bind ( "useful-only" , "useful_only" , ( ) => { this . make_menu ( ) } ) ;
389387 this . settings . bind ( "author-list" , "author_list" , ( ) => { this . update_authors ( ) } ) ;
390388 this . settings . bind ( "uuid-list" , "uuid_list" , ( ) => { this . update_uuids ( ) } ) ;
391389 this . settings . bind ( "spices_to_spy" , "spices_to_spy" ) ;
@@ -482,11 +480,11 @@ class SpiceSpy extends Applet.TextIconApplet {
482480
483481 updateUI ( score = 0 , comments = 0 , translations = 0 ) {
484482 let _label ;
485- if ( this . show_translations )
486- _label = "%s %s\n%s %s\n%s %s" . format ( STAR_CHAR , score . toString ( ) , MESSAGE_CHAR , comments . toString ( ) , FLAG_CHAR , translations . toString ( ) ) ;
487- else
488- _label = "%s %s\n%s %s" . format ( STAR_CHAR , score . toString ( ) , MESSAGE_CHAR , comments . toString ( ) ) ;
489- this . set_applet_label ( _label ) ;
483+ //~ if (this.show_translations)
484+ //~ _label = "%s %s\n%s %s\n%s %s".format(STAR_CHAR, score.toString(), MESSAGE_CHAR, comments.toString(), FLAG_CHAR, translations.toString());
485+ //~ else
486+ //~ _label = "%s %s\n%s %s".format(STAR_CHAR, score.toString(), MESSAGE_CHAR, comments.toString());
487+ //~ this.set_applet_label(_label);
490488 if ( score == 0 && comments == 0 && translations == 0 ) {
491489 if ( this . display_on_panel === "normal" ) {
492490 this . actor . show ( ) ;
@@ -504,14 +502,23 @@ class SpiceSpy extends Applet.TextIconApplet {
504502 this . actor . set_style ( null ) ;
505503 this . _applet_label . set_style ( null ) ;
506504 } else {
507- if ( this . useful_only ) {
508- let _labels = [ ] ;
509- if ( score != 0 ) _labels . push ( "%s %s" . format ( STAR_CHAR , score . toString ( ) ) ) ;
510- if ( comments != 0 ) _labels . push ( "%s %s" . format ( MESSAGE_CHAR , comments . toString ( ) ) ) ;
511- if ( this . show_translations && translations != 0 ) _labels . push ( "%s %s" . format ( FLAG_CHAR , translations . toString ( ) ) ) ;
505+ let _labels = [ ] ;
506+ if ( ! this . useful_only || score != 0 ) _labels . push ( "%s %s" . format ( STAR_CHAR , score . toString ( ) ) ) ;
507+ if ( ! this . useful_only || comments != 0 ) _labels . push ( "%s %s" . format ( MESSAGE_CHAR , comments . toString ( ) ) ) ;
508+ if ( ! this . useful_only || ( this . show_translations && translations != 0 ) ) _labels . push ( "%s %s" . format ( FLAG_CHAR , translations . toString ( ) ) ) ;
509+ if ( this . is_vertical ) {
510+ logDebug ( "Vertical panel" ) ;
512511 _label = "" + _labels . join ( "\n" ) ;
513- this . set_applet_label ( _label ) ;
512+ } else {
513+ logDebug ( "Horizontal panel" ) ;
514+ logDebug ( "_labels.length * 20: " + _labels . length * 20 ) ;
515+ logDebug ( "this._panelHeight: " + this . _panelHeight ) ;
516+ if ( _labels . length * 20 <= this . _panelHeight )
517+ _label = "" + _labels . join ( "\n" ) ;
518+ else
519+ _label = "" + _labels . join ( " " ) ;
514520 }
521+ this . set_applet_label ( _label ) ;
515522 this . actor . show ( ) ;
516523 this . showLabel ( ) ;
517524 this . actor . set_style ( "color: %s;" . format ( this . color_on_change ) ) ;
@@ -589,7 +596,7 @@ class SpiceSpy extends Applet.TextIconApplet {
589596 } // End of commentsJobs_loop
590597
591598 async do_commentsJob ( type , spice , page ) {
592- logDebug ( `do_commentsJob(${ type } , ${ spice } , ${ page } )` ) ;
599+ //~ logDebug(`do_commentsJob(${type}, ${spice}, ${page})`);
593600 if ( ! this . spices_to_spy [ type ] || ! this . spices_to_spy [ type ] [ spice ] ) {
594601 this . commentsJobsList . push ( [ type , spice , page ] ) ;
595602 //~ logDebug("Re-inserted at the end of the list.")
@@ -756,32 +763,11 @@ class SpiceSpy extends Applet.TextIconApplet {
756763 } // End of get_spices_to_spy
757764
758765 update_comments ( ) {
759- //~ const interval = 13000; //ms = 13 seconds (the spices website accepts a maximum of 5 requests per minute.)
760- //~ var index = 0;
761- //~ var http = new HttpLib();
762766 for ( let type of TYPES ) {
763767 let spices = this . spices_to_spy [ type ] ;
764768 for ( let spice of Object . keys ( spices ) ) {
765769 const page = spices [ spice ] [ 'url' ] + `#${ HTML_COUNT_ID } ` ;
766770 this . commentsJobsList . push ( [ type , spice , page ] ) ;
767- //~ let id = setTimeout(() => {
768- //~ clearTimeout(id);
769- //~ let response = http.LoadAsync(page);
770- //~ if (response.Success) {
771- //~ let result = COMMENTS_REGEX.exec(response.Data);
772- //~ if (result && result[1]) {
773- //~ let count = parseInt(result[1]);
774- //~ this.spices_to_spy[type][spice]['comments'] = count;
775- //~ //this.make_menu();
776- //~ } else {
777- //~ global.logWarning(spices[spice]['uuid'] + ": This spice is cached in the "
778- //~ + ".json file but doesn't actually exist in the "
779- //~ + "Spices now OR the Cinnamon Spices changed the ID "
780- //~ + "(please report if there are 0 items)");
781- //~ }
782- //~ }
783- //~ }, index*interval);
784- //~ index += 1;
785771 }
786772 }
787773 } // End of update_comments
@@ -1006,10 +992,11 @@ class SpiceSpy extends Applet.TextIconApplet {
1006992 //~ this.update_comments();
1007993
1008994 this . loopId = timeout_add_seconds ( 60 , ( ) => { this . loop ( ) } ) ;
1009- this . jobsLoopId = timeout_add_seconds ( 13 , ( ) => { this . commentsJobs_loop ( ) ; return this . is_looping ; } ) ;
995+ this . jobsLoopId = timeout_add_seconds ( 15 , ( ) => { this . commentsJobs_loop ( ) ; return this . is_looping ; } ) ;
1010996
1011997 this . update_issues_json ( ) ;
1012998 //~ this.make_menu();
999+ this . updateUI ( ) ;
10131000 } // End of on_applet_added_to_panel
10141001
10151002 on_applet_clicked ( ) {
@@ -1032,9 +1019,17 @@ class SpiceSpy extends Applet.TextIconApplet {
10321019 this . issuesJsonLoopId = null ;
10331020 } // End of on_applet_removed_from_panel
10341021
1022+ on_panel_height_changed ( ) {
1023+ this . make_menu ( ) ;
1024+ }
1025+
10351026 _reload_this_applet ( event = null ) {
10361027 reloadExtension ( UUID , Type . APPLET )
10371028 } // End of _reload_this_applet
1029+
1030+ get is_vertical ( ) {
1031+ return ( this . orientation == St . Side . LEFT || this . orientation == St . Side . RIGHT ) ;
1032+ }
10381033}
10391034
10401035function main ( metadata , orientation , panel_height , instance_id ) {
0 commit comments