diff options
author | John Sullivan <sullivan@src.gnome.org> | 2000-02-15 19:25:37 +0000 |
---|---|---|
committer | John Sullivan <sullivan@src.gnome.org> | 2000-02-15 19:25:37 +0000 |
commit | ee43878056ae1da0732b442c20d043177f55911f (patch) | |
tree | de98935505df05c633e11298a743f6db4e2bc331 /src | |
parent | 57ec570570340bbe83d4251da95288c3fabeacde (diff) | |
download | nautilus-ee43878056ae1da0732b442c20d043177f55911f.tar.gz |
Added small icons to the Back and Forward context menus. Made window back and
forward lists store NautilusBookmark pointers instead of just char *.
Diffstat (limited to 'src')
-rw-r--r-- | src/nautilus-bookmark.c | 59 | ||||
-rw-r--r-- | src/nautilus-bookmark.h | 10 | ||||
-rw-r--r-- | src/nautilus-bookmarks-menu.c | 59 | ||||
-rw-r--r-- | src/nautilus-navigation-window.c | 55 | ||||
-rw-r--r-- | src/nautilus-navigation-window.h | 5 | ||||
-rw-r--r-- | src/nautilus-object-window.c | 55 | ||||
-rw-r--r-- | src/nautilus-object-window.h | 5 | ||||
-rw-r--r-- | src/nautilus-spatial-window.c | 55 | ||||
-rw-r--r-- | src/nautilus-spatial-window.h | 5 | ||||
-rw-r--r-- | src/nautilus-window-manage-views.c | 54 | ||||
-rw-r--r-- | src/nautilus-window.c | 55 | ||||
-rw-r--r-- | src/nautilus-window.h | 5 | ||||
-rw-r--r-- | src/ntl-window-msgs.c | 54 | ||||
-rw-r--r-- | src/ntl-window.c | 55 | ||||
-rw-r--r-- | src/ntl-window.h | 5 |
15 files changed, 300 insertions, 236 deletions
diff --git a/src/nautilus-bookmark.c b/src/nautilus-bookmark.c index 8372f6e36..314c9800b 100644 --- a/src/nautilus-bookmark.c +++ b/src/nautilus-bookmark.c @@ -34,6 +34,8 @@ struct _NautilusBookmarkDetails +static GtkWidget *create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark); + static GtkObjectClass *parent_class = NULL; /* GtkObject methods. */ @@ -219,3 +221,60 @@ nautilus_bookmark_new (const gchar *name, const gchar *uri) return new_bookmark; } +static GtkWidget * +create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark) +{ + GdkPixmap *gdk_pixmap; + GdkBitmap *mask; + + if (!nautilus_bookmark_get_pixmap_and_mask (bookmark, + NAUTILUS_ICON_SIZE_SMALLER, + &gdk_pixmap, + &mask)) + { + return NULL; + } + + return gtk_pixmap_new (gdk_pixmap, mask); +} + +/** + * nautilus_bookmark_menu_item_new: + * + * Return a menu item representing a bookmark. + * @bookmark: The bookmark the menu item represents. + * Return value: A newly-created bookmark. + **/ +GtkWidget * +nautilus_bookmark_menu_item_new (const NautilusBookmark *bookmark) +{ + GtkWidget *menu_item; + GtkWidget *pixmap_widget; + GtkWidget *accel_label; + + /* Could check gnome_preferences_get_menus_have_icons here, but these + * are more important than stock menu icons, since they're connected to + * user data. For now let's not let them be turn-offable and see if + * anyone objects strenuously. + */ + menu_item = gtk_pixmap_menu_item_new (); + + pixmap_widget = create_pixmap_widget_for_bookmark (bookmark); + if (pixmap_widget != NULL) + { + gtk_widget_show (pixmap_widget); + gtk_pixmap_menu_item_set_pixmap (GTK_PIXMAP_MENU_ITEM (menu_item), pixmap_widget); + } + + accel_label = gtk_accel_label_new (nautilus_bookmark_get_name (bookmark)); + gtk_misc_set_alignment (GTK_MISC (accel_label), 0.0, 0.5); + + gtk_container_add (GTK_CONTAINER (menu_item), accel_label); + gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (accel_label), menu_item); + gtk_widget_show (accel_label); + + return menu_item; +} + + + diff --git a/src/nautilus-bookmark.h b/src/nautilus-bookmark.h index ce3b17878..e4120090a 100644 --- a/src/nautilus-bookmark.h +++ b/src/nautilus-bookmark.h @@ -59,15 +59,19 @@ NautilusBookmark *nautilus_bookmark_new (const gchar *name, const gchar *uri); NautilusBookmark *nautilus_bookmark_copy (const NautilusBookmark *bookmark); const gchar *nautilus_bookmark_get_name (const NautilusBookmark *bookmark); -const gchar *nautilus_bookmark_get_uri (const NautilusBookmark *bookmark); +const gchar *nautilus_bookmark_get_uri (const NautilusBookmark *bookmark); +gint nautilus_bookmark_compare_with (gconstpointer a, gconstpointer b); + +/* Helper functions for displaying bookmarks */ + gboolean nautilus_bookmark_get_pixmap_and_mask (const NautilusBookmark *bookmark, guint icon_size, GdkPixmap **pixmap_return, GdkBitmap **mask_return); - +GtkWidget * nautilus_bookmark_menu_item_new + (const NautilusBookmark *bookmark); -gint nautilus_bookmark_compare_with (gconstpointer a, gconstpointer b); #endif /* NAUTILUS_BOOKMARK_H */ diff --git a/src/nautilus-bookmarks-menu.c b/src/nautilus-bookmarks-menu.c index 3cda863c9..b0ab0250a 100644 --- a/src/nautilus-bookmarks-menu.c +++ b/src/nautilus-bookmarks-menu.c @@ -39,8 +39,6 @@ static void add_bookmark_cb (GtkMenuItem *, gpointer); static void bookmark_activated_cb (GtkMenuItem *, gpointer); -GtkWidget * bookmark_menu_item_new (const NautilusBookmark *bookmark); -static GtkWidget *create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark); static void edit_bookmarks_cb (GtkMenuItem *, gpointer); static void list_changed_cb (NautilusBookmarklist *, gpointer); @@ -140,61 +138,6 @@ bookmark_activated_cb(GtkMenuItem* item, gpointer func_data) nautilus_bookmarklist_item_at(bookmarks, item_index))); } -static GtkWidget * -create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark) -{ - GdkPixmap *gdk_pixmap; - GdkBitmap *mask; - - if (!nautilus_bookmark_get_pixmap_and_mask (bookmark, - NAUTILUS_ICON_SIZE_SMALLER, - &gdk_pixmap, - &mask)) - { - return NULL; - } - - return gtk_pixmap_new (gdk_pixmap, mask); -} - -/** - * bookmark_menu_item_new: - * - * Return a menu item representing a bookmark. - * @bookmark: The bookmark the menu item represents. - * Return value: A newly-created bookmark. - **/ -GtkWidget * -bookmark_menu_item_new (const NautilusBookmark *bookmark) -{ - GtkWidget *menu_item; - GtkWidget *pixmap_widget; - GtkWidget *accel_label; - - /* Could check gnome_preferences_get_menus_have_icons here, but these - * are more important than stock menu icons, since they're connected to - * user data. For now let's not let them be turn-offable and see if - * anyone objects strenuously. - */ - menu_item = gtk_pixmap_menu_item_new (); - - pixmap_widget = create_pixmap_widget_for_bookmark (bookmark); - if (pixmap_widget != NULL) - { - gtk_widget_show (pixmap_widget); - gtk_pixmap_menu_item_set_pixmap (GTK_PIXMAP_MENU_ITEM (menu_item), pixmap_widget); - } - - accel_label = gtk_accel_label_new (nautilus_bookmark_get_name (bookmark)); - gtk_misc_set_alignment (GTK_MISC (accel_label), 0.0, 0.5); - - gtk_container_add (GTK_CONTAINER (menu_item), accel_label); - gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (accel_label), menu_item); - gtk_widget_show (accel_label); - - return menu_item; -} - static void edit_bookmarks_cb(GtkMenuItem* item, gpointer ignored) { @@ -414,7 +357,7 @@ nautilus_bookmarks_menu_repopulate (NautilusBookmarksMenu *menu) { GtkWidget *item; - item = bookmark_menu_item_new (nautilus_bookmarklist_item_at(bookmarks, index)); + item = nautilus_bookmark_menu_item_new (nautilus_bookmarklist_item_at(bookmarks, index)); /* The signal will need to know both the menu that this item is diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c index 5fd799bce..ba5173bd1 100644 --- a/src/nautilus-navigation-window.c +++ b/src/nautilus-navigation-window.c @@ -465,19 +465,21 @@ activate_back_or_forward_menu_item (GtkMenuItem *menu_item, gboolean back) { int index; - const char *uri; + NautilusBookmark *bookmark; g_assert (GTK_IS_MENU_ITEM (menu_item)); g_assert (NAUTILUS_IS_WINDOW (window)); index = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (menu_item))); - uri = g_slist_nth_data (back ? window->uris_prev : window->uris_next, index); + bookmark = NAUTILUS_BOOKMARK (g_slist_nth_data (back ? window->back_list + : window->forward_list, + index)); /* FIXME: This should do the equivalent of going back or forward n times, * rather than just going to the right uri. This is needed to * keep the back/forward chain intact. - */ - nautilus_window_goto_uri (window, uri); + */ + nautilus_window_goto_uri (window, nautilus_bookmark_get_uri (bookmark)); } static void @@ -497,18 +499,18 @@ create_back_or_forward_menu (NautilusWindow *window, gboolean back) { GtkMenu *menu; GtkWidget *menu_item; - GSList *uri_in_list; + GSList *list_link; int index; g_assert (NAUTILUS_IS_WINDOW (window)); menu = GTK_MENU (gtk_menu_new ()); - uri_in_list = back ? window->uris_prev : window->uris_next; + list_link = back ? window->back_list : window->forward_list; index = 0; - while (uri_in_list != NULL) + while (list_link != NULL) { - menu_item = gtk_menu_item_new_with_label (uri_in_list->data); + menu_item = nautilus_bookmark_menu_item_new (NAUTILUS_BOOKMARK (list_link->data)); gtk_object_set_user_data (GTK_OBJECT (menu_item), GINT_TO_POINTER (index)); gtk_widget_show (GTK_WIDGET (menu_item)); gtk_signal_connect(GTK_OBJECT(menu_item), @@ -517,7 +519,7 @@ create_back_or_forward_menu (NautilusWindow *window, gboolean back) window); gtk_menu_append (menu, menu_item); - uri_in_list = g_slist_next (uri_in_list); + list_link = g_slist_next (list_link); ++index; } @@ -751,10 +753,10 @@ static void nautilus_window_destroy (NautilusWindow *window) g_slist_free(window->meta_views); CORBA_free(window->ni); CORBA_free(window->si); - g_slist_foreach(window->uris_prev, (GFunc)g_free, NULL); - g_slist_foreach(window->uris_next, (GFunc)g_free, NULL); - g_slist_free(window->uris_prev); - g_slist_free(window->uris_next); + g_slist_foreach(window->back_list, (GFunc)gtk_object_unref, NULL); + g_slist_foreach(window->forward_list, (GFunc)gtk_object_unref, NULL); + g_slist_free(window->back_list); + g_slist_free(window->forward_list); if(window->statusbar_clear_id) g_source_remove(window->statusbar_clear_id); @@ -917,30 +919,33 @@ nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view /* FIXME: Factor toolbar stuff out into ntl-window-toolbar.c */ static void -nautilus_window_back (GtkWidget *btn, NautilusWindow *window) +nautilus_window_back_or_forward (NautilusWindow *window, gboolean back) { Nautilus_NavigationRequestInfo nri; - g_assert(window->uris_prev); + g_assert(back ? window->back_list : window->forward_list); memset(&nri, 0, sizeof(nri)); - nri.requested_uri = window->uris_prev->data; + /* FIXME: Have to cast away the const for nri.requested_uri. This field should be + * declared const. */ + nri.requested_uri = (char *)nautilus_bookmark_get_uri (back ? + window->back_list->data : + window->forward_list->data); nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; - nautilus_window_change_location(window, &nri, NULL, TRUE, FALSE); + nautilus_window_change_location(window, &nri, NULL, back, FALSE); } static void -nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window) +nautilus_window_back (GtkWidget *btn, NautilusWindow *window) { - Nautilus_NavigationRequestInfo nri; - - g_assert(window->uris_next); + nautilus_window_back_or_forward (window, TRUE); +} - memset(&nri, 0, sizeof(nri)); - nri.requested_uri = window->uris_next->data; - nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; - nautilus_window_change_location(window, &nri, NULL, FALSE, FALSE); +static void +nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window) +{ + nautilus_window_back_or_forward (window, FALSE); } const char * diff --git a/src/nautilus-navigation-window.h b/src/nautilus-navigation-window.h index 3545ffe65..03d4ea267 100644 --- a/src/nautilus-navigation-window.h +++ b/src/nautilus-navigation-window.h @@ -70,8 +70,9 @@ struct _NautilusWindow { /* Information about current location/selection */ Nautilus_NavigationInfo *ni; Nautilus_SelectionInfo *si; - /* History stuff */ - GSList *uris_prev, *uris_next; + + /* Back/Forward chain stuff. The data in these lists are NautilusBookmark pointers. */ + GSList *back_list, *forward_list; /* Current views stuff */ NautilusView *content_view; diff --git a/src/nautilus-object-window.c b/src/nautilus-object-window.c index 5fd799bce..ba5173bd1 100644 --- a/src/nautilus-object-window.c +++ b/src/nautilus-object-window.c @@ -465,19 +465,21 @@ activate_back_or_forward_menu_item (GtkMenuItem *menu_item, gboolean back) { int index; - const char *uri; + NautilusBookmark *bookmark; g_assert (GTK_IS_MENU_ITEM (menu_item)); g_assert (NAUTILUS_IS_WINDOW (window)); index = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (menu_item))); - uri = g_slist_nth_data (back ? window->uris_prev : window->uris_next, index); + bookmark = NAUTILUS_BOOKMARK (g_slist_nth_data (back ? window->back_list + : window->forward_list, + index)); /* FIXME: This should do the equivalent of going back or forward n times, * rather than just going to the right uri. This is needed to * keep the back/forward chain intact. - */ - nautilus_window_goto_uri (window, uri); + */ + nautilus_window_goto_uri (window, nautilus_bookmark_get_uri (bookmark)); } static void @@ -497,18 +499,18 @@ create_back_or_forward_menu (NautilusWindow *window, gboolean back) { GtkMenu *menu; GtkWidget *menu_item; - GSList *uri_in_list; + GSList *list_link; int index; g_assert (NAUTILUS_IS_WINDOW (window)); menu = GTK_MENU (gtk_menu_new ()); - uri_in_list = back ? window->uris_prev : window->uris_next; + list_link = back ? window->back_list : window->forward_list; index = 0; - while (uri_in_list != NULL) + while (list_link != NULL) { - menu_item = gtk_menu_item_new_with_label (uri_in_list->data); + menu_item = nautilus_bookmark_menu_item_new (NAUTILUS_BOOKMARK (list_link->data)); gtk_object_set_user_data (GTK_OBJECT (menu_item), GINT_TO_POINTER (index)); gtk_widget_show (GTK_WIDGET (menu_item)); gtk_signal_connect(GTK_OBJECT(menu_item), @@ -517,7 +519,7 @@ create_back_or_forward_menu (NautilusWindow *window, gboolean back) window); gtk_menu_append (menu, menu_item); - uri_in_list = g_slist_next (uri_in_list); + list_link = g_slist_next (list_link); ++index; } @@ -751,10 +753,10 @@ static void nautilus_window_destroy (NautilusWindow *window) g_slist_free(window->meta_views); CORBA_free(window->ni); CORBA_free(window->si); - g_slist_foreach(window->uris_prev, (GFunc)g_free, NULL); - g_slist_foreach(window->uris_next, (GFunc)g_free, NULL); - g_slist_free(window->uris_prev); - g_slist_free(window->uris_next); + g_slist_foreach(window->back_list, (GFunc)gtk_object_unref, NULL); + g_slist_foreach(window->forward_list, (GFunc)gtk_object_unref, NULL); + g_slist_free(window->back_list); + g_slist_free(window->forward_list); if(window->statusbar_clear_id) g_source_remove(window->statusbar_clear_id); @@ -917,30 +919,33 @@ nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view /* FIXME: Factor toolbar stuff out into ntl-window-toolbar.c */ static void -nautilus_window_back (GtkWidget *btn, NautilusWindow *window) +nautilus_window_back_or_forward (NautilusWindow *window, gboolean back) { Nautilus_NavigationRequestInfo nri; - g_assert(window->uris_prev); + g_assert(back ? window->back_list : window->forward_list); memset(&nri, 0, sizeof(nri)); - nri.requested_uri = window->uris_prev->data; + /* FIXME: Have to cast away the const for nri.requested_uri. This field should be + * declared const. */ + nri.requested_uri = (char *)nautilus_bookmark_get_uri (back ? + window->back_list->data : + window->forward_list->data); nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; - nautilus_window_change_location(window, &nri, NULL, TRUE, FALSE); + nautilus_window_change_location(window, &nri, NULL, back, FALSE); } static void -nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window) +nautilus_window_back (GtkWidget *btn, NautilusWindow *window) { - Nautilus_NavigationRequestInfo nri; - - g_assert(window->uris_next); + nautilus_window_back_or_forward (window, TRUE); +} - memset(&nri, 0, sizeof(nri)); - nri.requested_uri = window->uris_next->data; - nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; - nautilus_window_change_location(window, &nri, NULL, FALSE, FALSE); +static void +nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window) +{ + nautilus_window_back_or_forward (window, FALSE); } const char * diff --git a/src/nautilus-object-window.h b/src/nautilus-object-window.h index 3545ffe65..03d4ea267 100644 --- a/src/nautilus-object-window.h +++ b/src/nautilus-object-window.h @@ -70,8 +70,9 @@ struct _NautilusWindow { /* Information about current location/selection */ Nautilus_NavigationInfo *ni; Nautilus_SelectionInfo *si; - /* History stuff */ - GSList *uris_prev, *uris_next; + + /* Back/Forward chain stuff. The data in these lists are NautilusBookmark pointers. */ + GSList *back_list, *forward_list; /* Current views stuff */ NautilusView *content_view; diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c index 5fd799bce..ba5173bd1 100644 --- a/src/nautilus-spatial-window.c +++ b/src/nautilus-spatial-window.c @@ -465,19 +465,21 @@ activate_back_or_forward_menu_item (GtkMenuItem *menu_item, gboolean back) { int index; - const char *uri; + NautilusBookmark *bookmark; g_assert (GTK_IS_MENU_ITEM (menu_item)); g_assert (NAUTILUS_IS_WINDOW (window)); index = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (menu_item))); - uri = g_slist_nth_data (back ? window->uris_prev : window->uris_next, index); + bookmark = NAUTILUS_BOOKMARK (g_slist_nth_data (back ? window->back_list + : window->forward_list, + index)); /* FIXME: This should do the equivalent of going back or forward n times, * rather than just going to the right uri. This is needed to * keep the back/forward chain intact. - */ - nautilus_window_goto_uri (window, uri); + */ + nautilus_window_goto_uri (window, nautilus_bookmark_get_uri (bookmark)); } static void @@ -497,18 +499,18 @@ create_back_or_forward_menu (NautilusWindow *window, gboolean back) { GtkMenu *menu; GtkWidget *menu_item; - GSList *uri_in_list; + GSList *list_link; int index; g_assert (NAUTILUS_IS_WINDOW (window)); menu = GTK_MENU (gtk_menu_new ()); - uri_in_list = back ? window->uris_prev : window->uris_next; + list_link = back ? window->back_list : window->forward_list; index = 0; - while (uri_in_list != NULL) + while (list_link != NULL) { - menu_item = gtk_menu_item_new_with_label (uri_in_list->data); + menu_item = nautilus_bookmark_menu_item_new (NAUTILUS_BOOKMARK (list_link->data)); gtk_object_set_user_data (GTK_OBJECT (menu_item), GINT_TO_POINTER (index)); gtk_widget_show (GTK_WIDGET (menu_item)); gtk_signal_connect(GTK_OBJECT(menu_item), @@ -517,7 +519,7 @@ create_back_or_forward_menu (NautilusWindow *window, gboolean back) window); gtk_menu_append (menu, menu_item); - uri_in_list = g_slist_next (uri_in_list); + list_link = g_slist_next (list_link); ++index; } @@ -751,10 +753,10 @@ static void nautilus_window_destroy (NautilusWindow *window) g_slist_free(window->meta_views); CORBA_free(window->ni); CORBA_free(window->si); - g_slist_foreach(window->uris_prev, (GFunc)g_free, NULL); - g_slist_foreach(window->uris_next, (GFunc)g_free, NULL); - g_slist_free(window->uris_prev); - g_slist_free(window->uris_next); + g_slist_foreach(window->back_list, (GFunc)gtk_object_unref, NULL); + g_slist_foreach(window->forward_list, (GFunc)gtk_object_unref, NULL); + g_slist_free(window->back_list); + g_slist_free(window->forward_list); if(window->statusbar_clear_id) g_source_remove(window->statusbar_clear_id); @@ -917,30 +919,33 @@ nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view /* FIXME: Factor toolbar stuff out into ntl-window-toolbar.c */ static void -nautilus_window_back (GtkWidget *btn, NautilusWindow *window) +nautilus_window_back_or_forward (NautilusWindow *window, gboolean back) { Nautilus_NavigationRequestInfo nri; - g_assert(window->uris_prev); + g_assert(back ? window->back_list : window->forward_list); memset(&nri, 0, sizeof(nri)); - nri.requested_uri = window->uris_prev->data; + /* FIXME: Have to cast away the const for nri.requested_uri. This field should be + * declared const. */ + nri.requested_uri = (char *)nautilus_bookmark_get_uri (back ? + window->back_list->data : + window->forward_list->data); nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; - nautilus_window_change_location(window, &nri, NULL, TRUE, FALSE); + nautilus_window_change_location(window, &nri, NULL, back, FALSE); } static void -nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window) +nautilus_window_back (GtkWidget *btn, NautilusWindow *window) { - Nautilus_NavigationRequestInfo nri; - - g_assert(window->uris_next); + nautilus_window_back_or_forward (window, TRUE); +} - memset(&nri, 0, sizeof(nri)); - nri.requested_uri = window->uris_next->data; - nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; - nautilus_window_change_location(window, &nri, NULL, FALSE, FALSE); +static void +nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window) +{ + nautilus_window_back_or_forward (window, FALSE); } const char * diff --git a/src/nautilus-spatial-window.h b/src/nautilus-spatial-window.h index 3545ffe65..03d4ea267 100644 --- a/src/nautilus-spatial-window.h +++ b/src/nautilus-spatial-window.h @@ -70,8 +70,9 @@ struct _NautilusWindow { /* Information about current location/selection */ Nautilus_NavigationInfo *ni; Nautilus_SelectionInfo *si; - /* History stuff */ - GSList *uris_prev, *uris_next; + + /* Back/Forward chain stuff. The data in these lists are NautilusBookmark pointers. */ + GSList *back_list, *forward_list; /* Current views stuff */ NautilusView *content_view; diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c index 9007446e7..d9f4f864d 100644 --- a/src/nautilus-window-manage-views.c +++ b/src/nautilus-window-manage-views.c @@ -191,32 +191,46 @@ nautilus_window_update_internals(NautilusWindow *window, NautilusNavigationInfo { /* Going back. Remove one item from the prev list and add the current item to the next list. */ - g_assert(window->uris_prev); - g_assert(!strcmp((const char*)window->uris_prev->data, loci->navinfo.requested_uri)); + g_assert(window->back_list); + g_assert(!strcmp(nautilus_bookmark_get_uri (NAUTILUS_BOOKMARK (window->back_list->data)), loci->navinfo.requested_uri)); g_assert(window->ni); - window->uris_next = g_slist_prepend(window->uris_next, g_strdup(window->ni->requested_uri)); - g_free(window->uris_prev->data); - window->uris_prev = g_slist_remove_link(window->uris_prev, window->uris_prev); + /* FIXME: should get the title for the document a better way, so it is web page title, e.g. */ + window->forward_list = g_slist_prepend(window->forward_list, + nautilus_bookmark_new (window->ni->requested_uri, + window->ni->requested_uri)); + gtk_object_unref(window->back_list->data); + window->back_list = g_slist_remove_link(window->back_list, window->back_list); } else { - /* Going forward. Remove one item from the next if it's the same as the the request. - Otherwise, clobber the entire next list. - */ - - if (window->uris_next && !strcmp(loci->navinfo.requested_uri, (const char*)window->uris_next->data)) - { - g_free(window->uris_next->data); - window->uris_next = g_slist_remove_link(window->uris_next, window->uris_next); - } - else + /* Not going back. Could be an arbitrary new uri, or could be going forward in the forward list. + * Remove one item from the next if it's the same as the the request. + * Otherwise, clobber the entire next list. FIXME: This is not quite correct behavior (doesn't + * match web browsers) because it doesn't distinguish between using the Forward button or list + * to move in the Forward chain and coincidentally visiting a site that happens to be in the + * Forward chain. + */ + if (window->forward_list) { - g_slist_foreach(window->uris_next, (GFunc)g_free, NULL); - g_slist_free(window->uris_next); window->uris_next = NULL; + if (strcmp (loci->navinfo.requested_uri, + nautilus_bookmark_get_uri (NAUTILUS_BOOKMARK (window->forward_list->data))) == 0) + { + gtk_object_unref(window->forward_list->data); + window->forward_list = g_slist_remove_link(window->forward_list, window->forward_list); + } + else + { + g_slist_foreach(window->forward_list, (GFunc)gtk_object_unref, NULL); + g_slist_free(window->forward_list); window->forward_list = NULL; + } } + + /* FIXME: should get the title for the document a better way, so it is web page title, e.g. */ if (window->ni) - window->uris_prev = g_slist_prepend(window->uris_prev, g_strdup(window->ni->requested_uri)); + window->back_list = g_slist_prepend(window->back_list, + nautilus_bookmark_new (window->ni->requested_uri, + window->ni->requested_uri)); } } @@ -248,8 +262,8 @@ nautilus_window_update_internals(NautilusWindow *window, NautilusNavigationInfo nautilus_index_panel_set_uri(window->index_panel, loci->navinfo.requested_uri); } - nautilus_window_allow_back(window, window->uris_prev?TRUE:FALSE); - nautilus_window_allow_forward(window, window->uris_next?TRUE:FALSE); + nautilus_window_allow_back(window, window->back_list != NULL); + nautilus_window_allow_forward(window, window->forward_list != NULL); explorer_location_bar_set_uri_string(EXPLORER_LOCATION_BAR(window->ent_uri), window->ni->requested_uri); diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 5fd799bce..ba5173bd1 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -465,19 +465,21 @@ activate_back_or_forward_menu_item (GtkMenuItem *menu_item, gboolean back) { int index; - const char *uri; + NautilusBookmark *bookmark; g_assert (GTK_IS_MENU_ITEM (menu_item)); g_assert (NAUTILUS_IS_WINDOW (window)); index = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (menu_item))); - uri = g_slist_nth_data (back ? window->uris_prev : window->uris_next, index); + bookmark = NAUTILUS_BOOKMARK (g_slist_nth_data (back ? window->back_list + : window->forward_list, + index)); /* FIXME: This should do the equivalent of going back or forward n times, * rather than just going to the right uri. This is needed to * keep the back/forward chain intact. - */ - nautilus_window_goto_uri (window, uri); + */ + nautilus_window_goto_uri (window, nautilus_bookmark_get_uri (bookmark)); } static void @@ -497,18 +499,18 @@ create_back_or_forward_menu (NautilusWindow *window, gboolean back) { GtkMenu *menu; GtkWidget *menu_item; - GSList *uri_in_list; + GSList *list_link; int index; g_assert (NAUTILUS_IS_WINDOW (window)); menu = GTK_MENU (gtk_menu_new ()); - uri_in_list = back ? window->uris_prev : window->uris_next; + list_link = back ? window->back_list : window->forward_list; index = 0; - while (uri_in_list != NULL) + while (list_link != NULL) { - menu_item = gtk_menu_item_new_with_label (uri_in_list->data); + menu_item = nautilus_bookmark_menu_item_new (NAUTILUS_BOOKMARK (list_link->data)); gtk_object_set_user_data (GTK_OBJECT (menu_item), GINT_TO_POINTER (index)); gtk_widget_show (GTK_WIDGET (menu_item)); gtk_signal_connect(GTK_OBJECT(menu_item), @@ -517,7 +519,7 @@ create_back_or_forward_menu (NautilusWindow *window, gboolean back) window); gtk_menu_append (menu, menu_item); - uri_in_list = g_slist_next (uri_in_list); + list_link = g_slist_next (list_link); ++index; } @@ -751,10 +753,10 @@ static void nautilus_window_destroy (NautilusWindow *window) g_slist_free(window->meta_views); CORBA_free(window->ni); CORBA_free(window->si); - g_slist_foreach(window->uris_prev, (GFunc)g_free, NULL); - g_slist_foreach(window->uris_next, (GFunc)g_free, NULL); - g_slist_free(window->uris_prev); - g_slist_free(window->uris_next); + g_slist_foreach(window->back_list, (GFunc)gtk_object_unref, NULL); + g_slist_foreach(window->forward_list, (GFunc)gtk_object_unref, NULL); + g_slist_free(window->back_list); + g_slist_free(window->forward_list); if(window->statusbar_clear_id) g_source_remove(window->statusbar_clear_id); @@ -917,30 +919,33 @@ nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view /* FIXME: Factor toolbar stuff out into ntl-window-toolbar.c */ static void -nautilus_window_back (GtkWidget *btn, NautilusWindow *window) +nautilus_window_back_or_forward (NautilusWindow *window, gboolean back) { Nautilus_NavigationRequestInfo nri; - g_assert(window->uris_prev); + g_assert(back ? window->back_list : window->forward_list); memset(&nri, 0, sizeof(nri)); - nri.requested_uri = window->uris_prev->data; + /* FIXME: Have to cast away the const for nri.requested_uri. This field should be + * declared const. */ + nri.requested_uri = (char *)nautilus_bookmark_get_uri (back ? + window->back_list->data : + window->forward_list->data); nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; - nautilus_window_change_location(window, &nri, NULL, TRUE, FALSE); + nautilus_window_change_location(window, &nri, NULL, back, FALSE); } static void -nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window) +nautilus_window_back (GtkWidget *btn, NautilusWindow *window) { - Nautilus_NavigationRequestInfo nri; - - g_assert(window->uris_next); + nautilus_window_back_or_forward (window, TRUE); +} - memset(&nri, 0, sizeof(nri)); - nri.requested_uri = window->uris_next->data; - nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; - nautilus_window_change_location(window, &nri, NULL, FALSE, FALSE); +static void +nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window) +{ + nautilus_window_back_or_forward (window, FALSE); } const char * diff --git a/src/nautilus-window.h b/src/nautilus-window.h index 3545ffe65..03d4ea267 100644 --- a/src/nautilus-window.h +++ b/src/nautilus-window.h @@ -70,8 +70,9 @@ struct _NautilusWindow { /* Information about current location/selection */ Nautilus_NavigationInfo *ni; Nautilus_SelectionInfo *si; - /* History stuff */ - GSList *uris_prev, *uris_next; + + /* Back/Forward chain stuff. The data in these lists are NautilusBookmark pointers. */ + GSList *back_list, *forward_list; /* Current views stuff */ NautilusView *content_view; diff --git a/src/ntl-window-msgs.c b/src/ntl-window-msgs.c index 9007446e7..d9f4f864d 100644 --- a/src/ntl-window-msgs.c +++ b/src/ntl-window-msgs.c @@ -191,32 +191,46 @@ nautilus_window_update_internals(NautilusWindow *window, NautilusNavigationInfo { /* Going back. Remove one item from the prev list and add the current item to the next list. */ - g_assert(window->uris_prev); - g_assert(!strcmp((const char*)window->uris_prev->data, loci->navinfo.requested_uri)); + g_assert(window->back_list); + g_assert(!strcmp(nautilus_bookmark_get_uri (NAUTILUS_BOOKMARK (window->back_list->data)), loci->navinfo.requested_uri)); g_assert(window->ni); - window->uris_next = g_slist_prepend(window->uris_next, g_strdup(window->ni->requested_uri)); - g_free(window->uris_prev->data); - window->uris_prev = g_slist_remove_link(window->uris_prev, window->uris_prev); + /* FIXME: should get the title for the document a better way, so it is web page title, e.g. */ + window->forward_list = g_slist_prepend(window->forward_list, + nautilus_bookmark_new (window->ni->requested_uri, + window->ni->requested_uri)); + gtk_object_unref(window->back_list->data); + window->back_list = g_slist_remove_link(window->back_list, window->back_list); } else { - /* Going forward. Remove one item from the next if it's the same as the the request. - Otherwise, clobber the entire next list. - */ - - if (window->uris_next && !strcmp(loci->navinfo.requested_uri, (const char*)window->uris_next->data)) - { - g_free(window->uris_next->data); - window->uris_next = g_slist_remove_link(window->uris_next, window->uris_next); - } - else + /* Not going back. Could be an arbitrary new uri, or could be going forward in the forward list. + * Remove one item from the next if it's the same as the the request. + * Otherwise, clobber the entire next list. FIXME: This is not quite correct behavior (doesn't + * match web browsers) because it doesn't distinguish between using the Forward button or list + * to move in the Forward chain and coincidentally visiting a site that happens to be in the + * Forward chain. + */ + if (window->forward_list) { - g_slist_foreach(window->uris_next, (GFunc)g_free, NULL); - g_slist_free(window->uris_next); window->uris_next = NULL; + if (strcmp (loci->navinfo.requested_uri, + nautilus_bookmark_get_uri (NAUTILUS_BOOKMARK (window->forward_list->data))) == 0) + { + gtk_object_unref(window->forward_list->data); + window->forward_list = g_slist_remove_link(window->forward_list, window->forward_list); + } + else + { + g_slist_foreach(window->forward_list, (GFunc)gtk_object_unref, NULL); + g_slist_free(window->forward_list); window->forward_list = NULL; + } } + + /* FIXME: should get the title for the document a better way, so it is web page title, e.g. */ if (window->ni) - window->uris_prev = g_slist_prepend(window->uris_prev, g_strdup(window->ni->requested_uri)); + window->back_list = g_slist_prepend(window->back_list, + nautilus_bookmark_new (window->ni->requested_uri, + window->ni->requested_uri)); } } @@ -248,8 +262,8 @@ nautilus_window_update_internals(NautilusWindow *window, NautilusNavigationInfo nautilus_index_panel_set_uri(window->index_panel, loci->navinfo.requested_uri); } - nautilus_window_allow_back(window, window->uris_prev?TRUE:FALSE); - nautilus_window_allow_forward(window, window->uris_next?TRUE:FALSE); + nautilus_window_allow_back(window, window->back_list != NULL); + nautilus_window_allow_forward(window, window->forward_list != NULL); explorer_location_bar_set_uri_string(EXPLORER_LOCATION_BAR(window->ent_uri), window->ni->requested_uri); diff --git a/src/ntl-window.c b/src/ntl-window.c index 5fd799bce..ba5173bd1 100644 --- a/src/ntl-window.c +++ b/src/ntl-window.c @@ -465,19 +465,21 @@ activate_back_or_forward_menu_item (GtkMenuItem *menu_item, gboolean back) { int index; - const char *uri; + NautilusBookmark *bookmark; g_assert (GTK_IS_MENU_ITEM (menu_item)); g_assert (NAUTILUS_IS_WINDOW (window)); index = GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (menu_item))); - uri = g_slist_nth_data (back ? window->uris_prev : window->uris_next, index); + bookmark = NAUTILUS_BOOKMARK (g_slist_nth_data (back ? window->back_list + : window->forward_list, + index)); /* FIXME: This should do the equivalent of going back or forward n times, * rather than just going to the right uri. This is needed to * keep the back/forward chain intact. - */ - nautilus_window_goto_uri (window, uri); + */ + nautilus_window_goto_uri (window, nautilus_bookmark_get_uri (bookmark)); } static void @@ -497,18 +499,18 @@ create_back_or_forward_menu (NautilusWindow *window, gboolean back) { GtkMenu *menu; GtkWidget *menu_item; - GSList *uri_in_list; + GSList *list_link; int index; g_assert (NAUTILUS_IS_WINDOW (window)); menu = GTK_MENU (gtk_menu_new ()); - uri_in_list = back ? window->uris_prev : window->uris_next; + list_link = back ? window->back_list : window->forward_list; index = 0; - while (uri_in_list != NULL) + while (list_link != NULL) { - menu_item = gtk_menu_item_new_with_label (uri_in_list->data); + menu_item = nautilus_bookmark_menu_item_new (NAUTILUS_BOOKMARK (list_link->data)); gtk_object_set_user_data (GTK_OBJECT (menu_item), GINT_TO_POINTER (index)); gtk_widget_show (GTK_WIDGET (menu_item)); gtk_signal_connect(GTK_OBJECT(menu_item), @@ -517,7 +519,7 @@ create_back_or_forward_menu (NautilusWindow *window, gboolean back) window); gtk_menu_append (menu, menu_item); - uri_in_list = g_slist_next (uri_in_list); + list_link = g_slist_next (list_link); ++index; } @@ -751,10 +753,10 @@ static void nautilus_window_destroy (NautilusWindow *window) g_slist_free(window->meta_views); CORBA_free(window->ni); CORBA_free(window->si); - g_slist_foreach(window->uris_prev, (GFunc)g_free, NULL); - g_slist_foreach(window->uris_next, (GFunc)g_free, NULL); - g_slist_free(window->uris_prev); - g_slist_free(window->uris_next); + g_slist_foreach(window->back_list, (GFunc)gtk_object_unref, NULL); + g_slist_foreach(window->forward_list, (GFunc)gtk_object_unref, NULL); + g_slist_free(window->back_list); + g_slist_free(window->forward_list); if(window->statusbar_clear_id) g_source_remove(window->statusbar_clear_id); @@ -917,30 +919,33 @@ nautilus_window_remove_meta_view(NautilusWindow *window, NautilusView *meta_view /* FIXME: Factor toolbar stuff out into ntl-window-toolbar.c */ static void -nautilus_window_back (GtkWidget *btn, NautilusWindow *window) +nautilus_window_back_or_forward (NautilusWindow *window, gboolean back) { Nautilus_NavigationRequestInfo nri; - g_assert(window->uris_prev); + g_assert(back ? window->back_list : window->forward_list); memset(&nri, 0, sizeof(nri)); - nri.requested_uri = window->uris_prev->data; + /* FIXME: Have to cast away the const for nri.requested_uri. This field should be + * declared const. */ + nri.requested_uri = (char *)nautilus_bookmark_get_uri (back ? + window->back_list->data : + window->forward_list->data); nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; - nautilus_window_change_location(window, &nri, NULL, TRUE, FALSE); + nautilus_window_change_location(window, &nri, NULL, back, FALSE); } static void -nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window) +nautilus_window_back (GtkWidget *btn, NautilusWindow *window) { - Nautilus_NavigationRequestInfo nri; - - g_assert(window->uris_next); + nautilus_window_back_or_forward (window, TRUE); +} - memset(&nri, 0, sizeof(nri)); - nri.requested_uri = window->uris_next->data; - nri.new_window_default = nri.new_window_suggested = nri.new_window_enforced = Nautilus_V_FALSE; - nautilus_window_change_location(window, &nri, NULL, FALSE, FALSE); +static void +nautilus_window_fwd (GtkWidget *btn, NautilusWindow *window) +{ + nautilus_window_back_or_forward (window, FALSE); } const char * diff --git a/src/ntl-window.h b/src/ntl-window.h index 3545ffe65..03d4ea267 100644 --- a/src/ntl-window.h +++ b/src/ntl-window.h @@ -70,8 +70,9 @@ struct _NautilusWindow { /* Information about current location/selection */ Nautilus_NavigationInfo *ni; Nautilus_SelectionInfo *si; - /* History stuff */ - GSList *uris_prev, *uris_next; + + /* Back/Forward chain stuff. The data in these lists are NautilusBookmark pointers. */ + GSList *back_list, *forward_list; /* Current views stuff */ NautilusView *content_view; |