[PATCH] Improve session management



The attached patch makes Nautilus store the state of previously open
windows on exit and reopen them in their mode when restarted through the
session. It also adds support for storing a browser window's maximized
state in addition to its geometry.

http://bugzilla.gnome.org/show_bug.cgi?id=334215

-- 
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-global-preferences.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-global-preferences.c,v
retrieving revision 1.225
diff -u -p -r1.225 nautilus-global-preferences.c
--- libnautilus-private/nautilus-global-preferences.c	15 Dec 2005 14:25:57 -0000	1.225
+++ libnautilus-private/nautilus-global-preferences.c	16 Mar 2006 19:44:26 -0000
@@ -384,6 +384,10 @@ static const PreferenceDefault preferenc
 	  PREFERENCE_STRING,
 	  ""
 	},
+	{ NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_MAXIMIZED,
+	  PREFERENCE_BOOLEAN,
+	  GINT_TO_POINTER (FALSE)
+	},
 	{ NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES,
 	  PREFERENCE_BOOLEAN,
 	  GINT_TO_POINTER (TRUE)
Index: libnautilus-private/nautilus-global-preferences.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-global-preferences.h,v
retrieving revision 1.132
diff -u -p -r1.132 nautilus-global-preferences.h
--- libnautilus-private/nautilus-global-preferences.h	15 Dec 2005 14:32:57 -0000	1.132
+++ libnautilus-private/nautilus-global-preferences.h	16 Mar 2006 19:44:28 -0000
@@ -88,6 +88,7 @@ typedef enum
 #define NAUTILUS_PREFERENCES_START_WITH_TOOLBAR			"preferences/start_with_toolbar"
 #define NAUTILUS_PREFERENCES_SIDE_PANE_VIEW                     "preferences/side_pane_view"
 #define NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_SAVED_GEOMETRY 	"preferences/navigation_window_saved_geometry"
+#define NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_MAXIMIZED        "preferences/navigation_window_saved_maximized"
 
 /* Sorting order */
 #define NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST		"preferences/sort_directories_first"
Index: libnautilus-private/nautilus-metadata.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-metadata.h,v
retrieving revision 1.30
diff -u -p -r1.30 nautilus-metadata.h
--- libnautilus-private/nautilus-metadata.h	11 Oct 2004 08:10:42 -0000	1.30
+++ libnautilus-private/nautilus-metadata.h	16 Mar 2006 19:44:31 -0000
@@ -55,6 +55,7 @@
 #define NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY			"window_geometry"
 #define NAUTILUS_METADATA_KEY_WINDOW_SCROLL_POSITION		"window_scroll_position"
 #define NAUTILUS_METADATA_KEY_WINDOW_SHOW_HIDDEN_FILES		"window_show_hidden_files"
+#define NAUTILUS_METADATA_KEY_WINDOW_MAXIMIZED			"window_maximized"
 
 #define NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR   	"sidebar_background_color"
 #define NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE   	"sidebar_background_tile_image"
Index: src/nautilus-application.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-application.c,v
retrieving revision 1.239
diff -u -p -r1.239 nautilus-application.c
--- src/nautilus-application.c	26 Feb 2006 11:03:24 -0000	1.239
+++ src/nautilus-application.c	16 Mar 2006 19:44:34 -0000
@@ -52,6 +52,8 @@
 #include "nautilus-shell.h"
 #include "nautilus-window-bookmarks.h"
 #include "nautilus-window-private.h"
+#include "nautilus-window-manage-views.h"
+#include <glib/gstdio.h>
 #include <bonobo/bonobo-main.h>
 #include <bonobo/bonobo-object.h>
 #include <eel/eel-gtk-macros.h>
@@ -119,6 +121,9 @@ static void     update_session          
 static void     init_session                      (void);
 static gboolean is_kdesktop_present               (void);
 
+static void     save_all_windows                  (void);
+static void     restore_all_windows               (NautilusApplication *application);
+
 BONOBO_CLASS_BOILERPLATE (NautilusApplication, nautilus_application,
 			  BonoboGenericFactory, BONOBO_TYPE_GENERIC_FACTORY)
 
@@ -375,6 +380,8 @@ finish_startup (NautilusApplication *app
 
 	/* Initialize the desktop link monitor singleton */
 	nautilus_desktop_link_monitor_get ();
+
+	restore_all_windows (application);
 }
 
 static void
@@ -1140,12 +1147,30 @@ nautilus_application_present_spatial_win
 	return window;
 }
 
