|
| 1 | +From 8d36fce61821c28ce5c051e3d2558ca778bea0eb Mon Sep 17 00:00:00 2001 |
| 2 | +From: =?UTF-8?q?Tau=20G=C3=A4rtli?= <git@tau.garden> |
| 3 | +Date: Mon, 24 Nov 2025 22:33:17 +0100 |
| 4 | +Subject: [PATCH 1/2] Accept activation token in `ShowFile` |
| 5 | + |
| 6 | +Passes an activation token when calling sushi over |
| 7 | +D-Bus which makes it work properly with mutter's |
| 8 | +'strict' focus mode. |
| 9 | + |
| 10 | +Depends on https://gitlab.gnome.org/GNOME/nautilus/-/merge_requests/1885 |
| 11 | +Part of https://gitlab.gnome.org/GNOME/nautilus/-/issues/4058 |
| 12 | +--- |
| 13 | + src/org.gnome.NautilusPreviewer2.xml | 1 + |
| 14 | + src/ui/application.js | 11 ++++++++--- |
| 15 | + 2 files changed, 9 insertions(+), 3 deletions(-) |
| 16 | + |
| 17 | +diff --git a/src/org.gnome.NautilusPreviewer2.xml b/src/org.gnome.NautilusPreviewer2.xml |
| 18 | +index faa8c58..4ff218b 100644 |
| 19 | +--- a/src/org.gnome.NautilusPreviewer2.xml |
| 20 | ++++ b/src/org.gnome.NautilusPreviewer2.xml |
| 21 | +@@ -4,6 +4,7 @@ |
| 22 | + <arg type="s" direction="in" name="uri" /> |
| 23 | + <arg type="s" direction="in" name="windowHandle" /> |
| 24 | + <arg type="b" direction="in" name="closeIfAlreadyShown" /> |
| 25 | ++ <arg type="s" direction="in" name="activationToken" /> |
| 26 | + </method> |
| 27 | + <method name="Close"> |
| 28 | + </method> |
| 29 | +diff --git a/src/ui/application.js b/src/ui/application.js |
| 30 | +index e019e7a..ac0ddfd 100644 |
| 31 | +--- a/src/ui/application.js |
| 32 | ++++ b/src/ui/application.js |
| 33 | +@@ -76,8 +76,9 @@ var NautilusPreviewer2Skeleton = class extends NautilusPreviewerSkeleton { |
| 34 | + super(application, '/org/gnome/NautilusPreviewer/org.gnome.NautilusPreviewer2.xml'); |
| 35 | + } |
| 36 | + |
| 37 | +- ShowFile(uri, windowHandle, closeIfAlreadyShown) { |
| 38 | +- this.application.showFile(uri, windowHandle, closeIfAlreadyShown); |
| 39 | ++ ShowFile(uri, windowHandle, closeIfAlreadyShown, activationToken) { |
| 40 | ++ this.application.showFile( |
| 41 | ++ uri, windowHandle, closeIfAlreadyShown, activationToken); |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | +@@ -148,9 +149,13 @@ var Application = GObject.registerClass(class Application extends Gtk.Applicatio |
| 46 | + 'ParentHandle', new GLib.Variant('s', handle)); |
| 47 | + } |
| 48 | + |
| 49 | +- showFile(uri, windowHandle, closeIfAlreadyShown) { |
| 50 | ++ showFile(uri, windowHandle, closeIfAlreadyShown, activationToken = "") { |
| 51 | + this._ensureMainWindow(); |
| 52 | + |
| 53 | ++ if (activationToken) { |
| 54 | ++ this._mainWindow.set_startup_id(activationToken); |
| 55 | ++ } |
| 56 | ++ |
| 57 | + let file = Gio.file_new_for_uri(uri); |
| 58 | + if (closeIfAlreadyShown && |
| 59 | + this._mainWindow.file && |
| 60 | +-- |
| 61 | +GitLab |
| 62 | + |
| 63 | + |
| 64 | +From 4a7449ecdde60b0d3851b03d37447db769933e36 Mon Sep 17 00:00:00 2001 |
| 65 | +From: =?UTF-8?q?Tau=20G=C3=A4rtli?= <git@tau.garden> |
| 66 | +Date: Tue, 2 Dec 2025 17:13:33 +0100 |
| 67 | +Subject: [PATCH 2/2] Remove org.gnome.NautilusPreviewer interface |
| 68 | + |
| 69 | +Since the interface is only used by nautilus |
| 70 | +it can now be safely removed. |
| 71 | +--- |
| 72 | + ...org.gnome.NautilusPreviewer.data.gresource.xml | 1 - |
| 73 | + src/org.gnome.NautilusPreviewer.xml | 11 ----------- |
| 74 | + src/sushi.in | 8 ++++++-- |
| 75 | + src/ui/application.js | 15 --------------- |
| 76 | + 4 files changed, 6 insertions(+), 29 deletions(-) |
| 77 | + delete mode 100644 src/org.gnome.NautilusPreviewer.xml |
| 78 | + |
| 79 | +diff --git a/src/org.gnome.NautilusPreviewer.data.gresource.xml b/src/org.gnome.NautilusPreviewer.data.gresource.xml |
| 80 | +index 134eec3..9682d40 100644 |
| 81 | +--- a/src/org.gnome.NautilusPreviewer.data.gresource.xml |
| 82 | ++++ b/src/org.gnome.NautilusPreviewer.data.gresource.xml |
| 83 | +@@ -1,7 +1,6 @@ |
| 84 | + <?xml version="1.0" encoding="UTF-8"?> |
| 85 | + <gresources> |
| 86 | + <gresource prefix="/org/gnome/NautilusPreviewer"> |
| 87 | +- <file>org.gnome.NautilusPreviewer.xml</file> |
| 88 | + <file>org.gnome.NautilusPreviewer2.xml</file> |
| 89 | + </gresource> |
| 90 | + </gresources> |
| 91 | +diff --git a/src/org.gnome.NautilusPreviewer.xml b/src/org.gnome.NautilusPreviewer.xml |
| 92 | +deleted file mode 100644 |
| 93 | +index cb5ac10..0000000 |
| 94 | +--- a/src/org.gnome.NautilusPreviewer.xml |
| 95 | ++++ /dev/null |
| 96 | +@@ -1,11 +0,0 @@ |
| 97 | +-<node> |
| 98 | +- <interface name="org.gnome.NautilusPreviewer"> |
| 99 | +- <method name="ShowFile"> |
| 100 | +- <arg type="s" direction="in" name="uri" /> |
| 101 | +- <arg type="i" direction="in" name="xid" /> |
| 102 | +- <arg type="b" direction="in" name="closeIfAlreadyShown" /> |
| 103 | +- </method> |
| 104 | +- <method name="Close"> |
| 105 | +- </method> |
| 106 | +- </interface> |
| 107 | +-</node> |
| 108 | +diff --git a/src/sushi.in b/src/sushi.in |
| 109 | +index 05323b0..14d4992 100644 |
| 110 | +--- a/src/sushi.in |
| 111 | ++++ b/src/sushi.in |
| 112 | +@@ -39,7 +39,7 @@ try { |
| 113 | + } |
| 114 | + |
| 115 | + let bytes = Gio.resources_lookup_data( |
| 116 | +- '/org/gnome/NautilusPreviewer/org.gnome.NautilusPreviewer.xml', 0); |
| 117 | ++ '/org/gnome/NautilusPreviewer/org.gnome.NautilusPreviewer2.xml', 0); |
| 118 | + let wrapper = Gio.DBusProxy.makeProxyWrapper(ByteArray.toString(bytes.toArray())); |
| 119 | + |
| 120 | + let proxy; |
| 121 | +@@ -51,4 +51,8 @@ try { |
| 122 | + System.exit(1); |
| 123 | + } |
| 124 | + |
| 125 | +-proxy.ShowFileSync(file.get_uri(), 0, false); |
| 126 | ++const activationToken = GLib.getenv("XDG_ACTIVATION_TOKEN") ?? ""; |
| 127 | ++const windowHandle = ""; |
| 128 | ++const closeIfAlreadyShown = false; |
| 129 | ++proxy.ShowFileSync( |
| 130 | ++ file.get_uri(), windowHandle, closeIfAlreadyShown, activationToken); |
| 131 | +diff --git a/src/ui/application.js b/src/ui/application.js |
| 132 | +index ac0ddfd..f3e6786 100644 |
| 133 | +--- a/src/ui/application.js |
| 134 | ++++ b/src/ui/application.js |
| 135 | +@@ -60,17 +60,6 @@ var NautilusPreviewerSkeleton = class { |
| 136 | + } |
| 137 | + } |
| 138 | + |
| 139 | +-var NautilusPreviewer1Skeleton = class extends NautilusPreviewerSkeleton { |
| 140 | +- constructor(application) { |
| 141 | +- super(application, '/org/gnome/NautilusPreviewer/org.gnome.NautilusPreviewer.xml'); |
| 142 | +- } |
| 143 | +- |
| 144 | +- ShowFile(uri, xid, closeIfAlreadyShown) { |
| 145 | +- let handle = 'x11:%d'.format(xid); |
| 146 | +- this.application.showFile(uri, handle, closeIfAlreadyShown); |
| 147 | +- } |
| 148 | +-} |
| 149 | +- |
| 150 | + var NautilusPreviewer2Skeleton = class extends NautilusPreviewerSkeleton { |
| 151 | + constructor(application) { |
| 152 | + super(application, '/org/gnome/NautilusPreviewer/org.gnome.NautilusPreviewer2.xml'); |
| 153 | +@@ -92,17 +81,13 @@ var Application = GObject.registerClass(class Application extends Gtk.Applicatio |
| 154 | + vfunc_dbus_register(connection, path) { |
| 155 | + let actualPath = `/org/gnome/${pkg.name.split('.').at(-1)}`; |
| 156 | + |
| 157 | +- this._skeleton = new NautilusPreviewer1Skeleton(this); |
| 158 | + this._skeleton2 = new NautilusPreviewer2Skeleton(this); |
| 159 | +- |
| 160 | +- this._skeleton.export(connection, actualPath); |
| 161 | + this._skeleton2.export(connection, actualPath); |
| 162 | + |
| 163 | + return super.vfunc_dbus_register(connection, path); |
| 164 | + } |
| 165 | + |
| 166 | + vfunc_dbus_unregister(connection, path) { |
| 167 | +- this._skeleton.unexport(connection); |
| 168 | + this._skeleton2.unexport(connection); |
| 169 | + |
| 170 | + return super.vfunc_dbus_unregister(connection, path); |
| 171 | +-- |
| 172 | +GitLab |
| 173 | + |
0 commit comments