From 769aaf1ae34febc4067e927d9819ace802ea5c8e Mon Sep 17 00:00:00 2001 From: Matt Rose Date: Fri, 17 Apr 2020 12:50:46 -0400 Subject: [PATCH] only import the GdkX11 if it is part of the glib module repository --- terminatorlib/terminator.py | 8 +++++++- terminatorlib/window.py | 10 ++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py index 8e8e28d0..81523dcf 100644 --- a/terminatorlib/terminator.py +++ b/terminatorlib/terminator.py @@ -6,7 +6,7 @@ import copy import os import gi gi.require_version('Vte', '2.91') -from gi.repository import Gtk, Gdk, Vte, GdkX11 +from gi.repository import Gtk, Gdk, Vte from gi.repository.GLib import GError from . import borg @@ -18,6 +18,12 @@ from .factory import Factory from .cwd import get_pid_cwd from .version import APP_NAME, APP_VERSION +try: + from gi.repository import GdkX11 +except ImportError: + dbg("could not import X11 gir module") + + def eventkey2gdkevent(eventkey): # FIXME FOR GTK3: is there a simpler way of casting from specific EventKey to generic (union) GdkEvent? gdkevent = Gdk.Event.new(eventkey.type) gdkevent.key.window = eventkey.window diff --git a/terminatorlib/window.py b/terminatorlib/window.py index 117b1667..fb01845a 100644 --- a/terminatorlib/window.py +++ b/terminatorlib/window.py @@ -7,16 +7,22 @@ import time import uuid import gi from gi.repository import GObject -from gi.repository import Gtk, Gdk, GdkX11 +from gi.repository import Gtk, Gdk from .util import dbg, err, make_uuid, display_manager + +try: + from gi.repository import GdkX11 +except ImportError: + dbg("could not import X11 gir module") + + from . import util from .translation import _ from .version import APP_NAME from .container import Container from .factory import Factory from .terminator import Terminator - if display_manager() == 'X11': try: gi.require_version('Keybinder', '3.0')