@@ -31,6 +31,7 @@ public final class GtkBackend: AppBackend {
31
31
public let defaultToggleStyle = ToggleStyle . button
32
32
public let requiresImageUpdateOnScaleFactorChange = false
33
33
public let menuImplementationStyle = MenuImplementationStyle . dynamicPopover
34
+ public let canRevealFiles = true
34
35
35
36
var gtkApp : Application
36
37
@@ -164,6 +165,39 @@ public final class GtkBackend: AppBackend {
164
165
gtk_show_uri ( nil , url. absoluteString, guint ( GDK_CURRENT_TIME) )
165
166
}
166
167
168
+ public func revealFile( _ url: URL ) throws {
169
+ var success = false
170
+
171
+ #if !os(Windows)
172
+ let fileURI = url. absoluteString. replacingOccurrences (
173
+ of: " , " ,
174
+ with: " \\ , "
175
+ )
176
+ let process = Process ( )
177
+ process. arguments = [
178
+ " dbus-send " , " --print-reply " ,
179
+ " --dest=org.freedesktop.FileManager1 " ,
180
+ " /org/freedesktop/FileManager1 " ,
181
+ " org.freedesktop.FileManager1.ShowItems " ,
182
+ " array:string: \( fileURI) " ,
183
+ " string: "
184
+ ]
185
+ process. executableURL = URL ( fileURLWithPath: " /usr/bin/env " )
186
+
187
+ do {
188
+ try process. run ( )
189
+ process. waitUntilExit ( )
190
+
191
+ success = process. terminationStatus == 0
192
+ } catch {
193
+ break
194
+ }
195
+ #endif
196
+
197
+ // Fall back to opening the parent directory without highlighting the file.
198
+ try openExternalURL ( url. deletingLastPathComponent ( ) )
199
+ }
200
+
167
201
private func renderMenu(
168
202
_ menu: ResolvedMenu ,
169
203
actionMap: any GActionMap ,
0 commit comments