lookingGlass: Turn toolbar icons into actual buttons
Yes, we can use reactive icons with a `button-press-event` handler, but really, there's a standard control for that kind of behavior ... Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2156>
This commit is contained in:
parent
543ec6a0d3
commit
a92f749daf
@ -1264,11 +1264,15 @@ class LookingGlass extends St.BoxLayout {
|
|||||||
|
|
||||||
let toolbar = new St.BoxLayout({ name: 'Toolbar' });
|
let toolbar = new St.BoxLayout({ name: 'Toolbar' });
|
||||||
this.add_actor(toolbar);
|
this.add_actor(toolbar);
|
||||||
let inspectIcon = new St.Icon({ icon_name: 'find-location-symbolic',
|
const inspectButton = new St.Button({
|
||||||
icon_size: 24 });
|
style_class: 'lg-toolbar-button',
|
||||||
toolbar.add_actor(inspectIcon);
|
child: new St.Icon({
|
||||||
inspectIcon.reactive = true;
|
icon_name: 'find-location-symbolic',
|
||||||
inspectIcon.connect('button-press-event', () => {
|
icon_size: 24,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
toolbar.add_actor(inspectButton);
|
||||||
|
inspectButton.connect('clicked', () => {
|
||||||
let inspector = new Inspector(this);
|
let inspector = new Inspector(this);
|
||||||
inspector.connect('target', (i, target, stageX, stageY) => {
|
inspector.connect('target', (i, target, stageX, stageY) => {
|
||||||
this._pushResult('inspect(%d, %d)'.format(Math.round(stageX), Math.round(stageY)), target);
|
this._pushResult('inspect(%d, %d)'.format(Math.round(stageX), Math.round(stageY)), target);
|
||||||
@ -1281,21 +1285,25 @@ class LookingGlass extends St.BoxLayout {
|
|||||||
return Clutter.EVENT_STOP;
|
return Clutter.EVENT_STOP;
|
||||||
});
|
});
|
||||||
|
|
||||||
let gcIcon = new St.Icon({ icon_name: 'user-trash-full-symbolic',
|
const gcButton = new St.Button({
|
||||||
icon_size: 24 });
|
style_class: 'lg-toolbar-button',
|
||||||
toolbar.add_actor(gcIcon);
|
child: new St.Icon({
|
||||||
gcIcon.reactive = true;
|
icon_name: 'user-trash-full-symbolic',
|
||||||
gcIcon.connect('button-press-event', () => {
|
icon_size: 24,
|
||||||
gcIcon.icon_name = 'user-trash-symbolic';
|
}),
|
||||||
|
});
|
||||||
|
toolbar.add_actor(gcButton);
|
||||||
|
gcButton.connect('clicked', () => {
|
||||||
|
gcButton.child.icon_name = 'user-trash-symbolic';
|
||||||
System.gc();
|
System.gc();
|
||||||
this._timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 500, () => {
|
this._timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 500, () => {
|
||||||
gcIcon.icon_name = 'user-trash-full-symbolic';
|
gcButton.child.icon_name = 'user-trash-full-symbolic';
|
||||||
this._timeoutId = 0;
|
this._timeoutId = 0;
|
||||||
return GLib.SOURCE_REMOVE;
|
return GLib.SOURCE_REMOVE;
|
||||||
});
|
});
|
||||||
GLib.Source.set_name_by_id(
|
GLib.Source.set_name_by_id(
|
||||||
this._timeoutId,
|
this._timeoutId,
|
||||||
'[gnome-shell] gcIcon.icon_name = \'user-trash-full-symbolic\''
|
'[gnome-shell] gcButton.child.icon_name = \'user-trash-full-symbolic\''
|
||||||
);
|
);
|
||||||
return Clutter.EVENT_PROPAGATE;
|
return Clutter.EVENT_PROPAGATE;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user