gnome-main-menu r480 - in trunk: . libslab main-menu/src



Author: sreeves
Date: Wed Jul 16 18:26:46 2008
New Revision: 480
URL: http://svn.gnome.org/viewvc/gnome-main-menu?rev=480&view=rev

Log:
Fix for BNC#390400 - make places use the default mime type handler


Modified:
   trunk/ChangeLog
   trunk/libslab/bookmark-agent.c
   trunk/libslab/directory-tile.c
   trunk/libslab/directory-tile.h
   trunk/libslab/document-tile.c
   trunk/main-menu/src/main-menu-ui.c

Modified: trunk/libslab/bookmark-agent.c
==============================================================================
--- trunk/libslab/bookmark-agent.c	(original)
+++ trunk/libslab/bookmark-agent.c	Wed Jul 16 18:26:46 2008
@@ -1141,7 +1141,6 @@
 	gchar *tag_close_ptr = NULL;
 	gchar *search_string = NULL;
 
-
 	if (! strcmp (uri, "HOME")) {
 		uri_new = g_filename_to_uri (g_get_home_dir (), NULL, NULL);
 		name    = _("Home");
@@ -1205,10 +1204,7 @@
 
 	if (name)
 		g_bookmark_file_set_title (priv->store, uri, name);
-
-	g_bookmark_file_set_mime_type   (priv->store, uri, "inode/directory");
-	g_bookmark_file_add_application (priv->store, uri, "nautilus", "nautilus --browser %u");
-
+	
 	if (uri_new && libslab_strcmp (uri, uri_new))
 		g_bookmark_file_move_item (priv->store, uri, uri_new, NULL);
 }

Modified: trunk/libslab/directory-tile.c
==============================================================================
--- trunk/libslab/directory-tile.c	(original)
+++ trunk/libslab/directory-tile.c	Wed Jul 16 18:26:46 2008
@@ -24,6 +24,7 @@
 #include <string.h>
 #include <eel/eel-alert-dialog.h>
 #include <libgnomeui/gnome-icon-lookup.h>
+#include <libgnomevfs/gnome-vfs-mime-handlers.h>
 #include <libgnomevfs/gnome-vfs.h>
 #include <unistd.h>
 
@@ -48,7 +49,7 @@
 
 static void header_size_allocate_cb (GtkWidget *, GtkAllocation *, gpointer);
 
-static void open_trigger (Tile *, TileEvent *, TileAction *);
+static void open_with_default_trigger (Tile *, TileEvent *, TileAction *);
 static void rename_trigger (Tile *, TileEvent *, TileAction *);
 static void move_to_trash_trigger (Tile *, TileEvent *, TileAction *);
 static void delete_trigger (Tile *, TileEvent *, TileAction *);
@@ -63,12 +64,12 @@
 typedef struct
 {
 	gchar *basename;
+	gchar *mime_type;
+	gchar *icon_name;
 	
 	GtkBin *header_bin;
-
-	gchar *icon_name;
+	GnomeVFSMimeApplication *default_app;
 	
-	gboolean renaming;
 	gboolean image_is_broken;
 	
 	gboolean delete_enabled;
@@ -90,7 +91,7 @@
 }
 
 GtkWidget *
