summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDarin Adler <darin@src.gnome.org>2001-02-27 23:25:53 +0000
committerDarin Adler <darin@src.gnome.org>2001-02-27 23:25:53 +0000
commit27d4785eb3c19e2b8f2c1777cea8b1916ce89908 (patch)
treedee9770f7d722ae79d69809de90258d5e90cf412 /src
parentc05003831fc379d8e743cb8392c0b9175707a367 (diff)
downloadnautilus-27d4785eb3c19e2b8f2c1777cea8b1916ce89908.tar.gz
reviewed by: John Sullivan <sullivan@eazel.com>
Finished bug 6950 (need new report_redirect call in addition to report_location_change). * src/nautilus-window-manage-views.c: (update_history): Split out this part of update_for_new_location, since it really was begging for a case statement. Added a redirect case, which does nothing (just like reload, but it needs a separate case to make sense anyway). (update_for_new_location): Use the new update_history. (report_redirect_callback): Do nothing if we are no longer at the "from" location of the redirect. In the case where we do redirect, make sure we update history properly, but don't update the back and forward lists at all. * src/nautilus-window-private.h: * src/nautilus-window.c: (remove_from_history_list): New function shared by the normal add case and the new remove call. (add_to_history_list): New name for nautilus_add_to_history_list to help emphasize it's a private function. Change to use remove_from_history_list. (nautilus_remove_from_history_list_no_notify): New call for use by the redirect code. (real_add_current_location_to_history_list), (nautilus_window_add_current_location_to_history_list): Moved these functions down to avoid adding a prototype for add_to_history_list.
Diffstat (limited to 'src')
-rw-r--r--src/nautilus-navigation-window.c82
-rw-r--r--src/nautilus-object-window.c82
-rw-r--r--src/nautilus-spatial-window.c82
-rw-r--r--src/nautilus-window-manage-views.c67
-rw-r--r--src/nautilus-window-private.h5
-rw-r--r--src/nautilus-window.c82
6 files changed, 247 insertions, 153 deletions
diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c
index 89f563d31..e978d876e 100644
--- a/src/nautilus-navigation-window.c
+++ b/src/nautilus-navigation-window.c
@@ -1509,32 +1509,39 @@ free_history_list (void)
history_list = NULL;
}
+/* Remove the this URI from the history list.
+ * Do not sent out a change notice.
+ * We pass in a bookmark for convenience.
+ */
static void
-real_add_current_location_to_history_list (NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- nautilus_add_to_history_list (window->current_location_bookmark);
-}
-
-void
-nautilus_window_add_current_location_to_history_list (NautilusWindow *window)
+remove_from_history_list (NautilusBookmark *bookmark)
{
- g_assert (NAUTILUS_IS_WINDOW (window));
+ GList *node;
- NAUTILUS_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- add_current_location_to_history_list, (window));
+ /* Compare only the uris here. Comparing the names also is not
+ * necessary and can cause problems due to the asynchronous
+ * nature of when the title of the window is set.
+ */
+ node = g_list_find_custom (history_list,
+ bookmark,
+ nautilus_bookmark_compare_uris);
+
+ /* Remove any older entry for this same item. There can be at most 1. */
+ if (node != NULL) {
+ history_list = g_list_remove_link (history_list, node);
+ gtk_object_unref (node->data);
+ g_list_free_1 (node);
+ }
}
-void
-nautilus_add_to_history_list (NautilusBookmark *bookmark)
+static void
+add_to_history_list (NautilusBookmark *bookmark)
{
/* Note that the history is shared amongst all windows so
* this is not a NautilusWindow function. Perhaps it belongs
* in its own file.
*/
static gboolean free_history_list_is_set_up;
- GList *found_link;
g_return_if_fail (NAUTILUS_IS_BOOKMARK (bookmark));
@@ -1544,23 +1551,7 @@ nautilus_add_to_history_list (NautilusBookmark *bookmark)
}
gtk_object_ref (GTK_OBJECT (bookmark));
-
- /* Compare only the uris here. Comparing the names also is not necessary
- * and can cause problems due to the asynchronous nature of when the title
- * of the window is set.
- */
- found_link = g_list_find_custom (history_list,
- bookmark,
- nautilus_bookmark_compare_uris);
-
- /* Remove any older entry for this same item. There can be at most 1. */
- if (found_link != NULL) {
- history_list = g_list_remove_link (history_list, found_link);
- gtk_object_unref (found_link->data);
- g_list_free_1 (found_link);
- }
-
- /* New item goes first. */
+ remove_from_history_list (bookmark);
history_list = g_list_prepend (history_list, bookmark);
/* Tell world that history list has changed. At least all the
@@ -1570,6 +1561,33 @@ nautilus_add_to_history_list (NautilusBookmark *bookmark)
}
void
+nautilus_remove_from_history_list_no_notify (const char *uri)
+{
+ NautilusBookmark *bookmark;
+
+ bookmark = nautilus_bookmark_new (uri, "");
+ remove_from_history_list (bookmark);
+ gtk_object_unref (GTK_OBJECT (bookmark));
+}
+
+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);
+}
+
+void
+nautilus_window_add_current_location_to_history_list (NautilusWindow *window)
+{
+ g_assert (NAUTILUS_IS_WINDOW (window));
+
+ NAUTILUS_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
+ add_current_location_to_history_list, (window));
+}
+
+void
nautilus_window_clear_forward_list (NautilusWindow *window)
{
nautilus_gtk_object_list_free (window->forward_list);
diff --git a/src/nautilus-object-window.c b/src/nautilus-object-window.c
index 89f563d31..e978d876e 100644
--- a/src/nautilus-object-window.c
+++ b/src/nautilus-object-window.c
@@ -1509,32 +1509,39 @@ free_history_list (void)
history_list = NULL;
}
+/* Remove the this URI from the history list.
+ * Do not sent out a change notice.
+ * We pass in a bookmark for convenience.
+ */
static void
-real_add_current_location_to_history_list (NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- nautilus_add_to_history_list (window->current_location_bookmark);
-}
-
-void
-nautilus_window_add_current_location_to_history_list (NautilusWindow *window)
+remove_from_history_list (NautilusBookmark *bookmark)
{
- g_assert (NAUTILUS_IS_WINDOW (window));
+ GList *node;
- NAUTILUS_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- add_current_location_to_history_list, (window));
+ /* Compare only the uris here. Comparing the names also is not
+ * necessary and can cause problems due to the asynchronous
+ * nature of when the title of the window is set.
+ */
+ node = g_list_find_custom (history_list,
+ bookmark,
+ nautilus_bookmark_compare_uris);
+
+ /* Remove any older entry for this same item. There can be at most 1. */
+ if (node != NULL) {
+ history_list = g_list_remove_link (history_list, node);
+ gtk_object_unref (node->data);
+ g_list_free_1 (node);
+ }
}
-void
-nautilus_add_to_history_list (NautilusBookmark *bookmark)
+static void
+add_to_history_list (NautilusBookmark *bookmark)
{
/* Note that the history is shared amongst all windows so
* this is not a NautilusWindow function. Perhaps it belongs
* in its own file.
*/
static gboolean free_history_list_is_set_up;
- GList *found_link;
g_return_if_fail (NAUTILUS_IS_BOOKMARK (bookmark));
@@ -1544,23 +1551,7 @@ nautilus_add_to_history_list (NautilusBookmark *bookmark)
}
gtk_object_ref (GTK_OBJECT (bookmark));
-
- /* Compare only the uris here. Comparing the names also is not necessary
- * and can cause problems due to the asynchronous nature of when the title
- * of the window is set.
- */
- found_link = g_list_find_custom (history_list,
- bookmark,
- nautilus_bookmark_compare_uris);
-
- /* Remove any older entry for this same item. There can be at most 1. */
- if (found_link != NULL) {
- history_list = g_list_remove_link (history_list, found_link);
- gtk_object_unref (found_link->data);
- g_list_free_1 (found_link);
- }
-
- /* New item goes first. */
+ remove_from_history_list (bookmark);
history_list = g_list_prepend (history_list, bookmark);
/* Tell world that history list has changed. At least all the
@@ -1570,6 +1561,33 @@ nautilus_add_to_history_list (NautilusBookmark *bookmark)
}
void
+nautilus_remove_from_history_list_no_notify (const char *uri)
+{
+ NautilusBookmark *bookmark;
+
+ bookmark = nautilus_bookmark_new (uri, "");
+ remove_from_history_list (bookmark);
+ gtk_object_unref (GTK_OBJECT (bookmark));
+}
+
+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);
+}
+
+void
+nautilus_window_add_current_location_to_history_list (NautilusWindow *window)
+{
+ g_assert (NAUTILUS_IS_WINDOW (window));
+
+ NAUTILUS_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
+ add_current_location_to_history_list, (window));
+}
+
+void
nautilus_window_clear_forward_list (NautilusWindow *window)
{
nautilus_gtk_object_list_free (window->forward_list);
diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c
index 89f563d31..e978d876e 100644
--- a/src/nautilus-spatial-window.c
+++ b/src/nautilus-spatial-window.c
@@ -1509,32 +1509,39 @@ free_history_list (void)
history_list = NULL;
}
+/* Remove the this URI from the history list.
+ * Do not sent out a change notice.
+ * We pass in a bookmark for convenience.
+ */
static void
-real_add_current_location_to_history_list (NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- nautilus_add_to_history_list (window->current_location_bookmark);
-}
-
-void
-nautilus_window_add_current_location_to_history_list (NautilusWindow *window)
+remove_from_history_list (NautilusBookmark *bookmark)
{
- g_assert (NAUTILUS_IS_WINDOW (window));
+ GList *node;
- NAUTILUS_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- add_current_location_to_history_list, (window));
+ /* Compare only the uris here. Comparing the names also is not
+ * necessary and can cause problems due to the asynchronous
+ * nature of when the title of the window is set.
+ */
+ node = g_list_find_custom (history_list,
+ bookmark,
+ nautilus_bookmark_compare_uris);
+
+ /* Remove any older entry for this same item. There can be at most 1. */
+ if (node != NULL) {
+ history_list = g_list_remove_link (history_list, node);
+ gtk_object_unref (node->data);
+ g_list_free_1 (node);
+ }
}
-void
-nautilus_add_to_history_list (NautilusBookmark *bookmark)
+static void
+add_to_history_list (NautilusBookmark *bookmark)
{
/* Note that the history is shared amongst all windows so
* this is not a NautilusWindow function. Perhaps it belongs
* in its own file.
*/
static gboolean free_history_list_is_set_up;
- GList *found_link;
g_return_if_fail (NAUTILUS_IS_BOOKMARK (bookmark));
@@ -1544,23 +1551,7 @@ nautilus_add_to_history_list (NautilusBookmark *bookmark)
}
gtk_object_ref (GTK_OBJECT (bookmark));
-
- /* Compare only the uris here. Comparing the names also is not necessary
- * and can cause problems due to the asynchronous nature of when the title
- * of the window is set.
- */
- found_link = g_list_find_custom (history_list,
- bookmark,
- nautilus_bookmark_compare_uris);
-
- /* Remove any older entry for this same item. There can be at most 1. */
- if (found_link != NULL) {
- history_list = g_list_remove_link (history_list, found_link);
- gtk_object_unref (found_link->data);
- g_list_free_1 (found_link);
- }
-
- /* New item goes first. */
+ remove_from_history_list (bookmark);
history_list = g_list_prepend (history_list, bookmark);
/* Tell world that history list has changed. At least all the
@@ -1570,6 +1561,33 @@ nautilus_add_to_history_list (NautilusBookmark *bookmark)
}
void
+nautilus_remove_from_history_list_no_notify (const char *uri)
+{
+ NautilusBookmark *bookmark;
+
+ bookmark = nautilus_bookmark_new (uri, "");
+ remove_from_history_list (bookmark);
+ gtk_object_unref (GTK_OBJECT (bookmark));
+}
+
+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);
+}
+
+void
+nautilus_window_add_current_location_to_history_list (NautilusWindow *window)
+{
+ g_assert (NAUTILUS_IS_WINDOW (window));
+
+ NAUTILUS_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
+ add_current_location_to_history_list, (window));
+}
+
+void
nautilus_window_clear_forward_list (NautilusWindow *window)
{
nautilus_gtk_object_list_free (window->forward_list);
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 06928d696..f2fdf8824 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -536,6 +536,34 @@ cancel_viewed_file_changed_callback (NautilusWindow *window)
}
}
+static void
+update_history (NautilusWindow *window,
+ NautilusLocationChangeType type,
+ const char *new_location)
+{
+ switch (type) {
+ case NAUTILUS_LOCATION_CHANGE_STANDARD:
+ nautilus_window_add_current_location_to_history_list (window);
+ handle_go_elsewhere (window, new_location);
+ return;
+ case NAUTILUS_LOCATION_CHANGE_RELOAD:
+ /* for reload there is no work to do */
+ return;
+ case NAUTILUS_LOCATION_CHANGE_BACK:
+ nautilus_window_add_current_location_to_history_list (window);
+ handle_go_back (window, new_location);
+ return;
+ case NAUTILUS_LOCATION_CHANGE_FORWARD:
+ nautilus_window_add_current_location_to_history_list (window);
+ handle_go_forward (window, new_location);
+ return;
+ case NAUTILUS_LOCATION_CHANGE_REDIRECT:
+ /* for the redirect case, the caller can do the updating */
+ return;
+ }
+ g_return_if_fail (FALSE);
+}
+
/* Handle the changes for the NautilusWindow itself. */
static void
update_for_new_location (NautilusWindow *window)
@@ -546,22 +574,8 @@ update_for_new_location (NautilusWindow *window)
new_location = window->details->pending_location;
window->details->pending_location = NULL;
- /* Maintain history lists. */
- if (window->details->location_change_type != NAUTILUS_LOCATION_CHANGE_RELOAD) {
- /* Always add new location to history list. */
- nautilus_window_add_current_location_to_history_list (window);
+ update_history (window, window->details->location_change_type, new_location);
- /* Update back and forward list. */
- if (window->details->location_change_type == NAUTILUS_LOCATION_CHANGE_BACK) {
- handle_go_back (window, new_location);
- } else if (window->details->location_change_type == NAUTILUS_LOCATION_CHANGE_FORWARD) {
- handle_go_forward (window, new_location);
- } else {
- g_assert (window->details->location_change_type == NAUTILUS_LOCATION_CHANGE_STANDARD);
- handle_go_elsewhere (window, new_location);
- }
- }
-
/* Set the new location. */
g_free (window->details->location);
window->details->location = new_location;
@@ -1832,6 +1846,8 @@ report_redirect_callback (NautilusViewFrame *view,
const char *title,
NautilusWindow *window)
{
+ const char *existing_location;
+
g_assert (NAUTILUS_IS_WINDOW (window));
if (view != window->content_view) {
@@ -1839,9 +1855,15 @@ report_redirect_callback (NautilusViewFrame *view,
return;
}
- /* FIXME bugzilla.eazel.com 6950: Ignore redirect if we aren't
- * at "from_location".
- */
+ /* Ignore redirect if we aren't already at "from_location". */
+ existing_location = window->details->pending_location;
+ if (existing_location == NULL) {
+ existing_location = window->details->location;
+ }
+ if (existing_location == NULL
+ || !nautilus_uris_match (existing_location, from_location)) {
+ return;
+ }
end_location_change (window);
@@ -1849,14 +1871,13 @@ report_redirect_callback (NautilusViewFrame *view,
to_location,
selection,
view);
+
+ nautilus_remove_from_history_list_no_notify (from_location);
+ nautilus_window_add_current_location_to_history_list (window);
- window->details->location_change_type = NAUTILUS_LOCATION_CHANGE_STANDARD;
+ window->details->location_change_type = NAUTILUS_LOCATION_CHANGE_REDIRECT;
window->details->pending_location = g_strdup (to_location);
update_for_new_location (window);
-
- /* FIXME bugzilla.eazel.com 6950: Make the history element for
- * this location overwrite the old one.
- */
}
static void
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index 3eb34a173..8cf0161fc 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -38,7 +38,8 @@ typedef enum {
NAUTILUS_LOCATION_CHANGE_STANDARD,
NAUTILUS_LOCATION_CHANGE_BACK,
NAUTILUS_LOCATION_CHANGE_FORWARD,
- NAUTILUS_LOCATION_CHANGE_RELOAD
+ NAUTILUS_LOCATION_CHANGE_RELOAD,
+ NAUTILUS_LOCATION_CHANGE_REDIRECT
} NautilusLocationChangeType;
/* FIXME bugzilla.eazel.com 2575: Migrate more fields into here. */
@@ -148,7 +149,7 @@ void nautilus_window_set_viewed_file (Nautil
NautilusFile *file);
void nautilus_send_history_list_changed (void);
void nautilus_window_add_current_location_to_history_list (NautilusWindow *window);
-void nautilus_add_to_history_list (NautilusBookmark *bookmark);
+void nautilus_remove_from_history_list_no_notify (const char *location);
GList * nautilus_get_history_list (void);
void nautilus_window_bookmarks_preference_changed_callback (gpointer user_data);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 89f563d31..e978d876e 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1509,32 +1509,39 @@ free_history_list (void)
history_list = NULL;
}
+/* Remove the this URI from the history list.
+ * Do not sent out a change notice.
+ * We pass in a bookmark for convenience.
+ */
static void
-real_add_current_location_to_history_list (NautilusWindow *window)
-{
- g_assert (NAUTILUS_IS_WINDOW (window));
-
- nautilus_add_to_history_list (window->current_location_bookmark);
-}
-
-void
-nautilus_window_add_current_location_to_history_list (NautilusWindow *window)
+remove_from_history_list (NautilusBookmark *bookmark)
{
- g_assert (NAUTILUS_IS_WINDOW (window));
+ GList *node;
- NAUTILUS_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- add_current_location_to_history_list, (window));
+ /* Compare only the uris here. Comparing the names also is not
+ * necessary and can cause problems due to the asynchronous
+ * nature of when the title of the window is set.
+ */
+ node = g_list_find_custom (history_list,
+ bookmark,
+ nautilus_bookmark_compare_uris);
+
+ /* Remove any older entry for this same item. There can be at most 1. */
+ if (node != NULL) {
+ history_list = g_list_remove_link (history_list, node);
+ gtk_object_unref (node->data);
+ g_list_free_1 (node);
+ }
}
-void
-nautilus_add_to_history_list (NautilusBookmark *bookmark)
+static void
+add_to_history_list (NautilusBookmark *bookmark)
{
/* Note that the history is shared amongst all windows so
* this is not a NautilusWindow function. Perhaps it belongs
* in its own file.
*/
static gboolean free_history_list_is_set_up;
- GList *found_link;
g_return_if_fail (NAUTILUS_IS_BOOKMARK (bookmark));
@@ -1544,23 +1551,7 @@ nautilus_add_to_history_list (NautilusBookmark *bookmark)
}
gtk_object_ref (GTK_OBJECT (bookmark));
-
- /* Compare only the uris here. Comparing the names also is not necessary
- * and can cause problems due to the asynchronous nature of when the title
- * of the window is set.
- */
- found_link = g_list_find_custom (history_list,
- bookmark,
- nautilus_bookmark_compare_uris);
-
- /* Remove any older entry for this same item. There can be at most 1. */
- if (found_link != NULL) {
- history_list = g_list_remove_link (history_list, found_link);
- gtk_object_unref (found_link->data);
- g_list_free_1 (found_link);
- }
-
- /* New item goes first. */
+ remove_from_history_list (bookmark);
history_list = g_list_prepend (history_list, bookmark);
/* Tell world that history list has changed. At least all the
@@ -1570,6 +1561,33 @@ nautilus_add_to_history_list (NautilusBookmark *bookmark)
}
void
+nautilus_remove_from_history_list_no_notify (const char *uri)
+{
+ NautilusBookmark *bookmark;
+
+ bookmark = nautilus_bookmark_new (uri, "");
+ remove_from_history_list (bookmark);
+ gtk_object_unref (GTK_OBJECT (bookmark));
+}
+
+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);
+}
+
+void
+nautilus_window_add_current_location_to_history_list (NautilusWindow *window)
+{
+ g_assert (NAUTILUS_IS_WINDOW (window));
+
+ NAUTILUS_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
+ add_current_location_to_history_list, (window));
+}
+
+void
nautilus_window_clear_forward_list (NautilusWindow *window)
{
nautilus_gtk_object_list_free (window->forward_list);