diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2018-10-01 07:17:16 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2018-10-01 07:17:16 +0200 |
commit | 71137cc5832110d91599d68790402cf196762ed3 (patch) | |
tree | e7985bbfb6ca50ea738b38a9f852ee51431d48a7 /src/util/system.vala | |
parent | 8ae550d463720d5d1c0e253af29843ff15de1a54 (diff) | |
parent | 1e92964463e564bb3359a7110342182fcfdc67f2 (diff) |
Merge branch 'release/debian/0.30.1-1'debian/0.30.1-1
Diffstat (limited to 'src/util/system.vala')
-rw-r--r-- | src/util/system.vala | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/util/system.vala b/src/util/system.vala index 38abf1e..1e69304 100644 --- a/src/util/system.vala +++ b/src/util/system.vala @@ -21,15 +21,29 @@ File? get_sys_install_dir(File exec_dir) { return null; } -string get_nautilus_install_location() { - return Environment.find_program_in_path("nautilus"); +[DBus (name = "org.freedesktop.FileManager1")] +public interface org.freedesktop.FileManager1 : Object { + public const string NAME = "org.freedesktop.FileManager1"; + public const string PATH = "/org/freedesktop/FileManager1"; + + public abstract async void show_folders(string[] uris, string startup_id) throws IOError, DBusError; + public abstract async void show_items(string[] uris, string startup_id) throws IOError, DBusError; + public abstract async void show_item_properties(string[] uris, string startup_id) throws IOError, DBusError; } -void sys_show_uri(Gdk.Screen screen, string uri) throws Error { - Gtk.show_uri(screen, uri, Gdk.CURRENT_TIME); -} - -void show_file_in_nautilus(string filename) throws Error { - GLib.Process.spawn_command_line_async(get_nautilus_install_location() + " " + filename); +async void show_file_in_filemanager(File file) throws Error { + try { + org.freedesktop.FileManager1? manager = yield Bus.get_proxy (BusType.SESSION, + org.freedesktop.FileManager1.NAME, + org.freedesktop.FileManager1.PATH, + DBusProxyFlags.DO_NOT_LOAD_PROPERTIES | + DBusProxyFlags.DO_NOT_CONNECT_SIGNALS); + var id = "%s_%s_%d_%s".printf(Environment.get_prgname(), Environment.get_host_name(), + Posix.getpid(), TimeVal().to_iso8601()); + yield manager.show_items({file.get_uri()}, id); + } catch (Error e) { + warning("Failed to launch file manager using DBus, using fall-back: %s", e.message); + Gtk.show_uri_on_window(AppWindow.get_instance(), file.get_parent().get_uri(), Gdk.CURRENT_TIME); + } } |