+static gboolean
+another_navigation_window_already_showing (NautilusWindow *the_window)
+{
+	GList *list, *item;
+	
+	list = nautilus_application_get_window_list ();
+	for (item = list; item != NULL; item = item->next) {
+		if (item->data != the_window &&
+		    NAUTILUS_IS_NAVIGATION_WINDOW (item->data)) {
+			return TRUE;
+		}
+	}
+	
+	return FALSE;
+}
+
 NautilusWindow *
 nautilus_application_create_navigation_window (NautilusApplication *application,
 					       const char          *startup_id,
 					       GdkScreen           *screen)
 {
 	NautilusWindow *window;
+	char *geometry_string;
+	gboolean maximized;
 
 	g_return_val_if_fail (NAUTILUS_IS_APPLICATION (application), NULL);
 	
@@ -1155,6 +1180,31 @@ nautilus_application_create_navigation_w
 				  startup_id);
 #endif
 
+	maximized = eel_preferences_get_boolean
+			(NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_MAXIMIZED);
+	if (maximized) {
+		gtk_window_maximize (GTK_WINDOW (window));
+	} else {
+		gtk_window_unmaximize (GTK_WINDOW (window));
+	}
+
+	geometry_string = eel_preferences_get
+			(NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_SAVED_GEOMETRY);
+	if (geometry_string != NULL &&
+	    geometry_string[0] != 0) {
+		/* Ignore saved window position if a window with the same
+		 * location is already showing. That way the two windows
+		 * wont appear at the exact same location on the screen.
+		 */
+		eel_gtk_window_set_initial_geometry_from_string 
+			(GTK_WINDOW (window), 
+			 geometry_string,
+			 NAUTILUS_WINDOW_MIN_WIDTH, 
+			 NAUTILUS_WINDOW_MIN_HEIGHT,
+			 another_navigation_window_already_showing (window));
+	}
+	g_free (geometry_string);
+
 	return window;
 }
 
@@ -1284,40 +1334,238 @@ removed_from_session (GnomeClient *clien
 	nautilus_main_event_loop_quit ();
 }
 
