aboutsummaryrefslogtreecommitdiff
path: root/libmessaging-menu
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-05-28 18:38:39 +0200
committerCharles Kerr <charles.kerr@canonical.com>2014-05-28 18:38:39 +0200
commitae3cdc27d6265c64510dd65d4fc1d246e799379c (patch)
tree00955f0751a6e46e8c38689ff55241e1f033077b /libmessaging-menu
parent79b77a977e27c53556ae8bed46c8c43e68608497 (diff)
downloadayatana-indicator-messages-ae3cdc27d6265c64510dd65d4fc1d246e799379c.tar.gz
ayatana-indicator-messages-ae3cdc27d6265c64510dd65d4fc1d246e799379c.tar.bz2
ayatana-indicator-messages-ae3cdc27d6265c64510dd65d4fc1d246e799379c.zip
Add an example for client usage from a python script.
Diffstat (limited to 'libmessaging-menu')
-rwxr-xr-xlibmessaging-menu/client-example.py21
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()