Web lists-archives.com

Re: Upcoming shift to Ayatana (App)Indicator(s)




HI Clément,

On  Fr 06 Apr 2018 16:14:36 CEST, Clément Hermann wrote:

On 29/03/2018 15:11, Mike Gabriel wrote:
[stuff]

Thanks for this summary and your work on this.

### Ayatana AppIndicator API

The Ayatana AppIndicator API is just one way of talking to an SNI DBus
service. The implementation is done in the shared lib
'libayatana-appindicator'. This library provides an easy to implement
API that allows GTK-2/3 applications to create an indicator icon in a
panel with an indicator renderer added.

In the application, the developer creates a generic menu structure and
defines one or more icons for the system tray (more than one icon: only
one icon is shown (plus some text, if needed), but that icon may changed
based on the applet's status). This generic menu is sent to a DBus
interface (org.kde.StatusNotifier). Sometimes, people say, that such
applications have SNI support (StatusNotifier Interface support).

The Ayatana Indicators project offers Ayatana AppIndicator to GTK-3
developers (and GTK-2, but well...). Canonical implemented bindings for
Python2, Perl, GIR, Mono/CLI and we continue to support these as long as
it makes sense.

That sounds interesting. I maintain openpgp-applet [0] (both upstream
and in debian, which is in perl / gtk3 and currently uses the old
fashion systray.

However, I did a quick search, and I couldn't find the bindings for perl
you speak about, be it on CPAN or Launchpad. I probably missed it,
could you share a link ?

There is no direct Perl module, but the libayatana-appindicator shared lib has gir1.2-ayatanaappindicator-0.1. So you should be good when using GIO in Perl, if you are on GTK3 already. (The perl-Gtk2-Appindicator module has indeed been recently removed from Debian to discourage work on appindicator based on GTK2).

The nice part of Ayatana AppIndicator shared library is: if a desktop
shell does not offer the SNI service, then it tries to fall back to the
xembed-way of adding system tray icons to your panel / status bar.

In Debian, we will start sending out patches too SNI supporting
applications soon, that make the shift from Ubuntu AppIndicator (badly
maintained in Debian) to Ayatana AppIndicator. The cool part of this is,
you can convert your GTK-3 application from Ubuntu AppIndicator to
Ayatana AppIndicator and use it on top of any(!) SNI implementation, be
it an applet based on Ubuntu Indicators, based on Ayatana Indicators or
some other implementation, like the vala-sntray-applet or SNI support in
KDE.

I remember reading somewhere that a limitation is that you can only use
one type of click (no way to behave differently on right-click /
left-click), so I guess in some cases the switch means also a new UI,
right ?

Yes. With GTK3 you would implement the Xembed based systray icon with GtkStatusIcon and attach a GtkMenu to that.
This allows left click and right click.

With AppIndicator, you will use the API provided by libayatana-appindicator for creating your systray icon. For now, we have to use Ubuntu's docs (it is on my todo list to port the implementation examples over to the Ayatana Indicators' web site) [1]. Unfortunately, the porting guide has no Perl example, but with GIO this should be easily transferable from e.g. Python code examples.

If you want to provide support for GtkStatusIcon and Ayatana AppIndicator, you may want to study the transmission-gtk code [2] (written in C, though).

You could also drop the GtkStatusIcon based implementation entirely and fully switch over to Ayatana AppIndicator. When doing that, you loose the right-click menu (I must re-check that, if that is really fully true). On desktops that don't provide the StatusNotifierItem interface, your application will fallback to Xembed.

Staying with Xembed-only support is IMHO not recommendable, because e.g. GNOME (and derivatives) are continuously discussing the removal of Xembed support in their desktop env.


Cheers,

[0] https://tracker.debian.org/openpgp-applet, and
   https://openpgp-applet-team.pages.debian.net for the upstream
   project

light+love,
Mike


[1] https://wiki.ubuntu.com/DesktopExperienceTeam/ApplicationIndicators#Porting_Guide_for_Applications
[2] https://sources.debian.org/src/transmission/2.92-3/gtk/tr-icon.c/#L138
--

mike gabriel aka sunweaver (Debian Developer)
mobile: +49 (1520) 1976 148
landline: +49 (4354) 8390 139

GnuPG Fingerprint: 9BFB AEE8 6C0A A5FF BF22  0782 9AF4 6B30 2577 1B31
mail: sunweaver@xxxxxxxxxx, http://sunweavers.net

Attachment: pgpU3tJMkimZu.pgp
Description: Digitale PGP-Signatur