tbursztyka / connman-ui

A full-featured GTK based trayicon UI for ConnMan
GNU General Public License v2.0
38 stars 13 forks source link

Wifi network selection popup is too small when tray icon is on bottom of screen #6

Closed shawnl closed 9 years ago

shawnl commented 10 years ago

this happens when using connman-ui in gnome-shell/gnome 3.

tbursztyka commented 10 years ago

Happens also on KDE4 yes (not in xfce, not in awesome, etc...), depend how the systray is implemented I guess. But, it's a GTK fw issue, how the menu recalculate its size when it gets new items dynamically: I tried the same exact code logic in Qt and it just worked fine everywhere.

Fixing this would mean to implement the size calculation logic in the app itself...

Btw, since you are in gnome3, have you tried the connman extension? (though it does not provide any UI for tweaking the network settings)

The fix would

shawnl commented 10 years ago

The connman gnome extension wouldn't install on my gnome 3.8 (debian sid)-- I don't think its been updated very recently

So i've been using the up-to-date connman that I packaged and have uploaded to mentors.debian.net.

shawnl commented 10 years ago

https://mentors.debian.net/package/connman

for the connmanctl command

tbursztyka commented 10 years ago

Indeed the gnome extension from gnome.org is outdated. Pick up latest from: https://github.com/connectivity/gnome-extension-connman (... which should be uploaded to gnome.org, that would be nice)

shawnl commented 10 years ago

That worked! thanks.

garbas commented 10 years ago

same problem here. would be nice to get this fixed.

lockheed commented 10 years ago

And same here. I did some more testing with stalonetray, trayer and xfce: https://bbs.archlinux.org/viewtopic.php?pid=1387314#p1387314

Is this problem put on a shelf for the moment, or is there work being done on this? It is a pity that such a superb connection manager has no fully functional gui. Why not move to Qt if there are problems with GTK? Especially since it looks like Qt is the future anyway.

tbursztyka commented 10 years ago

I am tempted to move on with Qt indeed. Just need to get time to do so. GTK is getting messy, it's unfortunate but true: there are many complaints about it, and many apps moving to Qt due to it.

I will anyway try to open again (3rd time...) a bug in gtk side.

lockheed commented 10 years ago

Great. Could you post it on pastebin? I think this forum damages the code.

tbursztyka commented 10 years ago

Btw lockheed, you could verify it works with Qt with that script: (I have the same for Gtk, that shows the same bug as in connman-ui also)

#! /usr/bin/env python
from PyQt4 import QtGui, QtCore

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

class ClickMenu(QtGui.QMenu):
    def __init__(self, parent=None):
        QtGui.QMenu.__init__(self, "go-top", parent)
        self._counter = 0

        icon = QtGui.QIcon.fromTheme("application-exit")
        action = QtGui.QAction(icon, "&Exit", self)
        action.triggered.connect(QtGui.qApp.quit)

        self.addAction(action)

        QtCore.QTimer.singleShot(500, self._populate)

    def _populate(self):
        print "populate"

        if (self._counter == len(item_names)):
            return

        icon = QtGui.QIcon.fromTheme("document-new")
        self.addAction(QtGui.QAction(icon, item_names[self._counter], self))

        QtCore.QTimer.singleShot(500, self._populate)
        self._counter += 1

class SystemTrayIcon(QtGui.QSystemTrayIcon):
    def __init__(self, parent=None):
        QtGui.QSystemTrayIcon.__init__(self, parent)

        self.setIcon(QtGui.QIcon.fromTheme("go-home"))
        self.activated.connect(self.click_event)

    def click_event(self, value):
        if value == self.Trigger:
            menu = ClickMenu()
            menu.exec_(QtGui.QCursor.pos())

if __name__ == "__main__":
    app = QtGui.QApplication([])

    tray = SystemTrayIcon()
    tray.show()

    #set the exec loop going
    app.exec_()
lockheed commented 10 years ago

I get this error:

$ connman-qt File "/home/lockheed/bin/connman-qt", line 26 print "populate" ^ SyntaxError: invalid syntax

tbursztyka commented 10 years ago

sorry, forgot to mention it's python 2 only (and did not handle it in the script itself either). run it like: python2.7 pyqttray.py (or any python2.x you have)

lockheed commented 10 years ago

Ok. I get a blank icon: $ python2.7 ~/bin/connman-qt QSystemTrayIcon::setVisible: No Icon set

And if I click on it, it shows "Exit" and then the list slowly populates with what I guess are network names (first one is "test"), but I can't be sure because the tray is on the bottom of the screen and the list populates downwards so it is offscreen

tbursztyka commented 10 years ago

It's a q&d script, I just did it to show that the menu gets re-sized by itself properly. If you see it getting re-sized properly: it means it works. And I bet it will on any tray.

lockheed commented 10 years ago

Yes, it resizes properly, growing with the number of networks detected. Do you think you could implement it into connman-ui? I'm happy to test things for you if you need it.

tbursztyka commented 10 years ago

It would mean recoding connman-ui in Qt.

If you want to try the Gtk based one: (right click to show the menu, left one to exit) It will show the bug on some tray, as for connman-ui.

#!/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()
lockheed commented 10 years ago

It starts, but the menu appears behind the tray, so it is cover, and I think it also grows downwards, because I can only see the top edge of it.

tbursztyka commented 10 years ago

Yes it's bogus, and it's in Gtk framework. It's up to it to know where/how to show the menu properly. Qt does it just fine, not Gtk.

djvs commented 9 years ago

Did you consider pre-populating it with, say, a dozen blank/bogus items, then dynamically removing and repopulating it?

tbursztyka commented 9 years ago

Actually, I have seen such patch already done somewhere (but not on github). Pre-alocating 10 empty items and polulating the informations once the results come. But then, if scan results reports - let's say - 2 services: you will have a menu of 8 items, with 2 labelled-services and 8 empty entries. It's a bit ugly. The only real fix is in Gtk+.

djvs commented 9 years ago

Would recommend Qt for a port then. A Supports very rapid development, less clunky than gtk On Dec 1, 2014 2:44 AM, "Tomasz Bursztyka" notifications@github.com wrote:

Actually, I have seen such patch already done somewhere (but not on github). Pre-alocating 10 empty items and polulating the informations once the results come. But then, if scan results reports - let's say - 2 services: you will have a menu of 8 items, with 2 labelled-services and 8 empty entries. It's a bit ugly. The only real fix is in Gtk+.

— Reply to this email directly or view it on GitHub https://github.com/tbursztyka/connman-ui/issues/6#issuecomment-65029888.

mrunion commented 9 years ago

I have no new information to add, but wanted to echo "me too". I use Arch Linux, latest updates (no TESTING repo), Openbox, compton and nVidia driver (if any of that matters.) The QT-based cmst GUI works, though.

timothytylee commented 9 years ago

After the merge of #18, the left popup menu now calculates its own height. Issue should be fixed.