From b2e19561e6cc988f280ad896b3680e81d9a23b28 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sat, 17 Nov 2018 13:12:35 +0000 Subject: [PATCH] [GTK] Fix file manager window popup behind Deluge Added 'TIMESTAMP' key to startup-id string for dbus method. Unsure if this is the correct way to specify startup id but it seems to work. Recreate the dbus session with each call since if there is an error with the dbus method then it will crash and subsequent calls will fail with a cryptic message: dbus error the name was not provided by any .service files --- deluge/common.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/deluge/common.py b/deluge/common.py index d82970990..d52a26dda 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -53,21 +53,12 @@ if platform.system() in ('Windows', 'Microsoft'): os.environ['SSL_CERT_FILE'] = where() -DBUS_FILEMAN = None # gi makes dbus available on Window but don't import it as unused. if platform.system() not in ('Windows', 'Microsoft', 'Darwin'): try: import dbus except ImportError: - pass - else: - try: - bus = dbus.SessionBus() - DBUS_FILEMAN = bus.get_object( - 'org.freedesktop.FileManager1', '/org/freedesktop/FileManager1' - ) - except dbus.DBusException: - pass + dbus = None log = logging.getLogger(__name__) @@ -352,15 +343,20 @@ def show_file(path, timestamp=None): else: if timestamp is None: timestamp = int(time.time()) - startup_id = '%s_%u_%s-dbus_TIME%d' % ( + startup_id = '%s_%u_%s-dbus_TIME%d TIMESTAMP=%d' % ( os.path.basename(sys.argv[0]), os.getpid(), os.uname()[1], timestamp, + timestamp, ) - if DBUS_FILEMAN: + if dbus: + bus = dbus.SessionBus() + filemanager1 = bus.get_object( + 'org.freedesktop.FileManager1', '/org/freedesktop/FileManager1' + ) paths = [urljoin('file:', pathname2url(path))] - DBUS_FILEMAN.ShowItems( + filemanager1.ShowItems( paths, startup_id, dbus_interface='org.freedesktop.FileManager1' ) else: