Wednesday, May 1, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 416  / 1 Year ago, fri, december 30, 2022, 7:48:15

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.



More From » indicator

 Answers
4

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.


[#43509] Saturday, December 31, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
gliroopy

Total Points: 290
Total Questions: 115
Total Answers: 114

Location: Egypt
Member since Tue, May 3, 2022
2 Years ago
;