I'm a student at the Free University of Berlin. I enjoy hacking and messing about with LaTeX.

In case you should whish to contanct me you can do so at carlos@cmartin.tk. To subscribe RSS 2.0 feed

 

Using libindicator-application for fun and profit

After spending two days fighting with DBus, GLib and the several libraries provided by the Ayatana project, I am now confident I know how to proceed implementing support for application indicators and DBus menus in GNOME Shell.

The first thing you have to do is connect to indicator-application-service (the process that). You do this by connecting through the session bus to the onwer of “org.ayatana.indicator.application” with path “/org/ayatana/indicator/application/service” using the interface “org.ayatana.indicator.application.service“.

Now you can know which applications have already connected to the service (or you will as soon as they implement it ;) by calling the “GetApplications” method. This returns an “a(siso)“. That is, an array (list) of structs made out of the following:

  • string: the icon’s name
  • int: the position (I don’t really know what this does)
  • string: the application’s address on the DBus session bus
  • object: this is actually a string with the application’s path on the “org.dbus.dbusmenu” interface

Once you have all this information. You can connect yourself to the “ApplicationAdded” and “ApplicationRemoved” signals. From “ApplicationAdded” you’ll get all the above information, and from “ApplicationRemoved” you get the position (so I guess you can use it as an unique identifier).

You are now ready to talk to the application and request such things as its alert icon, its state (passive, alert), its menu path (again), or its self-chosen id string. You get this information by building a proxy to the “;org.freedesktop.DBus.Properties” interface (again, connecting to the application’s address and the path is still “/need/a/path“) and calling the “Get” method, with the first argument set to “org.ayatana.indicator.application.NotificationItem” to say that you want to use that interface. The second argument is the name of the data you want to get.

Why you can’t simply connect to the “org.ayatana.indicator.application.NotificationItem” interface on the application’s address escapes me, but if I had to guess, I’d say they want to make testing easier.

Whilst this is enough to show the icon on the system tray (sorry, notification area, or whatever), you still need to get the menu from the application and display it. This will be the focus of my next post on this subject (just as soon as I figure out how to do it).

After that, I want to display the menu using clutter actors, which won’t be the easiest thing, I assume.

Tags: , ,

Filed under:gnome, hacking

Leave a Reply