Subject: Bug#989: [X2Go-Dev] Bug#989: pyhoca-gui fails to fall back to Gtk-2.0 notifications (pynotify)

From: Mihai Moldovan <[email-masked]>
Date: Thu, 4 Feb 2016 17:49:23 +0100

On 31.01.2016 09:04 AM, Ondřej Grover wrote:
> I believe commit e44e848415eff3e4dab69e990adfc447e79143f8 which introduced GTK3
> notification support broke GTK2 notification support fallback. The problem was
> not present in 0.5.0.4
> 
> I believe the problem lies in this import construct in
> pyhoca/wxgui/notify.py which will fail the same way even when put alone in a file
> 
> try:
>     from gi.repository import Notify as _Notify
> except ImportError:
>     import pynotify as _Notify
> 
> I think the problem is that even if the GTK3 Notify module is not available,
> many GTK3 libraries get loaded and then the pynotify import fails with 
> 
> ImportError: could not import gobject (could not find _PyGObject_API object)
> 
> This is the same exception I see when running pyhoca-gui.
> 
> I think some more sophisticated GTK version selection mechanism is needed, one
> that would not start loading conflicting libraries.

Thanks for the report. I think your analysis is spot-on.

It looks like a lot of modules from gobject-introspection are loaded, until it
hits an error importing the Notify module.

Then, importing pynotify fails, because the old, static python-gobject module
that pynotify depends on conflicts with the new python-gi
(gobject-introspection) modules.

> As a workaround for now I just removed that GTK3 import on my system.

But it's just that, a workaround.

I've been looking around for a way to actually rollback a failing module import
and came up with zit.

The only "actual" solution I currently see is removing pynotify support
completely, because the gobjects interface is deprecated anyway. However,
that'll break notification support on older systems not having GI/GTK3.

Not that I'd like it, of course. A working fallback would have been great.

Mihai