-static gint
-save_session (GnomeClient *client, gint phase, GnomeSaveStyle save_style, gint shutdown,
-	      GnomeInteractStyle interact_style, gint fast, gpointer data)
+static void
+save_all_windows (void)
 {
-	NautilusWindow *window;
+	xmlDocPtr doc;
+	xmlNodePtr root_node, history_node;
 	GList *l;
-	static char *clone_argv[] = { "nautilus", "--no-default-window" };
-	char **restart_argv;
-	int argc;
-	int i;
-	int num_windows;
-
-	num_windows = g_list_length (nautilus_application_window_list);
-	if (num_windows > 0) {
-		argc = 1 + num_windows;
-		i = 0;
-		restart_argv = g_new (char *, argc);
-		restart_argv[i++] = g_strdup ("nautilus");
-		for (l = nautilus_application_window_list; l != NULL; l = l->next) {
-			window = NAUTILUS_WINDOW (l->data);
-			restart_argv[i++] = nautilus_window_get_location (window);
+	char *dir, *filename;
+	unsigned n_processed;
+
+	doc = xmlNewDoc ("1.0");
+
+	root_node = xmlNewNode (NULL, "session");
+	xmlDocSetRootElement (doc, root_node);
+
+	history_node = xmlNewChild (root_node, NULL, "history", NULL);
+
+	n_processed = 0;
+	for (l = nautilus_get_history_list (); l != NULL; l = l->next) {
+		NautilusBookmark *bookmark;
+		xmlNodePtr bookmark_node;
+		char *tmp;
+
+		bookmark = l->data;
+
+		bookmark_node = xmlNewChild (history_node, NULL, "bookmark", NULL);
+
+		tmp = nautilus_bookmark_get_name (bookmark);
+		xmlNewProp (bookmark_node, "name", tmp);
+		g_free (tmp);
+
+		tmp = nautilus_bookmark_get_icon (bookmark);
+		xmlNewProp (bookmark_node, "icon", tmp);
+		g_free (tmp);
+
+		tmp = nautilus_bookmark_get_uri (bookmark);
+		xmlNewProp (bookmark_node, "uri", tmp);
+		g_free (tmp);
+
+		if (nautilus_bookmark_get_has_custom_name (bookmark)) {
+			xmlNewProp (bookmark_node, "has_custom_name", "TRUE");
 		}
-		
-		gnome_client_set_restart_command (client, argc, restart_argv);
 
-		for (i = 0; i < argc; i++) {
-			g_free (restart_argv[i]);
+		if (++n_processed > 50) { /* prevent history list from growing arbitrarily large. */
+			break;
 		}
-		g_free (restart_argv);
+	}
+
+	for (l = nautilus_application_window_list; l != NULL; l = l->next) {
+		xmlNodePtr win_node;
+		NautilusWindow *window;
+		char *tmp;
+
+		window = l->data;
+
+		win_node = xmlNewChild (root_node, NULL, "window", NULL);
+
+		xmlNewProp (win_node, "type", NAUTILUS_IS_NAVIGATION_WINDOW (window) ? "navigation" : "spatial");
+
+		if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) { /* spatial windows store their state as file metadata */
+			tmp = eel_gtk_window_get_geometry_string (GTK_WINDOW (window));
+			xmlNewProp (win_node, "geometry", tmp);
+			g_free (tmp);
+
+			if (GTK_WIDGET (window)->window &&
+			    gdk_window_get_state (GTK_WIDGET (window)->window) & GDK_WINDOW_STATE_MAXIMIZED) {
+				xmlNewProp (win_node, "maximized", "TRUE");
+			}
+		}
+
+		tmp = nautilus_window_get_location (window);
+		xmlNewProp (win_node, "location", tmp);
+		g_free (tmp);
+	}
+
+	dir = nautilus_get_user_directory ();
+	filename = g_build_filename (dir, "saved-session.xml", NULL);
+	g_free (dir);
+
+	xmlIndentTreeOutput = 1;
+	if (xmlSaveFormatFile (filename, doc, 1) < 0) {
+		g_message ("failed to save session to %s", filename);
+	}
+
+	xmlFreeDoc (doc);
+
+	g_free (filename);
+}
+
+static void
+restore_all_windows (NautilusApplication *application)
+{
+	xmlDocPtr doc;
+	char *dir, *filename;
+	gboolean bail;
+
+	dir = nautilus_get_user_directory ();
+	filename = g_build_filename (dir, "saved-session.xml", NULL);
+	g_free (dir);
+
+	bail = FALSE;
+
+	if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
+		xmlNodePtr root_node;
+
+		bail = TRUE;
+
+		doc = xmlReadFile (filename, NULL, 0);
+		if (doc != NULL && (root_node = xmlDocGetRootElement (doc)) != NULL) {
+			xmlNodePtr node;
+
+			bail = FALSE;
+
+			for (node = root_node->children; node != NULL; node = node->next) {
+
+				if (!strcmp (node->name, "text")) {
+					continue;
+				} else if (!strcmp (node->name, "history")) {
+					xmlNodePtr bookmark_node;
+					gboolean emit_change;
+
+					emit_change = FALSE;
+
+					for (bookmark_node = node->children; bookmark_node != NULL; bookmark_node = bookmark_node->next) {
+						if (!strcmp (bookmark_node->name, "text")) {
+							continue;
+						} else if (!strcmp (bookmark_node->name, "bookmark")) {
+							xmlChar *name, *icon, *uri;
+							gboolean has_custom_name;
+
+							uri = xmlGetProp (bookmark_node, "uri");
+							name = xmlGetProp (bookmark_node, "name");
+							has_custom_name = xmlHasProp (bookmark_node, "has_custom_name") ? TRUE : FALSE;
+							icon = xmlGetProp (bookmark_node, "icon");
+
+							emit_change |= nautilus_add_to_history_list_no_notify (uri, name, has_custom_name, icon);
+
+							xmlFree (name);
+							xmlFree (uri);
+							xmlFree (icon);
+						} else {
+							g_message ("unexpected bookmark node %s while parsing %s", bookmark_node->name, filename);
+							bail = TRUE;
+							continue;
+						}
+					}
+
+					if (emit_change) {
+						nautilus_send_history_list_changed ();
+					}
+				} else if (!strcmp (node->name, "window")) {
+					NautilusWindow *window;
+					xmlChar *type, *location;
+
+					type = xmlGetProp (node, "type");
+					if (type == NULL) {
+						g_message ("empty type node while parsing %s", filename);
+						bail = TRUE;
+						continue;
+					}
+
+					location = xmlGetProp (node, "location");
+					if (location == NULL) {
+						g_message ("empty location node while parsing %s", filename);
+						bail = TRUE;
+						xmlFree (type);
+						continue;
+					}
+
+					if (!strcmp (type, "navigation")) {
+						xmlChar *geometry;
+
+						window = nautilus_application_create_navigation_window (application, NULL, gdk_screen_get_default ());
+
+						geometry = xmlGetProp (node, "geometry");
+						if (geometry != NULL) {
+							eel_gtk_window_set_initial_geometry_from_string 
+								(GTK_WINDOW (window), 
+								 geometry,
+								 NAUTILUS_WINDOW_MIN_WIDTH, 
+								 NAUTILUS_WINDOW_MIN_HEIGHT,
+								 FALSE);
+						}
+						xmlFree (geometry);
+
+						if (xmlHasProp (node, "maximized")) {
+							gtk_window_maximize (GTK_WINDOW (window));
+						} else {
+							gtk_window_unmaximize (GTK_WINDOW (window));
+						}
+
+						nautilus_window_open_location (window, location, FALSE);
+					} else if (!strcmp (type, "spatial")) {
+						window = nautilus_application_present_spatial_window (application, NULL, NULL, location, gdk_screen_get_default ());
+					} else {
+						g_message ("unknown window type \"%s\" while parsing %s", type, filename);
+						bail = TRUE;
+					}
+
+					xmlFree (type);
+					xmlFree (location);
+				} else {
+					g_message ("unexpected node %s while parsing %s", node->name, filename);
+					bail = TRUE;
+					continue;
+				}
+			}
+		}
+
+		if (doc != NULL) {
+			xmlFreeDoc (doc);
+		}
+	}
+
+	if (bail) {
+		g_message ("failed to read last session from %s", filename);
 	} else {
-		gnome_client_set_restart_command (client, 
-						  G_N_ELEMENTS (clone_argv), 
-						  clone_argv);
+		g_remove (filename);
 	}
+
+	g_free (filename);
+}
+
+static gint
+save_session (GnomeClient *client, gint phase, GnomeSaveStyle save_style, gint shutdown,
+	      GnomeInteractStyle interact_style, gint fast, gpointer data)
+{
+	static char *argv[] = { "nautilus", "--no-default-window" };
+
+	save_all_windows ();
+	gnome_client_set_restart_command (client, 
+					  G_N_ELEMENTS (argv), 
+					  argv);
 	
 	return TRUE;
 }
Index: src/nautilus-navigation-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-navigation-window.c,v
retrieving revision 1.444
diff -u -p -r1.444 nautilus-navigation-window.c
--- src/nautilus-navigation-window.c	27 Feb 2006 15:51:47 -0000	1.444
+++ src/nautilus-navigation-window.c	16 Mar 2006 19:44:40 -0000
@@ -560,6 +560,22 @@ nautilus_navigation_window_unrealize (Gt
 	GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
 }
 
+static gboolean
+nautilus_navigation_window_state_event (GtkWidget *widget,
+					GdkEventWindowState *event)
+{
+	if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) {
+		eel_preferences_set_boolean (NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_MAXIMIZED,
+					     event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED);
+	}
+
+	if (GTK_WIDGET_CLASS (parent_class)->window_state_event != NULL) {
+		return GTK_WIDGET_CLASS (parent_class)->window_state_event (widget, event);
+	}
+
+	return FALSE;
+}
+
 static void
 nautilus_navigation_window_destroy (GtkObject *object)
 {
@@ -1418,8 +1434,7 @@ nautilus_navigation_window_save_geometry
 
 	g_assert (NAUTILUS_IS_WINDOW (window));
 
-	if (GTK_WIDGET(window)->window &&
-	    !(gdk_window_get_state (GTK_WIDGET(window)->window) & GDK_WINDOW_STATE_MAXIMIZED)) {
+	if (GTK_WIDGET(window)->window) {
 		geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window));
 		
 		if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_SAVED_GEOMETRY)) {
@@ -1428,6 +1443,12 @@ nautilus_navigation_window_save_geometry
 				 geometry_string);
 		}
 		g_free (geometry_string);
