summaryrefslogtreecommitdiff
path: root/src/util/system.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2018-09-30 14:09:20 +0200
committerJörg Frings-Fürst <debian@jff.email>2018-09-30 14:09:20 +0200
commit5e9f4eea451a77ba3b93db3747841ed2bd969e9f (patch)
tree75046a38ca68975261d853a2e56ff7bf6b3e1daa /src/util/system.vala
parent18b52c2983a1b3409011f72d27f15de576c5eb1c (diff)
New upstream version 0.30.1upstream/0.30.1
Diffstat (limited to 'src/util/system.vala')
-rw-r--r--src/util/system.vala30
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);
+ }
}