[nautilus] all: remove spatial windows methods from NautilusApplication



commit 073e1f9454d52523837a3a2073d710206c90a808
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Feb 17 12:04:06 2011 -0500

    all: remove spatial windows methods from NautilusApplication

 src/nautilus-application.c                   |  248 ++------------------------
 src/nautilus-application.h                   |    9 -
 src/nautilus-bookmarks-window.c              |   25 +---
 src/nautilus-connect-server-dialog-nonmain.c |   15 +--
 src/nautilus-navigation-window-menus.c       |   46 -----
 src/nautilus-navigation-window-ui.xml        |    1 -
 src/nautilus-navigation-window.c             |   19 --
 src/nautilus-spatial-window.c                |   20 --
 8 files changed, 15 insertions(+), 368 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index a1b1792..785afe8 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -43,7 +43,6 @@
 #include "nautilus-navigation-window-slot.h"
 #include "nautilus-progress-ui-handler.h"
 #include "nautilus-self-check-functions.h"
-#include "nautilus-spatial-window.h"
 #include "nautilus-window-bookmarks.h"
 #include "nautilus-window-manage-views.h"
 #include "nautilus-window-private.h"
@@ -91,9 +90,6 @@ static NautilusApplication *singleton = NULL;
 /* Keeps track of all the desktop windows. */
 static GList *nautilus_application_desktop_windows;
 
-/* Keeps track of all the object windows */
-static GList *nautilus_application_spatial_window_list;
-
 /* The saving of the accelerator map was requested  */
 static gboolean save_of_accel_map_requested = FALSE;
 
@@ -116,12 +112,6 @@ struct _NautilusApplicationPriv {
 	gboolean initialized;
 };
 
-static GList *
-nautilus_application_get_spatial_window_list (void)
-{
-	return nautilus_application_spatial_window_list;
-}
-
 static gboolean
 check_required_directories (NautilusApplication *application)
 {
@@ -507,12 +497,10 @@ finish_startup (NautilusApplication *application,
 static void
 open_window (NautilusApplication *application,
 	     const char *startup_id,
-	     const char *uri, GdkScreen *screen, const char *geometry,
-	     gboolean browser_window)
+	     const char *uri, GdkScreen *screen, const char *geometry)
 {
 	GFile *location;
 	NautilusWindow *window;
-	gboolean open_in_browser;
 
 	if (uri == NULL) {
 		location = g_file_new_for_path (g_get_home_dir ());
@@ -520,24 +508,11 @@ open_window (NautilusApplication *application,
 		location = g_file_new_for_uri (uri);
 	}
 
-	open_in_browser = browser_window ||
-		g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER);
-
-	DEBUG ("Opening new window at uri %s, browser %d", uri, open_in_browser);
-
-	if (open_in_browser) {
-		window = nautilus_application_create_navigation_window (application,
-									startup_id,
-									screen);
-	} else {
-		window = nautilus_application_get_spatial_window (application,
-								  NULL,
-								  startup_id,
-								  location,
-								  screen,
-								  NULL);
-	}
+	DEBUG ("Opening new window at uri %s", uri);
 
+	window = nautilus_application_create_navigation_window (application,
+								startup_id,
+								screen);
 	nautilus_window_go_to (window, location);
 
 	g_object_unref (location);
@@ -560,18 +535,17 @@ open_windows (NautilusApplication *application,
 	      const char *startup_id,
 	      char **uris,
 	      GdkScreen *screen,
-	      const char *geometry,
-	      gboolean browser_window)
+	      const char *geometry)
 {
 	guint i;
 
 	if (uris == NULL || uris[0] == NULL) {
 		/* Open a window pointing at the default location. */
-		open_window (application, startup_id, NULL, screen, geometry, browser_window);
+		open_window (application, startup_id, NULL, screen, geometry);
 	} else {
 		/* Open windows at each requested location. */
 		for (i = 0; uris[i] != NULL; i++) {
-			open_window (application, startup_id, uris[i], screen, geometry, browser_window);
+			open_window (application, startup_id, uris[i], screen, geometry);
 		}
 	}
 }
@@ -761,130 +735,6 @@ nautilus_application_close_all_navigation_windows (NautilusApplication *self)
 	g_list_free (list_copy);
 }
 
-static NautilusSpatialWindow *
-nautilus_application_get_existing_spatial_window (GFile *location)
-{
-	GList *l;
-	NautilusWindowSlot *slot;
-	GFile *window_location;
-
-	for (l = nautilus_application_get_spatial_window_list ();
-	     l != NULL; l = l->next) {
-		slot = NAUTILUS_WINDOW (l->data)->details->active_pane->active_slot;
-
-		window_location = slot->pending_location;
-		
-		if (window_location == NULL) {
-			window_location = slot->location;
-		}
-
-		if (window_location != NULL) {
-			if (g_file_equal (location, window_location)) {
-				return NAUTILUS_SPATIAL_WINDOW (l->data);
-			}
-		}
-	}
-
-	return NULL;
-}
-
-static NautilusSpatialWindow *
-find_parent_spatial_window (NautilusSpatialWindow *window)
-{
-	NautilusFile *file;
-	NautilusFile *parent_file;
-	NautilusWindowSlot *slot;
-	GFile *location;
-
-	slot = NAUTILUS_WINDOW (window)->details->active_pane->active_slot;
-
-	location = slot->location;
-	if (location == NULL) {
-		return NULL;
-	}
-	file = nautilus_file_get (location);
-
-	if (!file) {
-		return NULL;
-	}
-
-	parent_file = nautilus_file_get_parent (file);
-	nautilus_file_unref (file);
-	while (parent_file) {
-		NautilusSpatialWindow *parent_window;
-
-		location = nautilus_file_get_location (parent_file);
-		parent_window = nautilus_application_get_existing_spatial_window (location);
-		g_object_unref (location);
-
-		/* Stop at the desktop directory if it's not explicitely opened
-		 * in a spatial window of its own.
-		 */
-		if (nautilus_file_is_desktop_directory (parent_file) && !parent_window) {
-			nautilus_file_unref (parent_file);
-			return NULL;
-		}
-
-		if (parent_window) {
-			nautilus_file_unref (parent_file);
-			return parent_window;
-		}
-		file = parent_file;
-		parent_file = nautilus_file_get_parent (file);
-		nautilus_file_unref (file);
-	}
-
-	return NULL;
-}
-
-void
-nautilus_application_close_parent_windows (NautilusSpatialWindow *window)
-{
-	NautilusSpatialWindow *parent_window;
-	NautilusSpatialWindow *new_parent_window;
-
-	g_return_if_fail (NAUTILUS_IS_SPATIAL_WINDOW (window));
-
-	parent_window = find_parent_spatial_window (window);
-	
-	while (parent_window) {
-		
-		new_parent_window = find_parent_spatial_window (parent_window);
-		nautilus_window_close (NAUTILUS_WINDOW (parent_window));
-		parent_window = new_parent_window;
-	}
-}
-
-void
-nautilus_application_close_all_spatial_windows (void)
-{
-	GList *list_copy;
-	GList *l;
-	
-	list_copy = g_list_copy (nautilus_application_spatial_window_list);
-	/* First hide all window to get the feeling of quick response */
-	for (l = list_copy; l != NULL; l = l->next) {
-		NautilusWindow *window;
-		
-		window = NAUTILUS_WINDOW (l->data);
-		
-		if (NAUTILUS_IS_SPATIAL_WINDOW (window)) {
-			gtk_widget_hide (GTK_WIDGET (window));
-		}
-	}
-
-	for (l = list_copy; l != NULL; l = l->next) {
-		NautilusWindow *window;
-		
-		window = NAUTILUS_WINDOW (l->data);
-		
-		if (NAUTILUS_IS_SPATIAL_WINDOW (window)) {
-			nautilus_window_close (window);
-		}
-	}
-	g_list_free (list_copy);
-}
-
 static gboolean
 nautilus_window_delete_event_callback (GtkWidget *widget,
 				       GdkEvent *event,
@@ -933,75 +783,6 @@ create_window (NautilusApplication *application,
 	return window;
 }
 
-static void
-spatial_window_destroyed_callback (void *user_data, GObject *window)
-{
-	nautilus_application_spatial_window_list =
-		g_list_remove (nautilus_application_spatial_window_list, window);
-}
-
-NautilusWindow *
-nautilus_application_get_spatial_window (NautilusApplication *application,
-					 NautilusWindow      *requesting_window,
-					 const char          *startup_id,
-					 GFile               *location,
-					 GdkScreen           *screen,
-					 gboolean            *existing)
-{
-	NautilusWindow *window;
-
-	g_return_val_if_fail (NAUTILUS_IS_APPLICATION (application), NULL);
-
-	window = NAUTILUS_WINDOW
-		(nautilus_application_get_existing_spatial_window (location));
-
-	if (window != NULL) {
-		if (existing != NULL) {
-			*existing = TRUE;
-		}
-
-		DEBUG ("returning existing spatial window");
-
-		return window;
-	}
-
-	if (existing != NULL) {
-		*existing = FALSE;
-	}
-
-	window = create_window (application, NAUTILUS_TYPE_SPATIAL_WINDOW, startup_id, screen);
-	if (requesting_window) {
-		/* Center the window over the requesting window by default */
-		int orig_x, orig_y, orig_width, orig_height;
-		int new_x, new_y, new_width, new_height;
-		
-		gtk_window_get_position (GTK_WINDOW (requesting_window), 
-					 &orig_x, &orig_y);
-		gtk_window_get_size (GTK_WINDOW (requesting_window), 
-				     &orig_width, &orig_height);
-		gtk_window_get_default_size (GTK_WINDOW (window),
-					     &new_width, &new_height);
-		
-		new_x = orig_x + (orig_width - new_width) / 2;
-		new_y = orig_y + (orig_height - new_height) / 2;
-		
-		if (orig_width - new_width < 10) {
-			new_x += 10;
-			new_y += 10;
-		}
-
-		gtk_window_move (GTK_WINDOW (window), new_x, new_y);
-	}
-
-	nautilus_application_spatial_window_list = g_list_prepend (nautilus_application_spatial_window_list, window);
-	g_object_weak_ref (G_OBJECT (window), 
-			   spatial_window_destroyed_callback, NULL);
-
-	DEBUG ("Creating new spatial window");
-
-	return window;
-}
-
 static gboolean
 another_navigation_window_already_showing (NautilusApplication *application,
 					   NautilusWindow *the_window)
@@ -1133,9 +914,6 @@ should_close_slot_with_mount (NautilusWindow *window,
 			      NautilusWindowSlot *slot,
 			      GMount *mount)
 {
-	if (NAUTILUS_IS_SPATIAL_WINDOW (window)) {
-		return TRUE;
-	}
 	return nautilus_navigation_window_slot_should_close_with_mount (NAUTILUS_NAVIGATION_WINDOW_SLOT (slot),
 									mount);
 }
@@ -1292,7 +1070,6 @@ nautilus_application_command_line (GApplication *app,
 	gboolean version = FALSE;
 	gboolean no_default_window = FALSE;
 	gboolean no_desktop = FALSE;
-	gboolean browser_window = FALSE;
 	gboolean kill_shell = FALSE;
 	gboolean autostart_mode = FALSE;
 	const gchar *autostart_id;
@@ -1311,8 +1088,6 @@ nautilus_application_command_line (GApplication *app,
 		  N_("Only create windows for explicitly specified URIs."), NULL },
 		{ "no-desktop", '\0', 0, G_OPTION_ARG_NONE, &no_desktop,
 		  N_("Do not manage the desktop (ignore the preference set in the preferences dialog)."), NULL },
-		{ "browser", '\0', 0, G_OPTION_ARG_NONE, &browser_window, 
-		  N_("Open a browser window."), NULL },
 		{ "quit", 'q', 0, G_OPTION_ARG_NONE, &kill_shell, 
 		  N_("Quit Nautilus."), NULL },
 		{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining, NULL,  N_("[URI...]") },
@@ -1403,9 +1178,9 @@ nautilus_application_command_line (GApplication *app,
 		no_desktop = FALSE;
 	}
 
-	DEBUG ("Parsing command line, no_default_window %d browser %d, quit %d, "
+	DEBUG ("Parsing command line, no_default_window %d, quit %d, "
 	       "self checks %d, no_desktop %d",
-	       no_default_window, browser_window, kill_shell, perform_self_check, no_desktop);
+	       no_default_window, kill_shell, perform_self_check, no_desktop);
 
 	if (kill_shell) {
 		nautilus_application_quit (self);
@@ -1473,8 +1248,7 @@ nautilus_application_command_line (GApplication *app,
 			open_windows (self, NULL,
 				      uris,
 				      gdk_screen_get_default (),
-				      geometry,
-				      browser_window);
+				      geometry);
 		}
 	}
 
diff --git a/src/nautilus-application.h b/src/nautilus-application.h
index 6b31861..edbd589 100644
--- a/src/nautilus-application.h
+++ b/src/nautilus-application.h
@@ -71,19 +71,10 @@ NautilusApplication *nautilus_application_dup_singleton (void);
 
 void nautilus_application_quit (NautilusApplication *self);
 
-NautilusWindow *     nautilus_application_get_spatial_window     (NautilusApplication *application,
-								  NautilusWindow      *requesting_window,
-								  const char          *startup_id,
-								  GFile               *location,
-								  GdkScreen           *screen,
-								  gboolean            *existing);
-
 NautilusWindow *     nautilus_application_create_navigation_window     (NautilusApplication *application,
 									const char          *startup_id,
 									GdkScreen           *screen);
 
 void nautilus_application_close_all_navigation_windows (NautilusApplication *self);
-void                 nautilus_application_close_parent_windows     (NautilusSpatialWindow *window);
-void                 nautilus_application_close_all_spatial_windows  (void);
 
 #endif /* __NAUTILUS_APPLICATION_H__ */
diff --git a/src/nautilus-bookmarks-window.c b/src/nautilus-bookmarks-window.c
index 88e1649..86dfef3 100644
--- a/src/nautilus-bookmarks-window.c
+++ b/src/nautilus-bookmarks-window.c
@@ -565,30 +565,7 @@ open_selected_bookmark (gpointer user_data, GdkScreen *screen)
 		return;
 	}
 
