mate-desktop / mate-indicator-applet

http://www.mate-desktop.org
GNU General Public License v3.0
19 stars 15 forks source link

Add indicator object signal: secondary-activate / INDICATOR_OBJECT_SIGNAL_SECONDARY_ACTIVATE #42

Closed geki-yaba closed 3 years ago

geki-yaba commented 5 years ago

Expected behaviour

Mouse middle-click on indicator does emit signal "secondary-activate" for the ayatana indicator stack back to the application to handle the event.

Have code very similar to INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED.

Actual behaviour

Nothing happens.

References

https://github.com/AyatanaIndicators/libayatana-indicator/blob/master/libayatana-indicator/indicator-object.h#L60

https://github.com/AyatanaIndicators/libayatana-indicator/commits/master/libayatana-indicator/indicator-object.h

Steps to reproduce the behaviour

Python with AyatanaAppIncidator3. See API:

https://lazka.github.io/pgi-docs/AyatanaAppIndicator3-0.1/classes/Indicator.html#AyatanaAppIndicator3.Indicator.set_secondary_activate_target

MATE general version

1.20

Package version

1.20.1

Linux Distribution

Devuan (Debian based)

geki-yaba commented 5 years ago

As a reference implementation, see xfce_indicator_button_button_release at https://github.com/xfce-mirror/xfce4-indicator-plugin/blob/master/panel-plugin/indicator-button.c#L341

geki-yaba commented 5 years ago

As a help, AFAIS add the gtkbox into a gtkeventbox container and set event mask GDK_BUTTON_RELEASE_MASK and connect "button-release-event" to event box.

geki-yaba commented 5 years ago

And an untested patch attached. secondary-activate.patch.txt

UPDATE v2 Actually test for middle-button on event. secondary-activate_v2.patch.txt

UPDATE v3 Pass menuitem as data to callback. secondary-activate_v3.patch.txt

geki-yaba commented 5 years ago

If anyone is able to build a v1.20 package for debian buster, I could test it.

geki-yaba commented 5 years ago

To complete the report, here is some info about the application to test:

Based on MiyoLinux' pygtk2 update notifier as seen on Devuan forum[0], I did a python3/AyatanaAppIndicator3 update notifier[1]. Packaged for now on my website with cron jobs[2].

There is a gio script for notification reports only and the gtk script with an indicator.

That indicator should be hidden with the users middle-button released event passed as secondary-activate through the ayatana indicator stack. As does the xfce-indicator-plugin.

[0] https://dev1galaxy.org/viewtopic.php?id=2641 [1] https://dev1galaxy.org/viewtopic.php?pid=15571#p15571 [2] https://geki.selfhost.eu/files/update-notifier-py3.tar.xz

tar tvJf update-notifier-py3.tar.xz

-rw-r--r-- root/root 46 2019-03-25 20:14 etc/cron.d/update_notifier -rwxr-xr-x root/root 171 2019-03-24 10:21 etc/cron.hourly/update_notifier drwxr-xr-x root/root 0 2019-04-18 22:23 usr/share/update-notifier/ -rwxr-xr-x root/root 535 2019-02-06 19:12 usr/share/update-notifier/updates.svg -rwxr-xr-x root/root 4679 2019-04-18 22:23 usr/share/update-notifier/update-notifier-gtk.py -rwxr-xr-x root/root 2668 2019-04-16 22:50 usr/share/update-notifier/update-notifier-gio.py

geki-yaba commented 5 years ago

Finally could test thanks to Debian developer. It works just out-of-the-box with the menuitem. Though, I have to double-click the middle-button to receive the "button-release-event". Anyone any ideas?

The Gtk docs say that the grab widget receives the signal. https://developer.gnome.org/gtk3/stable/GtkWidget.html#GtkWidget-button-release-event

1001_secondary-activate.patch.txt

geki-yaba commented 5 years ago

A ha, to workaround the menuitem acting as button, it seems to be necessary to explicitely set the focus on "button-press-event" in case of middle-button pressed to signal secondary-activate on single-click "button-release-event" already. See: https://stackoverflow.com/questions/16459886/is-it-possible-for-a-gtk-menu-item-to-act-like-a-button-and-throw-a-signal-for-a

Well, to implement that is an exercise for the reader.

geki-yaba commented 5 years ago

Here is the final patch: 1001_secondary-activate.patch.txt

Here is the python indicator app for ayatana service: https://github.com/geki-yaba/ayatana-indicator-updatenotifier/releases