Skip to content

Commit

Permalink
util.py: Only use org.freedesktop.FileManager1 to reveal and select
Browse files Browse the repository at this point in the history
normal files.

When a folder uri is provided, the file manager ends up opening the
target location itself, instead of opening its parent and selecting
the folder.
  • Loading branch information
mtwebster committed Jun 12, 2020
1 parent 9fc4bc9 commit de9202e
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,26 @@ def open_save_folder(filename=None):

if filename != None:
abs_path = os.path.join(prefs.get_save_path(), filename)
file = Gio.File.new_for_path(abs_path)

startup_id = str(os.getpid())
if os.path.isfile(abs_path):
file = Gio.File.new_for_path(abs_path)

try:
bus.call_sync("org.freedesktop.FileManager1",
"/org/freedesktop/FileManager1",
"org.freedesktop.FileManager1",
"ShowItems",
GLib.Variant("(ass)",
([file.get_uri()], startup_id)),
None,
Gio.DBusCallFlags.NONE,
1000,
None)
return
except GLib.Error as e:
pass
startup_id = str(os.getpid())

try:
bus.call_sync("org.freedesktop.FileManager1",
"/org/freedesktop/FileManager1",
"org.freedesktop.FileManager1",
"ShowItems",
GLib.Variant("(ass)",
([file.get_uri()], startup_id)),
None,
Gio.DBusCallFlags.NONE,
1000,
None)
return
except GLib.Error as e:
pass

app = Gio.AppInfo.get_default_for_type("inode/directory", True)

Expand Down

0 comments on commit de9202e

Please sign in to comment.