diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2014-06-11 17:22:57 +0000 |
---|---|---|
committer | CI bot <ps-jenkins@lists.canonical.com> | 2014-06-11 17:22:57 +0000 |
commit | 656423a73ae1b87b1f8078da0954e065a8a6668b (patch) | |
tree | 9abf53e11df6f0dbf13f7a363c68dbd6d8c0258b /libmessaging-menu | |
parent | 8322076306609a1f8e0d6ebd03f49af3c74e734c (diff) | |
parent | ae3cdc27d6265c64510dd65d4fc1d246e799379c (diff) | |
download | ayatana-indicator-messages-656423a73ae1b87b1f8078da0954e065a8a6668b.tar.gz ayatana-indicator-messages-656423a73ae1b87b1f8078da0954e065a8a6668b.tar.bz2 ayatana-indicator-messages-656423a73ae1b87b1f8078da0954e065a8a6668b.zip |
Add example of using libmessaging-menu from a python client Fixes: 1315384
Diffstat (limited to 'libmessaging-menu')
-rwxr-xr-x | libmessaging-menu/client-example.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libmessaging-menu/client-example.py b/libmessaging-menu/client-example.py new file mode 100755 index 0000000..76cb326 --- /dev/null +++ b/libmessaging-menu/client-example.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +from gi.repository import GLib, Gio, MessagingMenu + +mmapp = MessagingMenu.App(desktop_id='evolution.desktop') + +# make the application appear in the messaging menu. The name and icon are taken from the desktop file above +mmapp.register() + +def source_activated(mmapp, source_id): + print('source {} activated'.format(source_id)) + +# do something when the user clicks on a source. The source will be removed automatically +mmapp.connect('activate-source', source_activated) + +# add a 'source' (a menu item below the application's name) with the name 'Inbox' and a count of 7 +icon = Gio.ThemedIcon.new_with_default_fallbacks('my-source-icon') +mmapp.append_source_with_count('inbox', icon, 'Inbox', 7) + +# this is not necessary for gtk applications, which start a mainloop in gtk_main() +GLib.MainLoop().run() |