15

Here is a minimal example of an AppIndicator:

#!/usr/bin/python

import gobject
import gtk
import appindicator

if __name__ == "__main__":
    ind = appindicator.Indicator("example-simple-client", "gtk-execute", appindicator.CATEGORY_APPLICATION_STATUS)
    ind.set_status (appindicator.STATUS_ACTIVE)
    menu = gtk.Menu()
    menu_items = gtk.MenuItem('Quit')
    menu.append(menu_items)
    menu_items.connect("activate", gtk.main_quit)
    menu_items.show()
    ind.set_menu(menu)
    gtk.main()

Unfortunately the documentation on this is very incomplete. What I'm looking for is a way to check if the AppIndicator menu was opend by the user (e.g. the indicator icon was clicked). So is there a signal, that is emitted when the menu is opened?

Lex Li
  • 60,503
  • 9
  • 116
  • 147
con-f-use
  • 3,772
  • 5
  • 39
  • 60
  • It may be that the documentation is complete, and that the functionality is just, by design, extremely limited. If you haven't tried already, you should go on Freenode and try to ask the Unity people directly. – dumbmatter Aug 19 '11 at 16:43
  • 1
    It's not incomplete, it was *deliberate*. The *major* motivation for AppIndicator is to have **consistency** and **uniformity** of both looks and **usage**. If people started creating random actions for clicking the icon, or right-clicking it, soon each app will do so in their own custom way, and Indicators will be as messed as Systray was. – MestreLion May 15 '13 at 11:43

2 Answers2

8

It looks like the answer is no unfortunately.

print gobject.signal_list_names(ind)
('new-icon', 'new-attention-icon', 'new-status', 'new-label', 'x-ayatana-new-label', 'connection-changed', 'new-icon-theme-path')

I tried all of them and none of them appear to activate when the indicator is clicked. For what it's worth the unity devs seem to want to keep all indicators behaving in a uniform way, so it's quite possible that it's deliberately limited.

Klohkwherk
  • 279
  • 3
  • 7
  • That's also what documentation says http://developer.ubuntu.com/api/ubuntu-11.04/libappindicator/libappindicator-app-indicator.html#AppIndicator – skrat Aug 26 '11 at 13:33
  • Of course this was deliberate. Consistency and uniformity would be thrown away once you allow apps to create custom actions for right-click, double-click, mouseover, etc. This is a plague in windows and I'm glad it's not allowed in AppIndicator – MestreLion May 15 '13 at 11:46
2

There is a bug filed about it on Launchpad https://bugs.launchpad.net/screenlets/+bug/522152

Notice that "activate" signal is available for AppIndicator submenus.

ramtam
  • 1,638
  • 2
  • 12
  • 5