diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2018-11-17 13:12:35 +0000 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2018-11-17 14:36:38 +0000 |
commit | b2e19561e6cc988f280ad896b3680e81d9a23b28 (patch) | |
tree | 830cdb9c18a1bf7f0f0877a32dac92d26c3d832e | |
parent | 389f4167b25d283f73fbed7375e0fff8fec4c55c (diff) | |
download | deluge-b2e19561e6cc988f280ad896b3680e81d9a23b28.tar.gz deluge-b2e19561e6cc988f280ad896b3680e81d9a23b28.tar.bz2 deluge-b2e19561e6cc988f280ad896b3680e81d9a23b28.zip |
[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
-rw-r--r-- | deluge/common.py | 22 |
1 files 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: |