summaryrefslogtreecommitdiff
path: root/net-misc/warpinator/files/warpinator-dbus-fallback.patch
blob: f4f4f094447b8610c643614bd3461d7fd0e72df0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
diff -Nur a/src/util.py b/src/util.py
--- a/src/util.py	2024-01-04 17:03:52.000000000 +0000
+++ b/src/util.py	2024-01-14 03:01:42.318649562 +0000
@@ -304,7 +304,7 @@
     # file manager might answer, if more than one is installed:
     # https://github.com/linuxmint/nemo/commit/c9cbba6a2f08be69bf02ffcaf9b0faf4a03ace8b
 
-    bus = Gio.Application.get_default().get_dbus_connection()
+    bus = Gio.Application.get_default().get_dbus_connection() # this is likely to fail
 
     if filename is not None:
         method = "ShowItems"
@@ -316,30 +316,32 @@
     file = Gio.File.new_for_path(abs_path)
     startup_id = str(os.getpid())
 
-    try:
-        bus.call_sync("org.freedesktop.FileManager1",
-                      "/org/freedesktop/FileManager1",
-                      "org.freedesktop.FileManager1",
-                      method,
-                      GLib.Variant("(ass)",
-                                   ([file.get_uri()], startup_id)),
-                      None,
-                      Gio.DBusCallFlags.NONE,
-                      1000,
-                      None)
-        logging.debug("Opening save folder using dbus")
-        return
-    except GLib.Error as e:
-        logging.debug("Could not use dbus interface to launch file manager: %s" % e.message)
-
-    # If dbus doesn't work, use xdg mimetype handlers.
-    app = Gio.AppInfo.get_default_for_type("inode/directory", True)
-
-    try:
-        logging.debug("Opening save folder using Gio (mimetype)")
-        Gio.AppInfo.launch_default_for_uri(prefs.get_save_uri(), None)
-    except GLib.Error as e:
-        logging.critical("Could not open received files location: %s" % e.message)
+    if bus is not None:
+        try:
+            bus.call_sync("org.freedesktop.FileManager1",
+                        "/org/freedesktop/FileManager1",
+                        "org.freedesktop.FileManager1",
+                        method,
+                        GLib.Variant("(ass)",
+                                    ([file.get_uri()], startup_id)),
+                        None,
+                        Gio.DBusCallFlags.NONE,
+                        1000,
+                        None)
+            logging.debug("Opening save folder using dbus")
+            return
+        except GLib.Error as e:
+            logging.debug("Could not use dbus interface to launch file manager: %s" % e.message)
+
+    else:
+        # If dbus doesn't work, use xdg mimetype handlers.
+        app = Gio.AppInfo.get_default_for_type("inode/directory", True)
+
+        try:
+            logging.debug("Opening save folder using Gio (mimetype)")
+            Gio.AppInfo.launch_default_for_uri(prefs.get_save_uri(), None)
+        except GLib.Error as e:
+            logging.critical("Could not open received files location: %s" % e.message)
 
 def verify_save_folder():
     # Forbidden locations for incoming files, relative to home.