+
+		if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_MAXIMIZED)) {
+			eel_preferences_set_boolean
+				(NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_MAXIMIZED, 
+				 gdk_window_get_state (GTK_WIDGET (window)->window) & GDK_WINDOW_STATE_MAXIMIZED);
+		}
 	}
 }
 
@@ -1462,6 +1483,7 @@ nautilus_navigation_window_class_init (N
 	GTK_OBJECT_CLASS (class)->destroy = nautilus_navigation_window_destroy;
 	GTK_WIDGET_CLASS (class)->show = nautilus_navigation_window_show;
 	GTK_WIDGET_CLASS (class)->unrealize = nautilus_navigation_window_unrealize;
+	GTK_WIDGET_CLASS (class)->window_state_event = nautilus_navigation_window_state_event;
 	NAUTILUS_WINDOW_CLASS (class)->load_view_as_menu = real_load_view_as_menu;
 	NAUTILUS_WINDOW_CLASS (class)->set_content_view_widget = real_set_content_view_widget;
 	NAUTILUS_WINDOW_CLASS (class)->set_throbber_active = real_set_throbber_active;
Index: src/nautilus-spatial-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-spatial-window.c,v
retrieving revision 1.457
diff -u -p -r1.457 nautilus-spatial-window.c
--- src/nautilus-spatial-window.c	27 Feb 2006 15:51:47 -0000	1.457
+++ src/nautilus-spatial-window.c	16 Mar 2006 19:44:42 -0000
@@ -192,6 +192,25 @@ nautilus_spatial_window_unrealize (GtkWi
 	}
 }
 