-	if (NAUTILUS_IS_NAVIGATION_WINDOW (user_data)) {
-		window = user_data;
-	} else if (NAUTILUS_IS_SPATIAL_WINDOW (user_data)) {
-		window = nautilus_application_get_spatial_window (application,
-								  NULL,
-								  NULL,
-								  location,
-								  screen,
-								  NULL);
-	} else { /* window that opened bookmarks window has been closed */
-		if (parent_is_browser_window || g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
-			window = nautilus_application_create_navigation_window (application,
-										NULL,
-										screen);
-		} else {
-			window = nautilus_application_get_spatial_window (application,
-									  NULL,
-									  NULL,
-									  location,
-									  screen,
-									  NULL);
-		}
-	}
-
+	window = user_data;
 	nautilus_window_go_to (window, location);
 
 	g_object_unref (location);
diff --git a/src/nautilus-connect-server-dialog-nonmain.c b/src/nautilus-connect-server-dialog-nonmain.c
index 77dbf02..1e60c10 100644
--- a/src/nautilus-connect-server-dialog-nonmain.c
+++ b/src/nautilus-connect-server-dialog-nonmain.c
@@ -79,18 +79,9 @@ nautilus_connect_server_dialog_display_location_async (NautilusConnectServerDial
 
 	application = nautilus_application_dup_singleton ();
 
-	if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
-		window = nautilus_application_create_navigation_window (application,
-									NULL,
-									gtk_widget_get_screen (widget));
-	} else {
-		window = nautilus_application_get_spatial_window (application,
-								  NULL,
-								  NULL,
-								  location,
-								  gtk_widget_get_screen (widget),
-								  NULL);
-	}
+	window = nautilus_application_create_navigation_window (application,
+								NULL,
+								gtk_widget_get_screen (widget));
 
 	nautilus_window_go_to_full (window, location,
 				    window_go_to_cb, self);
diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c
index b24c68c..6fc3e7c 100644
--- a/src/nautilus-navigation-window-menus.c
+++ b/src/nautilus-navigation-window-menus.c
@@ -223,19 +223,6 @@ nautilus_navigation_window_update_show_hide_menu_items (NautilusNavigationWindow
 	gtk_radio_action_set_current_value (GTK_RADIO_ACTION (action), current_value);
 }
 
-void
-nautilus_navigation_window_update_spatial_menu_item (NautilusNavigationWindow *window) 
-{
-	GtkAction *action;
-
-	g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
-
-	action = gtk_action_group_get_action (window->details->navigation_action_group,
-					      NAUTILUS_ACTION_FOLDER_WINDOW);
-	gtk_action_set_visible (action,
-				!g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER));
-}
-
 static void
 action_add_bookmark_callback (GtkAction *action,
 			      gpointer user_data)
@@ -397,34 +384,6 @@ action_new_tab_callback (GtkAction *action,
 }
 
 static void
-action_folder_window_callback (GtkAction *action,
-			       gpointer user_data)
-{
-	NautilusApplication *application;
-	NautilusWindow *current_window, *window;
-	NautilusWindowSlot *slot;
-	GFile *current_location;
-
-	current_window = NAUTILUS_WINDOW (user_data);
-	application = nautilus_application_dup_singleton ();
-	slot = current_window->details->active_pane->active_slot;
-	current_location = nautilus_window_slot_get_location (slot);
-
-	window = nautilus_application_get_spatial_window
-		(application,
-		 current_window,
-		 NULL,
-		 current_location,
-		 gtk_window_get_screen (GTK_WINDOW (current_window)),
-		 NULL);
-
-	nautilus_window_go_to (window, current_location);
-
-	g_clear_object (&current_location);
-	g_object_unref (application);
-}
-
-static void
 action_go_to_location_callback (GtkAction *action,
 				gpointer user_data)
 {
@@ -602,9 +561,6 @@ static const GtkActionEntry navigation_entries[] = {
   /* name, stock id, label */  { "New Tab", "tab-new", N_("New _Tab"),
                                  "<control>T", N_("Open another tab for the displayed location"),
                                  G_CALLBACK (action_new_tab_callback) },
-  /* name, stock id, label */  { "Folder Window", "folder", N_("Open Folder W_indow"),
-                                 NULL, N_("Open a folder window for the displayed location"),
-                                 G_CALLBACK (action_folder_window_callback) },
   /* name, stock id, label */  { "Close All Windows", NULL, N_("Close _All Windows"),
                                  "<control>Q", N_("Close all Navigation windows"),
                                  G_CALLBACK (action_close_all_windows_callback) },
@@ -857,7 +813,5 @@ nautilus_navigation_window_initialize_menus (NautilusNavigationWindow *window)
 	navigation_window_menus_set_bindings (window);
 
 	nautilus_navigation_window_update_show_hide_menu_items (window);
-	nautilus_navigation_window_update_spatial_menu_item (window);
-
 	nautilus_navigation_window_initialize_go_menu (window);
 }
diff --git a/src/nautilus-navigation-window-ui.xml b/src/nautilus-navigation-window-ui.xml
index 6b74dae..9270eb3 100644
--- a/src/nautilus-navigation-window-ui.xml
+++ b/src/nautilus-navigation-window-ui.xml
@@ -10,7 +10,6 @@
 		<placeholder name="New Items Placeholder">
 			<menuitem name="New Tab" action="New Tab"/>
 			<menuitem name="New Window" action="New Window"/>
-			<menuitem name="Folder Window" action="Folder Window"/>
 			<separator/>
 		</placeholder>
 		
diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c
index 81acb6b..3ecb63b 100644
--- a/src/nautilus-navigation-window.c
+++ b/src/nautilus-navigation-window.c
@@ -98,16 +98,6 @@ static const struct {
 #endif
 };
 
-static void
-always_use_browser_changed (gpointer callback_data)
-{
-	NautilusNavigationWindow *window;
-
-	window = NAUTILUS_NAVIGATION_WINDOW (callback_data);
-
-	nautilus_navigation_window_update_spatial_menu_item (window);
-}
-
 /* Sanity check: highest mouse button value I could find was 14. 5 is our 
  * lower threshold (well-documented to be the one of the button events for the 
  * scrollwheel), so it's hardcoded in the functions below. However, if you have
@@ -309,10 +299,6 @@ nautilus_navigation_window_finalize (GObject *object)
 	g_free (window->details->sidebar_id);
 	g_clear_object (&window->details->nav_state);
 
-	g_signal_handlers_disconnect_by_func (nautilus_preferences,
-					      always_use_browser_changed,
-					      window);
-
 	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -802,11 +788,6 @@ nautilus_navigation_window_init (NautilusNavigationWindow *window)
 
 	nautilus_navigation_window_initialize_menus (window);
 
-	g_signal_connect_swapped (nautilus_preferences,
-				  "changed::" NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER,
-				  G_CALLBACK(always_use_browser_changed),
-				  window);
-
 	g_signal_connect_swapped (nautilus_window_state,
 				  "changed::" NAUTILUS_WINDOW_STATE_SIDE_PANE_VIEW,
 				  G_CALLBACK (side_pane_id_changed),
diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c
index 3166f9a..a33783b 100644
--- a/src/nautilus-spatial-window.c
+++ b/src/nautilus-spatial-window.c
@@ -307,20 +307,6 @@ nautilus_spatial_window_show (GtkWidget *widget)
 }
 
 static void
-action_close_parent_folders_callback (GtkAction *action, 
-				      gpointer user_data)
-{
-	nautilus_application_close_parent_windows (NAUTILUS_SPATIAL_WINDOW (user_data));
-}
-
-static void
-action_close_all_folders_callback (GtkAction *action, 
-				   gpointer user_data)
-{
-	nautilus_application_close_all_spatial_windows ();
-}
-
-static void
 real_prompt_for_location (NautilusWindow *window,
 			  const char     *initial)
 {
@@ -885,12 +871,6 @@ static const GtkActionEntry spatial_entries[] = {
   /* name, stock id, label */  { SPATIAL_ACTION_GO_TO_LOCATION, NULL, N_("Open _Location..."),
                                  "<control>L", N_("Specify a location to open"),
                                  G_CALLBACK (action_go_to_location_callback) },
-  /* name, stock id, label */  { SPATIAL_ACTION_CLOSE_PARENT_FOLDERS, NULL, N_("Close P_arent Folders"),
-                                 "<control><shift>W", N_("Close this folder's parents"),
-                                 G_CALLBACK (action_close_parent_folders_callback) },
-  /* name, stock id, label */  { SPATIAL_ACTION_CLOSE_ALL_FOLDERS, NULL, N_("Clos_e All Folders"), 
-                                 "<control>Q", N_("Close all folder windows"),
-                                 G_CALLBACK (action_close_all_folders_callback) },
   /* name, stock id, label */  { "Add Bookmark", GTK_STOCK_ADD, N_("_Add Bookmark"),
                                  "<control>d", N_("Add a bookmark for the current location to this menu"),
                                  G_CALLBACK (action_add_bookmark_callback) },



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