File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -362,12 +362,11 @@ export default class MyExtension extends Extension {
362362 }
363363 }
364364
365- enable ( ) {
365+ _modifySystemItem ( ) {
366366 this . _setting = this . getSettings ( )
367367 this . _checkRequirements ( ) ;
368368 this . _loginManager = LoginManager . getLoginManager ( ) ;
369369 this . systemMenu = Main . panel . statusArea . quickSettings . _system ;
370-
371370 this . _hibernateMenuItem = new PopupMenu . PopupMenuItem ( __ ( 'Hibernate' ) ) ;
372371 this . _hibernateMenuItemId = this . _hibernateMenuItem . connect (
373372 'activate' ,
@@ -418,6 +417,24 @@ export default class MyExtension extends Extension {
418417 ) ;
419418 }
420419
420+ _queueModifySystemItem ( ) {
421+ this . sourceId = GLib . idle_add ( GLib . PRIORITY_DEFAULT , ( ) => {
422+ if ( ! Main . panel . statusArea . quickSettings . _system )
423+ return GLib . SOURCE_CONTINUE ;
424+
425+ this . _modifySystemItem ( ) ;
426+ return GLib . SOURCE_REMOVE ;
427+ } ) ;
428+ }
429+
430+ enable ( ) {
431+ if ( ! Main . panel . statusArea . quickSettings . _system ) {
432+ this . _queueModifySystemItem ( ) ;
433+ } else {
434+ this . _modifySystemItem ( ) ;
435+ }
436+ }
437+
421438 disable ( ) {
422439 this . _setting = null ;
423440 if ( this . _menuOpenStateChangedId ) {
@@ -456,6 +473,11 @@ export default class MyExtension extends Extension {
456473 this . _hibernateMenuItem . destroy ( ) ;
457474 this . _hibernateMenuItem = 0 ;
458475 }
476+
477+ if ( this . sourceId ) {
478+ GLib . Source . remove ( this . sourceId ) ;
479+ this . sourceId = null ;
480+ }
459481 } ;
460482}
461483
You can’t perform that action at this time.
0 commit comments