summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2019-06-12 15:44:44 +0100
committerCalum Lind <calumlind+deluge@gmail.com>2019-06-12 16:05:15 +0100
commita2dee79439a6ecc05b36e55eaeb350f90e13e831 (patch)
tree30683f4bb14f0a7ddd0e06267ffd24f390909d34
parent7a54db31792a73c6f63d13916c1f2f42518b8958 (diff)
downloaddeluge-a2dee79439a6ecc05b36e55eaeb350f90e13e831.zip
deluge-a2dee79439a6ecc05b36e55eaeb350f90e13e831.tar.gz
deluge-a2dee79439a6ecc05b36e55eaeb350f90e13e831.tar.bz2
[GTK] Improve detecting X11 display server
GdkX11 still imports on Wayland so check display server is X11 before importing.
-rw-r--r--deluge/ui/gtk3/addtorrentdialog.py12
-rw-r--r--deluge/ui/gtk3/common.py6
-rw-r--r--deluge/ui/gtk3/gtkui.py7
-rw-r--r--deluge/ui/gtk3/mainwindow.py15
4 files changed, 21 insertions, 19 deletions
diff --git a/deluge/ui/gtk3/addtorrentdialog.py b/deluge/ui/gtk3/addtorrentdialog.py
index 169703b..f987c9d 100644
--- a/deluge/ui/gtk3/addtorrentdialog.py
+++ b/deluge/ui/gtk3/addtorrentdialog.py
@@ -34,7 +34,12 @@ from deluge.httpdownloader import download_file
from deluge.ui.client import client
from deluge.ui.common import TorrentInfo
-from .common import get_clipboard_text, listview_replace_treestore, reparent_iter
+from .common import (
+ get_clipboard_text,
+ listview_replace_treestore,
+ reparent_iter,
+ windowing,
+)
from .dialogs import ErrorDialog
from .edittrackersdialog import trackers_tiers_from_text
from .path_chooser import PathChooser
@@ -174,11 +179,8 @@ class AddTorrentDialog(component.Component):
self.dialog.present()
if focus:
timestamp = main_window.get_timestamp()
- try:
+ if windowing('X11'):
self.dialog.get_window().set_user_time(timestamp)
- except AttributeError:
- # Not an X11 windowing system
- pass
def hide(self):
self.dialog.hide()
diff --git a/deluge/ui/gtk3/common.py b/deluge/ui/gtk3/common.py
index 757c3de..8359327 100644
--- a/deluge/ui/gtk3/common.py
+++ b/deluge/ui/gtk3/common.py
@@ -16,7 +16,7 @@ import shutil
import sys
import six.moves.cPickle as pickle # noqa: N813
-from gi.repository.Gdk import SELECTION_CLIPBOARD
+from gi.repository.Gdk import SELECTION_CLIPBOARD, Display
from gi.repository.GdkPixbuf import Colorspace, Pixbuf
from gi.repository.GLib import GError
from gi.repository.Gtk import (
@@ -389,3 +389,7 @@ def get_clipboard_text():
)
if text:
return text.strip()
+
+
+def windowing(like):
+ return like.lower() in str(type(Display.get_default())).lower()
diff --git a/deluge/ui/gtk3/gtkui.py b/deluge/ui/gtk3/gtkui.py
index 73a329f..d93bd2e 100644
--- a/deluge/ui/gtk3/gtkui.py
+++ b/deluge/ui/gtk3/gtkui.py
@@ -22,7 +22,6 @@ gi.require_version('Gtk', '3.0') # NOQA: E402
gi.require_version('Gdk', '3.0') # NOQA: E402
# isort:imports-thirdparty
-from gi.repository.Gdk import Display
from gi.repository.GLib import set_prgname
from gi.repository.Gtk import Builder, ResponseType
from twisted.internet import defer, gtk3reactor
@@ -55,7 +54,7 @@ from deluge.ui.tracker_icons import TrackerIcons
# isort:imports-localfolder
from .addtorrentdialog import AddTorrentDialog
-from .common import associate_magnet_links
+from .common import associate_magnet_links, windowing
from .connectionmanager import ConnectionManager
from .dialogs import YesNoDialog
from .filtertreeview import FilterTreeView
@@ -139,10 +138,6 @@ DEFAULT_PREFS = {
}
-def windowing(like):
- return like.lower() in str(type(Display.get_default())).lower()
-
-
class GtkUI(object):
def __init__(self, args):
# Setup gtkbuilder/glade translation
diff --git a/deluge/ui/gtk3/mainwindow.py b/deluge/ui/gtk3/mainwindow.py
index 92ef91b..2bdc6a9 100644
--- a/deluge/ui/gtk3/mainwindow.py
+++ b/deluge/ui/gtk3/mainwindow.py
@@ -24,17 +24,18 @@ from deluge.common import decode_bytes, fspeed, resource_filename
from deluge.configmanager import ConfigManager
from deluge.ui.client import client
-from .common import get_deluge_icon
+from .common import get_deluge_icon, windowing
from .dialogs import PasswordDialog
from .ipcinterface import process_args
-try:
- from gi.repository import GdkX11
-except ImportError:
- GdkX11 = None
-
+GdkX11 = None
Wnck = None
-if GdkX11:
+if windowing('X11'):
+ try:
+ from gi.repository import GdkX11
+ except ImportError:
+ pass
+
try:
gi.require_version('Wnck', '3.0')
from gi.repository import Wnck