+static gboolean
+nautilus_spatial_window_state_event (GtkWidget *widget,
+				     GdkEventWindowState *event)
+{
+	if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED &&
+	    NAUTILUS_WINDOW (widget)->details->viewed_file != NULL) {
+		nautilus_file_set_boolean_metadata (NAUTILUS_WINDOW (widget)->details->viewed_file,
+						    NAUTILUS_METADATA_KEY_WINDOW_MAXIMIZED,
+						    FALSE,
+						    event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED);
+	}
+
+	if (GTK_WIDGET_CLASS (parent_class)->window_state_event != NULL) {
+		return GTK_WIDGET_CLASS (parent_class)->window_state_event (widget, event);
+	}
+
+	return FALSE;
+}
+
 static void
 nautilus_spatial_window_destroy (GtkObject *object)
 {
@@ -978,6 +997,7 @@ nautilus_spatial_window_class_init (Naut
 	GTK_WIDGET_CLASS (class)->show = nautilus_spatial_window_show;
 	GTK_WIDGET_CLASS (class)->configure_event = nautilus_spatial_window_configure_event;
 	GTK_WIDGET_CLASS (class)->unrealize = nautilus_spatial_window_unrealize;
+	GTK_WIDGET_CLASS (class)->window_state_event = nautilus_spatial_window_state_event;
 
 	NAUTILUS_WINDOW_CLASS (class)->prompt_for_location = 
 		real_prompt_for_location;
Index: src/nautilus-window-manage-views.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-manage-views.c,v
retrieving revision 1.364
diff -u -p -r1.364 nautilus-window-manage-views.c
--- src/nautilus-window-manage-views.c	3 Mar 2006 13:42:24 -0000	1.364
+++ src/nautilus-window-manage-views.c	16 Mar 2006 19:44:45 -0000
@@ -657,23 +657,6 @@ nautilus_window_content_view_matches_iid
 }
 
 
-static gboolean
-another_navigation_window_already_showing (NautilusWindow *the_window)
-{
-	GList *list, *item;
-	
-	list = nautilus_application_get_window_list ();
-	for (item = list; item != NULL; item = item->next) {
-		if (item->data != the_window &&
-		    NAUTILUS_IS_NAVIGATION_WINDOW (item->data)) {
-			return TRUE;
-		}
-	}
-	
-	return FALSE;
-}
-
-
 /*
  * begin_location_change
  * 
@@ -783,6 +766,7 @@ setup_new_window (NautilusWindow *window
 	char *show_hidden_file_setting;
 	char *geometry_string;
 	char *scroll_string;
+	gboolean maximized;
 	
 	if (NAUTILUS_IS_SPATIAL_WINDOW (window) && !NAUTILUS_IS_DESKTOP_WINDOW (window)) {
 		/* load show hidden state */
@@ -801,6 +785,14 @@ setup_new_window (NautilusWindow *window
 		g_free (show_hidden_file_setting);
 		
 		/* load the saved window geometry */
+		maximized = nautilus_file_get_boolean_metadata
+			(file, NAUTILUS_METADATA_KEY_WINDOW_MAXIMIZED, FALSE);
+		if (maximized) {
+			gtk_window_maximize (GTK_WINDOW (window));
+		} else {
+			gtk_window_unmaximize (GTK_WINDOW (window));
+		}
+
 		geometry_string = nautilus_file_get_metadata 
 			(file, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, NULL);
                 if (geometry_string != NULL) {
@@ -829,25 +821,6 @@ setup_new_window (NautilusWindow *window
 			window->details->pending_scroll_to = scroll_string;
 		}
         }
-	
-        if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
-		geometry_string = eel_preferences_get
-				(NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_SAVED_GEOMETRY);
-                if (geometry_string != NULL &&
-		    geometry_string[0] != 0) {
-			/* Ignore saved window position if a window with the same
-			 * location is already showing. That way the two windows
-			 * wont appear at the exact same location on the screen.
-			 */
-                        eel_gtk_window_set_initial_geometry_from_string 
-                                (GTK_WINDOW (window), 
-                                 geometry_string,
-                                 NAUTILUS_WINDOW_MIN_WIDTH, 
-                                 NAUTILUS_WINDOW_MIN_HEIGHT,
-				 another_navigation_window_already_showing (window));
-                }
-                g_free (geometry_string);
-	}
 }
 
 static void
