GNOME Bugzilla – Bug 779153
Python cannot create NMGtkWifiDialog
Last modified: 2017-03-09 16:47:46 UTC
Python, using pygobject, is unable to spawn an NMGtkWifiDialog using the new function, due to the SSID setting not being settable (GArray<guchar> is not supported by pygobject). If the SSID is not set, the dialog will not display correctly, and will not function. A potential fix is to copy the SSID from the AP information if present.
Created attachment 346610 [details] Here is a test script. Edit IFACE and AP_NAME to match your computer.
Created attachment 346611 [details] [review] Here is a patch, copying the SSID information from the provided AP.
libnm-gtk is deprecated. What is the reason not to use libnma (and NMAWifiDialog)?
I will try again. It was hanging Python when attempting to run the example above.
(In reply to Thomas Haller from comment #3) > libnm-gtk is deprecated. > > What is the reason not to use libnma (and NMAWifiDialog)? If I were to move this code into libnma, would that make sense? To copy the AP's SSID if it is provided?
I agree that there is a problem using libnm-glib/libnm-gtk. I was unable to make use of the opaque gobject.GBoxed type. The libnm based library (libnma) doesn't have this problem. To me, it seems wrong that nma_wifi_dialog_new() modifies the provided connection. I would instead fix libnm-glib/libnm-util so that the SSID can be set from pygobject. Nowadays, libnm-util+libnm-glib+libnm-gtk is deprecated and replaced by libnm+libnma. That means, there is less incentive to fix libnm-glib, but it is not out of the question.
Created attachment 347348 [details] Here is a test script, demonstrating a hang with libnma. Edit IFACE and AP_NAME to something you can connect to.
(In reply to Jeremy Soller from comment #7) > Created attachment 347348 [details] > Here is a test script, demonstrating a hang with libnma. Edit IFACE and > AP_NAME to something you can connect to. The script fails with: (nma.py:7254): libnm-ERROR **: libnm-util symbols detected; Mixing libnm with libnm-util/libnm-glib is not supported A process cannot load libnm-util/libnm-glib/libnm-gtk at the same time as libnm/libnma. You must replace gi.require_version('NetworkManager', '1.0') from gi.repository import NetworkManager gi.require_version('NMClient', '1.0') from gi.repository import NMClient with gi.require_version('NM', '1.0') from gi.repository import NM (and then your script needs some fixing. For example: - client = NMClient.Client() + client = NM.Client.new(None) But even then, there is a bug that I just fixed: https://git.gnome.org/browse/network-manager-applet/commit/?id=7a59d41e5f6666d0da51f1f7aae7518befdb1182 Too bad, the pygobject binds for libnma were broken. Obviously, nobody was using them so far.
I applied that patch and will attempt to use libnma again.
Created attachment 347399 [details] After applying your patch to the GIR, this script works with libnma. Can you release a new network-manager-applet with that change?
(In reply to Jeremy Soller from comment #10) > Can you > release a new network-manager-applet with that change? a new release of network-manager-applet was done just yesterday. It may take one, two months until the next release is due. Downstream is encouraged to cherry-pick the patch.
re: comment 10. User code cannot create a connection = NM.RemoteConnection() should be connection = NM.SimpleConnection()
Ok, I will change that
This can now be fixed by using `libnma`, so I will mark this as resolved