Index: src/nautilus-shell.c
===================================================================
--- src/nautilus-shell.c	(revisión: 14443)
+++ src/nautilus-shell.c	(copia de trabajo)
@@ -77,6 +77,16 @@ static void     corba_quit              
 						 CORBA_Environment      *ev);
 static void     corba_restart                   (PortableServer_Servant  servant,
 						 CORBA_Environment      *ev);
+static void     open_window                     (NautilusShell *shell, 
+						 const char *uri, 
+						 const char *startup_id,
+						 const char *geometry,
+						 gboolean browser_window,
+						 gboolean got_filetype,
+						 GFileType file_type);
+void            get_file_type_cb		(GObject *source_object, 
+						 GAsyncResult *res, 
+						 gpointer user_data);
 
 BONOBO_CLASS_BOILERPLATE_FULL (NautilusShell, nautilus_shell,
 			       Nautilus_Shell,
@@ -123,13 +133,61 @@ nautilus_shell_new (NautilusApplication 
 	return shell;
 }
 
+typedef struct {
+	NautilusShell *shell;
+	char *uri;
+	char *startup_id;
+	char *geometry;
+	gboolean browser_window;
+	GFile *file;
+} get_type_data;
+
+void
+get_file_type_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) {
+	get_type_data *data;
+	GFileInfo *info;
+	GFileType ftype;
+	data = (get_type_data *) user_data;
+	info = g_file_query_info_finish (data->file, res, NULL);
+	ftype = (GFileType) g_file_info_get_attribute_uint32 (info, "standard::type");
+	open_window (data->shell, 
+		data->uri, 
+		data->startup_id, 
+		data->geometry, 
+		data->browser_window, 
+		TRUE,
+		ftype);
+	g_object_unref (data->file);
+	g_free (data->uri);
+	g_free (data->startup_id);
+	g_free (data->geometry);
+}
+
 static void
 open_window (NautilusShell *shell, const char *uri, const char *startup_id,
-	     const char *geometry, gboolean browser_window)
+	     const char *geometry, gboolean browser_window, gboolean got_filetype, GFileType file_type)
 {
-	GFile *location;
+	GFile *location = NULL;
+	GFile *location_dir;
+	GList *selection = NULL;
 	NautilusWindow *window;
-
+	get_type_data *cb_data;
+	if (uri != NULL) {
+		location = g_file_new_for_uri (uri);
+			if (!got_filetype) {
+				cb_data = g_new0 (get_type_data, 1);
+				cb_data->shell = shell;
+				cb_data->uri = g_strdup (uri);
+				cb_data->startup_id = g_strdup (startup_id);
+				cb_data->geometry = (geometry) ? g_strdup (geometry) : NULL;
+				cb_data->browser_window = browser_window;
+				cb_data->file = location;
+				g_file_query_info_async (location, "standard::type", 
+							 G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, 
+							 G_PRIORITY_DEFAULT, NULL, get_file_type_cb, cb_data);
+				return;
+			}
+	}
 	if (browser_window ||
 	    eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
 		window = nautilus_application_create_navigation_window (shell->details->application,
@@ -138,23 +196,47 @@ open_window (NautilusShell *shell, const
 		if (uri == NULL) {
 			nautilus_window_go_home (window);
 		} else {
-			location = g_file_new_for_uri (uri);
-			nautilus_window_go_to (window, location);
-			g_object_unref (location);
+			
+
+			if (file_type != G_FILE_TYPE_DIRECTORY && file_type != G_FILE_TYPE_UNKNOWN) {
+				location_dir = g_file_get_parent (location);
+				selection = g_list_prepend (selection, location);
+				nautilus_window_go_to_with_selection (window, location_dir, selection);
+				g_object_unref (location);
+				g_object_unref (location_dir);
+				g_list_free (selection);
+			} else {
+				nautilus_window_go_to (window, location);
+				g_object_unref (location);
+			}
 		}
 	} else {
 		if (uri == NULL) {
+			g_object_unref (location);
 			location = g_file_new_for_path (g_get_home_dir ());
+		}
+
+		if (file_type != G_FILE_TYPE_DIRECTORY && file_type != G_FILE_TYPE_UNKNOWN) {
+			location_dir = g_file_get_parent (location);
+			selection = g_list_prepend (selection, location);			
+			window = nautilus_application_present_spatial_window_with_selection (shell->details->application,
+										             NULL,
+										             startup_id,
+										             location_dir,
+										             selection,
+										             gdk_screen_get_default ());
+			g_object_unref (location_dir);
 		} else {
-			location = g_file_new_for_uri (uri);
+			window = nautilus_application_present_spatial_window (shell->details->application,
+									      NULL,
+									      startup_id,
+									      location,
+									      gdk_screen_get_default ());
 		}
-		
-		window = nautilus_application_present_spatial_window (shell->details->application,
-								      NULL,
-								      startup_id,
-								      location,
-								      gdk_screen_get_default ());
 		g_object_unref (location);
+		if (selection) {
+			g_list_free (selection);
+		}
 	}
 	
 	if (geometry != NULL && !GTK_WIDGET_VISIBLE (window)) {
@@ -188,13 +270,13 @@ open_windows_at_idle (gpointer _data)
 	if (data->uris == NULL) {
 		/* Open a window pointing at the default location. */
 		open_window (data->shell, NULL, data->startup_id,
-			     data->geometry, data->browser_window);
+			     data->geometry, data->browser_window, FALSE, 0);
 	} else {
 		/* Open windows at each requested location. */
 		for (l = data->uris; l != NULL; l = l->next) {
 			uri = (char *)l->data;
 			open_window (data->shell, uri, data->startup_id,
-				     data->geometry, data->browser_window);
+				     data->geometry, data->browser_window, FALSE, 0);
 			g_free (uri);
 		}
 	}