-directory_tile_new (const gchar *in_uri, const gchar *title, const gchar *icon_name)
+directory_tile_new (const gchar *in_uri, const gchar *title, const gchar *icon_name, const gchar *mime_type)
 {
 	DirectoryTile *this;
 	DirectoryTilePrivate *priv;
@@ -157,6 +158,7 @@
 	priv->basename    = g_strdup (basename);
 	priv->header_bin  = GTK_BIN (header);
 	priv->icon_name   = g_strdup (icon_name);
+	priv->mime_type   = g_strdup (mime_type);
 
 	directory_tile_private_setup (this);
 
@@ -168,7 +170,7 @@
 	/* make open with default action */
 
 	markup = g_markup_printf_escaped (_("<b>Open</b>"));
-	action = tile_action_new (TILE (this), open_trigger, markup, TILE_ACTION_OPENS_NEW_WINDOW);
+	action = tile_action_new (TILE (this), open_with_default_trigger, markup, TILE_ACTION_OPENS_NEW_WINDOW);
 	g_free (markup);
 
 	TILE (this)->default_action = action;
@@ -258,11 +260,12 @@
 directory_tile_private_setup (DirectoryTile *tile)
 {
 	DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
-
 	GConfClient *client;
 
-
-	priv->renaming = FALSE;
+	if (priv->mime_type)
+		priv->default_app = gnome_vfs_mime_get_default_application (priv->mime_type);
+	else
+		priv->default_app = NULL;
 
 	priv->delete_enabled =
 		(gboolean) GPOINTER_TO_INT (get_gconf_value (GCONF_ENABLE_DELETE_KEY));
@@ -281,10 +284,11 @@
 {
 	DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
 
+	priv->default_app = NULL;
 	priv->basename = NULL;
 	priv->header_bin = NULL;
 	priv->icon_name = NULL;
-	priv->renaming = FALSE;
+	priv->mime_type = NULL;
 	priv->image_is_broken = TRUE;
 	priv->delete_enabled = FALSE;
 	priv->gconf_conn_id = 0;
@@ -299,7 +303,10 @@
 
 	g_free (priv->basename);
 	g_free (priv->icon_name);
+	g_free (priv->mime_type);
 
+	gnome_vfs_mime_application_free (priv->default_app);
+    
 	client = gconf_client_get_default ();
 
 	gconf_client_notify_remove (client, priv->gconf_conn_id);
@@ -464,19 +471,6 @@
 }
 
 static void
-open_trigger (Tile *tile, TileEvent *event, TileAction *action)
-{
-	gchar *cmd;
-
-	cmd = string_replace_once (
-		get_slab_gconf_string (SLAB_FILE_MANAGER_OPEN_CMD), "FILE_URI", tile->uri);
-
-	spawn_process (cmd);
-
-	g_free (cmd);
-}
-
-static void
 rename_trigger (Tile *tile, TileEvent *event, TileAction *action)
 {
 	DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
@@ -674,3 +668,31 @@
 	setsid  ();
 	setpgrp ();
 }
+
+static void
+open_with_default_trigger (Tile *tile, TileEvent *event, TileAction *action)
+{
+	DirectoryTilePrivate *priv = DIRECTORY_TILE_GET_PRIVATE (tile);
+	GList *uris = NULL;
+	GnomeVFSResult retval;
+
+	if (priv->default_app)
+	{
+		uris = g_list_append (uris, TILE (tile)->uri);
+
+		retval = gnome_vfs_mime_application_launch (priv->default_app, uris);
+
+		if (retval != GNOME_VFS_OK)
+			g_warning
+				("error: could not launch application with [%s].  GnomeVFSResult = %d\n",
+				TILE (tile)->uri, retval);
+
+		g_list_free (uris);
+	} else {
+		gchar *cmd;
+		cmd = string_replace_once (
+			get_slab_gconf_string (SLAB_FILE_MANAGER_OPEN_CMD), "FILE_URI", tile->uri);
+		spawn_process (cmd);
+		g_free (cmd);
+	}
+}

Modified: trunk/libslab/directory-tile.h
==============================================================================
--- trunk/libslab/directory-tile.h	(original)
+++ trunk/libslab/directory-tile.h	Wed Jul 16 18:26:46 2008
@@ -50,7 +50,7 @@
 
 GType directory_tile_get_type (void);
 
-GtkWidget *directory_tile_new (const gchar *uri, const gchar *title, const gchar *icon_name);
+GtkWidget *directory_tile_new (const gchar *uri, const gchar *title, const gchar *icon_name, const gchar *mime_type);
 
 G_END_DECLS
 

Modified: trunk/libslab/document-tile.c
==============================================================================
--- trunk/libslab/document-tile.c	(original)
+++ trunk/libslab/document-tile.c	Wed Jul 16 18:26:46 2008
@@ -82,7 +82,6 @@
 
 	GtkBin *header_bin;
 
-	gboolean renaming;
 	gboolean image_is_broken;
 	gchar * force_icon_name;  //show an icon instead of a thumbnail
 
@@ -342,8 +341,6 @@
 	else
 		priv->default_app = NULL;
 
-	priv->renaming = FALSE;
-
 	gnome_vfs_file_info_unref (info);
 
 	priv->delete_enabled =
@@ -376,7 +373,6 @@
 
 	priv->header_bin       = NULL;
 
-	priv->renaming         = FALSE;
 	priv->image_is_broken  = TRUE;
 	priv->force_icon_name  = NULL;
 

Modified: trunk/main-menu/src/main-menu-ui.c
==============================================================================
--- trunk/main-menu/src/main-menu-ui.c	(original)
+++ trunk/main-menu/src/main-menu-ui.c	Wed Jul 16 18:26:46 2008
@@ -1146,7 +1146,7 @@
 static Tile *
 item_to_dir_tile (BookmarkItem *item, gpointer data)
 {
-	return TILE (directory_tile_new (item->uri, item->title, item->icon));
+	return TILE (directory_tile_new (item->uri, item->title, item->icon, item->mime_type));
 }
 
 static Tile *



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