16

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()

残念ながら、これに関するドキュメントは非常に不完全です。私が探しているのは、AppIndicator メニューがユーザーによって開かれたかどうか (たとえば、インジケーター アイコンがクリックされたかどうか) を確認する方法です。メニューが開かれたときに発せられる信号はありますか?

4

2 に答える 2

8

残念ながら、答えはノーのようです。

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')

私はそれらすべてを試しましたが、インジケーターがクリックされたときにアクティブになるように見えるものはありません。Unity 開発者は、すべてのインジケーターの動作を統一したいと考えているようです。そのため、意図的に制限されている可能性は十分にあります。

于 2011-08-21T03:59:08.093 に答える
2

Launchpad にバグが報告されています https://bugs.launchpad.net/screenlets/+bug/522152

AppIndicator サブメニューで「アクティブ化」シグナルを使用できることに注意してください。

于 2011-10-27T16:55:28.757 に答える