[GTK] Only import wnck on X11 display

Wnck is only supported on X11 and raises errors in Wayland so only load
it when X11 present.

Fixes: #3265
This commit is contained in:
Calum Lind 2019-06-12 10:16:32 +01:00
parent 7ee8750be4
commit 03e7952d26
2 changed files with 10 additions and 8 deletions

View File

@ -4,6 +4,7 @@
### Gtk UI
- Fix errors running on Wayland (#3265).
- Fix Peers Tab tooltip and context menu errors (#3266).
### Web UI

View File

@ -13,6 +13,7 @@ import logging
import os.path
from hashlib import sha1 as sha
import gi
from gi.repository import Gtk
from gi.repository.Gdk import DragAction, WindowState
from twisted.internet import reactor
@ -27,19 +28,19 @@ from .common import get_deluge_icon
from .dialogs import PasswordDialog
from .ipcinterface import process_args
try:
import gi
gi.require_version('Wnck', '3.0')
from gi.repository import Wnck
except ValueError:
Wnck = None
try:
from gi.repository import GdkX11
except ImportError:
GdkX11 = None
Wnck = None
if GdkX11:
try:
gi.require_version('Wnck', '3.0')
from gi.repository import Wnck
except (ImportError, ValueError):
pass
log = logging.getLogger(__name__)