Merge lp:~charlesk/indicator-messages/lp-1315384-add-python-example into lp:indicator-messages/13.10

Proposed by Charles Kerr
Status: Merged
Approved by: Lars Karlitski
Approved revision: 411
Merged at revision: 413
Proposed branch: lp:~charlesk/indicator-messages/lp-1315384-add-python-example
Merge into: lp:indicator-messages/13.10
Diff against target: 25 lines (+21/-0)
1 file modified
libmessaging-menu/client-example.py (+21/-0)
To merge this branch: bzr merge lp:~charlesk/indicator-messages/lp-1315384-add-python-example
Reviewer Review Type Date Requested Status
Lars Karlitski (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+221274@code.launchpad.net

Commit message

Add example of using libmessaging-menu from a python client

Description of the change

Add example of using libmessaging-menu from a python client

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Lars Karlitski (larsu) wrote :

Thanks Charles!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'libmessaging-menu/client-example.py'
2--- libmessaging-menu/client-example.py 1970-01-01 00:00:00 +0000
3+++ libmessaging-menu/client-example.py 2014-05-28 16:40:07 +0000
4@@ -0,0 +1,21 @@
5+#!/usr/bin/env python
6+
7+from gi.repository import GLib, Gio, MessagingMenu
8+
9+mmapp = MessagingMenu.App(desktop_id='evolution.desktop')
10+
11+# make the application appear in the messaging menu. The name and icon are taken from the desktop file above
12+mmapp.register()
13+
14+def source_activated(mmapp, source_id):
15+ print('source {} activated'.format(source_id))
16+
17+# do something when the user clicks on a source. The source will be removed automatically
18+mmapp.connect('activate-source', source_activated)
19+
20+# add a 'source' (a menu item below the application's name) with the name 'Inbox' and a count of 7
21+icon = Gio.ThemedIcon.new_with_default_fallbacks('my-source-icon')
22+mmapp.append_source_with_count('inbox', icon, 'Inbox', 7)
23+
24+# this is not necessary for gtk applications, which start a mainloop in gtk_main()
25+GLib.MainLoop().run()

Subscribers

People subscribed via source and target branches