Tentative popup menu

This commit is contained in:
Benjamin Drieu 2023-03-29 08:29:21 +02:00 committed by Benjamin Drieu
parent 65771792d3
commit 61964a83a4

View File

@ -169,15 +169,23 @@ class Indicator extends PanelMenu.Button {
this._prefsButton = this._createButton ( 'big', 'preferences-system-symbolic', _('Preferences'), this._onPreferencesActivate );
this._buttonMenu.actor.add_child (this._prefsButton);
if ( this.serverLogic && this.serverLogic.canRecheck )
{
this._recheckButton = this._createButton ( 'big', 'mail-send-receive-symbolic', _('Recheck all'), this.recheckAll );
this._buttonMenu.actor.add_child (this._recheckButton );
}
this._reloadButton = this._createButton ( 'big', 'view-refresh-symbolic', _('Reload view'), this.updateStatus );
this._buttonMenu.actor.add_child (this._reloadButton );
if ( this.serverLogic && this.serverLogic.canRecheck )
{
let multiButtonBox = new St.BoxLayout( { style_class: 'monito-multibutton' } );
this._recheckButton = this._createButton ( 'big', 'mail-send-receive-symbolic', _('Recheck all'), this.recheckAll );
this._recheckSpecialButton = this._createPopupButton ( this.recheckSpecial );
multiButtonBox.add_child ( this._recheckButton );
multiButtonBox.add_child ( this._recheckSpecialButton );
this._buttonMenu.actor.add_child (multiButtonBox);
const sourceActor = new St.Widget();
this._menu = new PopupMenu.PopupMenu(sourceActor, 0.0, St.Side.TOP);
const menuItem1 = this._menu.addAction('Item 1', () => console.log('activated'));
}
let _intermediate = new PopupMenu.PopupBaseMenuItem ( {
style_class: 'monito-services',
reactive: false
@ -222,6 +230,11 @@ class Indicator extends PanelMenu.Button {
this.serverLogic.recheckAll ( this._recheckButton );
}
recheckSpecial ( )
{
this._menu.open();
}
changeShowAll ( )
{
this.showAll = ! this.showAll;
@ -694,6 +707,28 @@ class Indicator extends PanelMenu.Button {
return button;
}
_createPopupButton ( callback ) {
let size = 48;
let sizeName = 'big';
let button = new St.Button({
x_align: Clutter.ActorAlign.END,
y_align: Clutter.ActorAlign.CENTER,
reactive: true,
can_focus: true,
track_hover: true,
style_class: 'button %s-button'.format(sizeName),
rotation_angle_x: 0.0,
width: 32,
height: size
});
button.child = PopupMenu.arrowIcon(St.Side.BOTTOM);
button.connect('clicked', Lang.bind(this, callback ) );
return button;
}
});
class Extension {