systray menu cannot expand dynamically



Hi,

I already posted a while ago the same trouble, but still no definitive answer. I work with Gtk3, I did not tried that on Gtk2.

There is actually a behavior "bug" on systray menu in Gnome3 and KDE4. Only those, all other WMs/DMs are working properly.
I opened a bug for each, no answers yet.

In short: if a menugets dynamically fed with menuitem, the menu does not get resized, thus it's impossible to see the items.


Here is a trivial script that can reproduce easily the issue:

---- CUT HERE ----
#!/usr/bin/python

from gi.repository.Gtk import StatusIcon, STOCK_HOME, Menu, \
MenuItem, main, main_quit
from gi.repository.GObject import timeout_add, source_remove

item_names = [ "test",
                "the",
                "dynamic",
                "status icon",
                "menu",
                "popup",
                "!"]

class TestTray( object ):
    def __init__(self):
        self._statusicon = StatusIcon()
self._statusicon.set_from_stock(STOCK_HOME)
self._statusicon.connect("popup-menu", self.right_click_event)
self._statusicon.connect("activate", main_quit)

        self._counter = 0;

        self._menu = Menu()

    def _populate_menu(self, _):
        if (self._counter == len(item_names)):
            return True

        item = MenuItem(item_names[self._counter])

        item.show()
        self._menu.append(item)

        self._counter += 1

        return True

    def right_click_event(self, s_icon, button, time):
        def position(menu, s_icon):
            return StatusIcon.position_menu(menu, s_icon)

        timeout_add(500, self._populate_menu, None)

        self._menu.popup(None, None, position, s_icon, button, time)

if __name__ == "__main__":
    statusicon = TestTray()
    main()

---- CUT HERE ----


What could affect Gtk not to beable to resize properly the menu?
How could it be fixed? Or is it a bug in the systray implementation in Gnome3/KDE4?

I haven't been able to track down the issue in Gtk3 sources.
At least I could somehow loosely "fix" it in recalculating myself the menu size and requesting it again.
But of course it's ugly and should not be done.


Thanks,

Tomasz



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]