After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 673396 - X11Screen must be imported before getting the default screen in order to call get_window_manager_name()
X11Screen must be imported before getting the default screen in order to call...
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2012-04-03 02:16 UTC by Joanmarie Diggs (IRC: joanie)
Modified: 2015-11-14 09:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Try to import GdkX11 in Gdk overrides (1.26 KB, patch)
2015-10-04 09:28 UTC, Christoph Reiter (lazka)
committed Details | Review

Description Joanmarie Diggs (IRC: joanie) 2012-04-03 02:16:04 UTC
To call gdk_x11_screen_get_window_manager_name(), you must not only import X11Screen even though you have an X11Screen object (see 1), but you must also do so before getting the default screen (see 3). The former is no big deal; the latter is a bit of a drag.

============= 1 =============

$ python
>>> from gi.repository import Gdk
>>> display = Gdk.Display.get_default()
>>> screen = display.get_default_screen()
>>> screen.get_window_manager_name()

Traceback (most recent call last):
  • File "<stdin>", line 1 in <module>
AttributeError: 'gtk.gdk.X11Screen' object has no attribute 'get_window_manager_name'

============= 2 =============

$ python
>>> from gi.repository import Gdk
>>> from gi.repository.GdkX11 import X11Screen
>>> display = Gdk.Display.get_default()
>>> screen = display.get_default_screen()
>>> screen.get_window_manager_name()

'Mutter'

============= 3 =============

$ python
>>> from gi.repository import Gdk
>>> display = Gdk.Display.get_default()
>>> screen = display.get_default_screen()
>>> from gi.repository.GdkX11 import X11Screen
>>> screen.get_window_manager_name()

Traceback (most recent call last):
  • File "<stdin>", line 1 in <module>
AttributeError: 'gtk.gdk.X11Screen' object has no attribute 'get_window_manager_name'

Comment 1 Martin Pitt 2012-04-20 07:45:08 UTC
Confirming with GNOME 3.4.

Note that it is sufficient to do "from gi.repository import GdkX11", which will do the necessary initialization.

This has some resemblence to bug 656314, but it is still different because the Gdk typelib does not depend on the GdkX11 one.

I don't have an off-hand idea how to fix this, though.
Comment 2 johnp 2012-04-23 16:06:25 UTC
We've run into this before.  It is sort of like C headers.  If you don't import it the runtime doesn't know about it so you kind of get screwed.

First fix is to print out a warning if an unknown object is returned.

Second fix is to have glib somehow tell you which lib was returned and load the gi information if it hasn't already.  GLib should be able to do this if it is actually an object and not just a struct.

A hack would be to have a arch dependent override that understood which gi libs to load when importing Gdk.  This of course does not work for gstreamer which will give you interfaces to underlying objects where sometimes you wish to manipulate the underlying object.  Might be worth it for Gdk though.
Comment 3 Martin Pitt 2013-02-27 15:11:25 UTC

*** This bug has been marked as a duplicate of bug 656314 ***
Comment 4 Christoph Reiter (lazka) 2015-10-04 08:41:43 UTC
Reopening, since as stated above loading the dependencies as proposed in bug 656314 wont fix this.

We could just try to import GdkX11 in the Gdk overrides. Seems like the easiest fix.

Or maybe make GdkX11 a typelib dependency on supported platforms in GTK+? This would also fix it after bug 656314 gets fixed.
Comment 5 Christoph Reiter (lazka) 2015-10-04 09:28:37 UTC
Created attachment 312622 [details] [review]
Try to import GdkX11 in Gdk overrides

pygobject will not provide GdkX11 instances until the namespace
is loaded so try to load it in the overrides.

This makes Gdk.Display.get_default() return a GdkX11.X11Display
instead of a dummy Gdk.Display subclass instance.
Comment 6 Simon Feltman 2015-10-25 19:18:25 UTC
Review of attachment 312622 [details] [review]:

This may be a stupid question as it is a bit out of my knowledge base, but are there any side effects of doing this on a system where something like wayland is being used but an X11 fallback is available?
Comment 7 Christoph Reiter (lazka) 2015-10-26 08:20:56 UTC
(In reply to Simon Feltman from comment #6)
> Review of attachment 312622 [details] [review] [review]:
> 
> This may be a stupid question as it is a bit out of my knowledge base, but
> are there any side effects of doing this on a system where something like
> wayland is being used but an X11 fallback is available?

Afaics loading GdkX11 will just load the typelib which like Gdk-3.0 depends on libgdk-3.so.0. It's just some gi information split out in a separate typelib.
Comment 8 Christoph Reiter (lazka) 2015-11-14 09:00:49 UTC
Pushed to master: https://git.gnome.org/browse/pygobject/commit/?id=6a26d3f2b25b3fbbd87def14f1df17b96ed23a0d