Technical discussions | Discussions techniques
Subscription date : 28 October 2009
Messages : 415
|
Hello,
I'm working on applets and it would be great to have a menu widget on left-click. Is that possible? Is there a Python binding for it too?
PS: i mean a menu other than the current right-click menu available, i.e. I'd like a new, blank one.
Thanks  |
fabounet, Tuesday 16 August 2011 à 13:05
|
|
Subscription date : 30 November 2007
Messages : 17118
|
you can do a gtk-menu in python, and place it at the mouse position.
although it might look a bit weird because all the other menus are placed above the icon.
if it's not a good solution, we might think of something more sophisticated with dbusmenu. |
Subscription date : 28 October 2009
Messages : 415
|
Option 1 would be OK if you give me the means to get the icon's position instead.
Option 2 would definitely expand possibilities though. |
fabounet, Tuesday 16 August 2011 à 16:16
|
|
Subscription date : 28 October 2009
Messages : 415
|
hi there,
I've got some difficulties implementing a pop-up menu, because of the API (which i don't understand completely to be honest).
A GTK Menu needs some data to pop up. Usually it needs data from the event, but in the case of the API how do I get the event? I have the iState, but all it returns is "256".
So I've defined a class:
class Menu(gtk.Menu):
def __init__(self):
gtk.Menu.__init__(self)
menu_item = gtk.MenuItem('test')
self.append(menu_item)
menu_item.show()
self.show()
And in the applet's main file:
def on_click(self, iState):
menu = Menu()
menu.popup()
Now some arguments should be passed in there, the first two can be "None". The third and fourth are for the menu placement. Another example shows that one can pass "None" as a third argument and ignore the fourth. 5th and 6th should be event.button and event.time respectively.
So how can I get the event data from the API?
Could I later one use the third and fourth arguments to locate the menu above the icon you think?
Cheers,
B. |
fabounet, Wednesday 24 August 2011 à 13:17
|
|
Subscription date : 30 November 2007
Messages : 17118
|
I think you can safely ignore all the arguments, (None for placement means under the mouse, and you can set the button and time to 0) |
Subscription date : 28 October 2009
Messages : 415
|
OK I've got it, now I need to place it above the icon thanks.
PS: i'd like to theme the menu, but that would be applet-centric. We once spoke of theming the menus globally. Did anything happen since then?
Otherwise, could it be done with a .rc file? |
fabounet, Thursday 25 August 2011 à 16:53
|
|
Subscription date : 30 November 2007
Messages : 17118
|
you can, but that's not a good idea to make it different from the rest of the dock.
it's possible to change it though, but I forgot the GTK functions to do that. |
Subscription date : 28 October 2009
Messages : 415
|
Heya,
i agree it's better to have it globally as an option. Will that be difficult to implement you think? Suppose I try to figure out how to make some menu theme, would you try implement it?
Also: i'm almost done with implementing a left-click menu for Gmail inbox. Now can I make the dock freeze while the menu's open as with right-click menu? Preferably without using Dbus.
Thanks.
B. |
Subscription date : 30 November 2007
Messages : 17118
|
yep, actually I've done it for widgets inside the dialogs, but not for menus.
I think you have already found how to do (seeing your latest gmail applet screenshot ), and it's probably straightforward to port it in C.
so ok to add it as an option in the config (in the Dialogs options for instance)  |
Technical discussions | Discussions techniques
|