Implement show all feature

This commit is contained in:
Benjamin Drieu 2022-05-30 11:27:27 +02:00 committed by Benjamin Drieu
parent 4e21919d2e
commit d7263f491b

View File

@ -78,8 +78,9 @@ class Indicator extends PanelMenu.Button {
this.namesBoxes = { }; this.namesBoxes = { };
this.boxes = { }; this.boxes = { };
this.sortIcons = { }; this.sortIcons = { };
this.showAll = false;
account_settings [ server ] = Preferences.getAccountSettings ( this.server ); account_settings [ server ] = Preferences.getAccountSettings ( this.server );
this.account_settings = account_settings [ server ]; this.account_settings = account_settings [ server ];
@ -165,9 +166,11 @@ class Indicator extends PanelMenu.Button {
this._searchField.connect('secondary-icon-clicked', Lang.bind(this, this._onSearchFieldActivate ) ); this._searchField.connect('secondary-icon-clicked', Lang.bind(this, this._onSearchFieldActivate ) );
this._searchField.clutter_text.connect('activate', Lang.bind(this, this._onSearchFieldActivate ) ); this._searchField.clutter_text.connect('activate', Lang.bind(this, this._onSearchFieldActivate ) );
this._searchField.clutter_text.connect('text-changed', Lang.bind(this, this._onSearchFieldActivate ) ); this._searchField.clutter_text.connect('text-changed', Lang.bind(this, this._onSearchFieldActivate ) );
this._buttonMenu.actor.add_child (this._searchField); this._buttonMenu.actor.add_child (this._searchField);
this._showAllButton = this._createButton ( 'big', 'view-reveal-symbolic', _('Show all'), this.changeShowAll, true );
this._buttonMenu.actor.add_child (this._showAllButton );
this._prefsButton = this._createButton ( 'big', 'preferences-system-symbolic', _('Preferences'), this._onPreferencesActivate ); this._prefsButton = this._createButton ( 'big', 'preferences-system-symbolic', _('Preferences'), this._onPreferencesActivate );
this._buttonMenu.actor.add_child (this._prefsButton); this._buttonMenu.actor.add_child (this._prefsButton);
@ -224,6 +227,12 @@ class Indicator extends PanelMenu.Button {
this.serverLogic.recheckAll ( this._recheckButton ); this.serverLogic.recheckAll ( this._recheckButton );
} }
changeShowAll ( )
{
this.showAll = ! this.showAll;
this.refreshUI ( );
}
updateStatus ( ) updateStatus ( )
{ {
this.spinChildOf ( this._reloadButton ); this.spinChildOf ( this._reloadButton );
@ -446,7 +455,8 @@ class Indicator extends PanelMenu.Button {
entry [ 'status_information' ].toLowerCase().includes ( this._searchString ) ) ) entry [ 'status_information' ].toLowerCase().includes ( this._searchString ) ) )
continue; continue;
if ( ( ! _status [ 'WARNING' ] && ! _status [ 'CRITICAL' ] && ! _status [ 'UNKNOWN' ] && entry.status == 'OK' ) || if ( this.showAll ||
( ! _status [ 'WARNING' ] && ! _status [ 'CRITICAL' ] && ! _status [ 'UNKNOWN' ] && entry.status == 'OK' ) ||
( ( _status [ 'WARNING' ] || _status [ 'CRITICAL' ] || _status [ 'UNKNOWN' ] ) && entry.status != 'OK' ) ) ( ( _status [ 'WARNING' ] || _status [ 'CRITICAL' ] || _status [ 'UNKNOWN' ] ) && entry.status != 'OK' ) )
{ {
let _style = this.getStyleForRow ( entry.status.toLowerCase(), _row ); let _style = this.getStyleForRow ( entry.status.toLowerCase(), _row );
@ -632,7 +642,7 @@ class Indicator extends PanelMenu.Button {
this.stopChildSpin ( e.service.button ); this.stopChildSpin ( e.service.button );
} }
_createButton ( sizeName, icon, data, callback ) { _createButton ( sizeName, icon, data, callback, radiobutton = false ) {
let size = 24; let size = 24;
if ( sizeName == 'small' ) if ( sizeName == 'small' )
size = 24; size = 24;
@ -657,6 +667,9 @@ class Indicator extends PanelMenu.Button {
}); });
button.prevIcon = icon; button.prevIcon = icon;
button.toggle_mode = true;
button.set_checked ( true );
if ( data instanceof Object ) if ( data instanceof Object )
button.service = data; button.service = data;