mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-10 11:36:01 +00:00
[GTK] Improve detecting X11 display server
GdkX11 still imports on Wayland so check display server is X11 before importing.
This commit is contained in:
parent
7a54db3179
commit
a2dee79439
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user