[gnome-user-share] obex: Use FileManager1 XDG API to reveal file



commit 5d4ab2b9640ecc73fdc49cfc0190f791d788cf7b
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Nov 15 11:58:23 2013 +0100

    obex: Use FileManager1 XDG API to reveal file
    
    Rather than just opening the containing folder, select and focus
    the file using the new XDG API.
    
    http://www.freedesktop.org/wiki/Specifications/file-manager-interface/

 src/obexpush.c |   35 ++++++++++++++++++++---------------
 1 files changed, 20 insertions(+), 15 deletions(-)
---
diff --git a/src/obexpush.c b/src/obexpush.c
index 8a86789..c8974ab 100644
--- a/src/obexpush.c
+++ b/src/obexpush.c
@@ -106,21 +106,26 @@ notification_launch_action_on_file_cb (NotifyNotification *notification,
 
        /* we open the Downloads folder */
        if (g_str_equal (action, "reveal") != FALSE) {
-               GFile *file;
-               GFile *parent;
-               gchar *parent_uri;
-
-               file = g_file_new_for_uri (file_uri);
-               parent = g_file_get_parent (file);
-               parent_uri = g_file_get_uri (parent);
-               g_object_unref (file);
-               g_object_unref (parent);
-
-               if (!g_app_info_launch_default_for_uri (parent_uri, ctx, NULL)) {
-                       g_warning ("Failed to launch the file manager\n");
-               }
-
-               g_free (parent_uri);
+               GDBusConnection *connection = agent->connection;
+               GVariantBuilder builder;
+
+               g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
+               g_variant_builder_add (&builder, "s", file_uri);
+
+               g_dbus_connection_call (connection,
+                                       "org.freedesktop.FileManager1",
+                                       "/org/freedesktop/FileManager1",
+                                       "org.freedesktop.FileManager1",
+                                       "ShowItems",
+                                       g_variant_new ("(ass)", &builder, ""),
+                                       NULL,
+                                       G_DBUS_CALL_FLAGS_NONE,
+                                       -1,
+                                       NULL,
+                                       NULL,
+                                       NULL);
+
+               g_variant_builder_clear (&builder);
        }
 
        notify_notification_close (notification, NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]