I wrote a PanelMenu.Button-derived class for shell 3.36 by following the tutorial at:
https://wiki.gnome.org/Projects/GnomeShell/Extensions/Writing
Everything works (after a few 3.36-related tweaks I had to do) but now I would like to have a single left click show/hide the application and single right click open the menu. For that I wanted to catch a 'clicked' signal but PanelMenu.Button only emits menu-set
. I'd need something like this:
indicator.connect("clicked", () => GLib.spawn_command_line_async("my_app"));
Is there a widget that supports the 'clicked' signal?
I think looking for a another widget might be more work than it's worth. If you look here at the implementation, they're really just overriding the event
vfunc to open the menu.
vfunc_event(event) {
if (this.menu &&
(event.type() == Clutter.EventType.TOUCH_BEGIN ||
event.type() == Clutter.EventType.BUTTON_PRESS))
this.menu.toggle();
return Clutter.EVENT_PROPAGATE;
}
If you've subclassed yourself and don't need the menu, you can simply do a similar thing just by redefining the virtual function like so (just put this in your subclass like a regular function):
vfunc_event() {
if ((event.type() == Clutter.EventType.TOUCH_BEGIN ||
event.type() == Clutter.EventType.BUTTON_PRESS))
GLib.spawn_command_line_async("my_app");
return Clutter.EVENT_PROPAGATE;
}
However, you may want to change the events to BUTTON_RELEASE
and TOUCH_END
so it happens when the user releases the button, giving them a chance to change their mind by dragging the mouse away.