Add button + change defaults

This commit is contained in:
Benjamin Drieu 2021-11-19 22:16:45 +01:00
parent 2e493e6fe7
commit 838f4012a1
2 changed files with 32 additions and 2 deletions

View File

@ -61,6 +61,7 @@ const column_definitions = {
last_check: { label: _('Last check'), width: 200, expand: false, },
attempts: { label: _('Attempts'), width: 50, expand: false, },
status_information: { label: _('Information'), width: 600, expand: true, },
actions: { label: 'Actions', width: 100, expand: true, special: 'actions' },
};
@ -150,6 +151,9 @@ class Indicator extends PanelMenu.Button {
this._prefsButton = this._createButton ( 'preferences-system-symbolic', 'Preferences', this._onPreferencesActivate );
this._buttonMenu.actor.add_child (this._prefsButton);
this._updateButton = this._createButton ( 'mail-send-receive-symbolic', 'Reload', this.updateStatus ); // Implement this
this._buttonMenu.actor.add_child (this._updateButton );
this._reloadButton = this._createButton ( 'view-refresh-symbolic', 'Reload', this.updateStatus );
this._buttonMenu.actor.add_child (this._reloadButton );
@ -254,12 +258,36 @@ class Indicator extends PanelMenu.Button {
}
createBin ( status, text, col ) {
let _child;
if ( ! col [ 'special' ] )
_child = new St.Label({ style_class: 'monito-label', text: text });
else if ( col.special == 'actions' )
{
_child = new St.BoxLayout ( { x_expand: true,
x_align: Clutter.ActorAlign.FILL,
vertical: false } );
let _button = new St.Button ( {
x_align: Clutter.ActorAlign.END,
y_align: Clutter.ActorAlign.CENTER,
can_focus: true,
track_hover: true,
} );
_button.child = new St.Icon ( {
icon_name: 'view-refresh-symbolic',
icon_size: 16,
width: 16,
height: 16,
} );
_child.add_child ( _button );
}
let _bin = new St.Bin({
style_class: 'monito-service-' + status,
track_hover: true,
width: col.width,
x_expand: col.expand,
child: new St.Label({ style_class: 'monito-label', text: text })
child: _child,
});
return _bin;
}
@ -284,6 +312,7 @@ class Indicator extends PanelMenu.Button {
let _columns = Preferences.getColumns ( this.server );
for ( let _col of _columns )
headerBox.add_child ( this.createHeaderBin ( _col ) );
headerBox.add_child ( this.createHeaderBin ( 'actions' ) );
let scrollBox = new St.ScrollView ( { hscrollbar_policy: St.PolicyType.NEVER,
enable_mouse_scrolling: true, } );
@ -313,6 +342,7 @@ class Indicator extends PanelMenu.Button {
{
infoBox.add_child ( this.createBin ( entry.status, entry [ _col ], column_definitions [ _col ] ) );
}
infoBox.add_child ( this.createBin ( entry.status, '', column_definitions [ 'actions' ] ) );
}
}

View File

@ -97,7 +97,7 @@
</key>
<key name="columns-order" type="as">
<default>['host_name+','service_display_name+']</default>
<default>['status+', 'host_name+','service_display_name+']</default>
</key>
</schema>