Getting gtk.StatusIcon Position on Windows

I help with Windows support for the PyGTK application, which appears as an applet in the system panel, but I'm not so strong in GTK + gooey stuff ...

We have this, so when you left-click on the systray icon, the window appears directly on your tray icon, no matter where your system tray is located - and on Linux this works fine using the results of gtk.StatusIcon.get_geometry() to calculate the size and position.

Of course, the docs for gtk.StatusIcon.get_geometry () indicate that "some platforms do not provide this information" - and this includes MS Windows, as a result, I get NoneType.

I can make an assumption and place the window in the lower right corner of the screen, 30 pixels up, as this will catch most Windows users who have not moved the taskbar. But for those who have, everything looks wrong.

So, is there a way for Windows to get the position of the systray icon so that I can place my window there?


Please note: I am already using gtk_menu_popup() with gtk_status_icon_position_menu for a popup menu that works correctly.

But what I'm trying to position is a separate gtk.Window that will not accept gtk_status_icon_position_menu (because it is not a menu).

Any other ideas would be appreciated ...

+4
source share
3 answers

Gtk provides the gtk_status_icon_position_menu function, which can be passed to gtk_menu_popup as a GtkPositionFunc. This seems to provide the requested functionality.

+1
source

The behavior I experienced in windows with gtk_status_icon_position_menu was that it spawned a window in the place where the user clicked in statusicon

0
source

I am also looking for an answer to this question, but have found something that might help.

It seems to me that GTK is figuring out where to get PopupMenu from the position of the mouse. Somehow he finds out that the mouse button is pressed over the StatusIcon. Presumably either from mouse events sent by the window system, or because of any knowledge of where StatusIcon is located.

What I get is that GTK must either 1) know the actual location of the StatusIcon, or 2) receive events from the window system when the mouse is clicked on StatusIcon. Therefore, he must know the information.

I also have a popup that I want to pop up next to StatusIcon, and I also have PopupMenu, which works fine. So I tried this, in pygtk:

 x, y, push = gtk.status_icon_position_menu(popup_menu, status_icon) 

I went to PopupMenu to try to find StatusIcon, even if I am not trying to pop up the menu. This makes the position next to StatusIcon, but it is strange that it only works after PopupMenu pops up.

In any case, it brought me closer and helped you or someone to find a complete solution.

0
source

All Articles