From 5e9f4eea451a77ba3b93db3747841ed2bd969e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 30 Sep 2018 14:09:20 +0200 Subject: New upstream version 0.30.1 --- src/util/system.vala | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'src/util/system.vala') 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); + } } -- cgit v1.2.3