[gnome-bluetooth/gnome-2-28] Remove hard-coded use of nautilus



commit 308e1c6f32168c031a59a90b400aba1033c0de15
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jan 7 17:49:23 2010 +0000

    Remove hard-coded use of nautilus
    
    And hope the user has a file manager installed anyway.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=553083

 applet/main.c |   41 +++++++++++++++++++++++++++++++----------
 1 files changed, 31 insertions(+), 10 deletions(-)
---
diff --git a/applet/main.c b/applet/main.c
index 9bee2b0..cb17ebe 100644
--- a/applet/main.c
+++ b/applet/main.c
@@ -100,9 +100,33 @@ select_device_changed(BluetoothChooser *sel,
 				GTK_RESPONSE_ACCEPT, address != NULL);
 }
 
+static void
+mount_finish_cb (GObject *source_object,
+		 GAsyncResult *res,
+		 gpointer user_data)
+{
+	GError *error = NULL;
+	char *uri;
+
+	if (g_file_mount_enclosing_volume_finish (G_FILE (source_object),
+						  res, &error) == FALSE) {
+		g_printerr ("Failed to mount OBEX volume: %s", error->message);
+		g_error_free (error);
+		return;
+	}
+
+	uri = g_file_get_uri (G_FILE (source_object));
+	if (gtk_show_uri (NULL, uri, GDK_CURRENT_TIME, &error) == FALSE) {
+		g_printerr ("Failed to open %s: %s", uri, error->message);
+		g_error_free (error);
+	}
+	g_free (uri);
+}
+
 void browse_callback(GObject *widget, gpointer user_data)
 {
-	char *address, *cmd;
+	GFile *file;
+	char *address, *uri;
 
 	address = g_strdup (g_object_get_data (widget, "address"));
 	if (address == NULL) {
@@ -146,14 +170,14 @@ void browse_callback(GObject *widget, gpointer user_data)
 			return;
 	}
 
-	cmd = g_strdup_printf("%s --no-default-window \"obex://[%s]\"",
-			      "nautilus", address);
+	uri = g_strdup_printf ("obex://[%s]/", address);
 	g_free (address);
 
-	if (!g_spawn_command_line_async(cmd, NULL))
-		g_printerr("Couldn't execute command: %s\n", cmd);
+	file = g_file_new_for_uri (uri);
+	g_free (uri);
 
-	g_free (cmd);
+	g_file_mount_enclosing_volume (file, G_MOUNT_MOUNT_NONE, NULL, NULL, mount_finish_cb, NULL);
+	g_object_unref (file);
 }
 
 void sendto_callback(GObject *widget, gpointer user_data)
@@ -380,10 +404,7 @@ update_menu_items (void)
 	if (enabled == FALSE)
 		return;
 
-	object = gtk_builder_get_object (xml, "browse-device");
-	gtk_action_set_sensitive (GTK_ACTION (object),
-				  program_available ("nautilus"));
-
+	gtk_action_set_sensitive (GTK_ACTION (object), TRUE);
 }
 
 static void



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