Dynamic shortcuts for Messaging Menu?
I'm Unity Mail developer and I wonder if it's possible to add a shortcut to Messaging Menu from within the application (it's written in Python).
I need to connect it's user-display
to a function in the application. For example, this is needed for "Mark all as read" command.
The specification only says about static shortcuts, which are added to .desktop file:
In the
.desktop
file itself, an application may specify shortcut actions that can be invoked regardless of whether the program is running. The syntax of these actions is defined in ApplicationShortcuts.
Yes, though the hand built bindings don't expose it, you'll have to use the GObject Introspected bindings to do it. Unfortunately, there isn't a tutorial that uses those yet.
To do this you'll need to get your IndicateServer and call set_menu on it. Which takes as a parameter the Dbusmenu that you'd like to provide. There are lots of ways to do that, but let me give you some quick pseudo code (as I'm not fluent in Python). Hopefully someone with edit privs that is can help.
menuserver = Dbusmenu.Server("/my/unique/path")
root = Dbusmenu.Menuitem()
menuserver.set_root(root)
first = Dbusmenu.Menuitem()
first.property_set("label", "First")
first.connect("item-activated", call_me_on_click)
root.child_append(first)
second = Dbusmenu.Menuitem()
second.property_set("label", "Second")
root.append_child(second)
indicateserver.set_menu(menuserver)
There are other properties that can be set on menu items to do just about anything you want. You can also build them from GTK menus if that is more comfortable to you using the DbusmenuGtk.parse_menu_structure()
. There is also API Documentation for DbusMenu.