libmessaging-menu already comes with python bindings through gobject-introspection. Unfortunately the online documentation seems to have been taken down. The libmessaging-menu-dev package contains the C documentation (viewable with devhelp), which maps 1:1 to the python API.
Here's a simple example:
from gi.repository import GLib, Gio, MessagingMenu
# 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()
libmessaging-menu already comes with python bindings through gobject- introspection. Unfortunately the online documentation seems to have been taken down. The libmessaging- menu-dev package contains the C documentation (viewable with devhelp), which maps 1:1 to the python API.
Here's a simple example:
from gi.repository import GLib, Gio, MessagingMenu
mmapp = MessagingMenu. App(desktop_ id='my- app.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): .format( source_ id))
print('source {} activated'
# do something when the user clicks on a source. The source will be removed automatically 'activate- source' , source_activated)
mmapp.connect(
# add a 'source' (a menu item below the application's name) with the name 'Inbox' and a count of 7 new_with_ default_ fallbacks( 'my-source- icon') source_ with_count( 'inbox' , icon, 'Inbox', 7)
icon = Gio.ThemedIcon.
mmapp.append_
# this is not necessary for gtk applications, which start a mainloop in gtk_main() ).run()
GLib.MainLoop(