Index: src/nautilus-window-private.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-private.h,v
retrieving revision 1.112
diff -u -p -r1.112 nautilus-window-private.h
--- src/nautilus-window-private.h	3 Mar 2006 13:42:24 -0000	1.112
+++ src/nautilus-window-private.h	16 Mar 2006 19:44:49 -0000
@@ -202,6 +202,10 @@ void               nautilus_window_set_v
 void               nautilus_send_history_list_changed                    (void);
 void               nautilus_window_add_current_location_to_history_list  (NautilusWindow    *window);
 void               nautilus_remove_from_history_list_no_notify           (const char        *location);
+gboolean           nautilus_add_to_history_list_no_notify                (const char        *location,
+									  const char        *name,
+									  gboolean           has_custom_name,
+									  const char        *icon);
 GList *            nautilus_get_history_list                             (void);
 void               nautilus_window_bookmarks_preference_changed_callback (gpointer           user_data);
 void		   nautilus_window_update_icon				 (NautilusWindow    *window);
Index: src/nautilus-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window.c,v
retrieving revision 1.461
diff -u -p -r1.461 nautilus-window.c
--- src/nautilus-window.c	27 Feb 2006 15:51:47 -0000	1.461
+++ src/nautilus-window.c	16 Mar 2006 19:44:51 -0000
@@ -1334,7 +1334,7 @@ remove_from_history_list (NautilusBookma
 	}
 }
 
-static void
+static gboolean
 add_to_history_list (NautilusBookmark *bookmark)
 {
 	/* Note that the history is shared amongst all windows so
@@ -1371,8 +1371,10 @@ add_to_history_list (NautilusBookmark *b
 			}
 		}
 
-		nautilus_send_history_list_changed ();
+		return TRUE;
 	}
+
+	return FALSE;
 }
 
 void
@@ -1385,12 +1387,30 @@ nautilus_remove_from_history_list_no_not
 	g_object_unref (bookmark);
 }
 
+gboolean
+nautilus_add_to_history_list_no_notify (const char *uri,
+					const char *name,
+					gboolean has_custom_name,
+					const char *icon)
+{
+	NautilusBookmark *bookmark;
+	gboolean ret;
+
+	bookmark = nautilus_bookmark_new_with_icon (uri, name, has_custom_name, icon);
+	ret = add_to_history_list (bookmark);
+	g_object_unref (bookmark);
+
+	return ret;
+}
+
 static void
 real_add_current_location_to_history_list (NautilusWindow *window)
 {
         g_assert (NAUTILUS_IS_WINDOW (window));
                 
-        add_to_history_list (window->current_location_bookmark);
+	if (add_to_history_list (window->current_location_bookmark)) {
+		nautilus_send_history_list_changed ();
+	}
 }
 
 void


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