summaryrefslogtreecommitdiff
path: root/src/nautilus-bookmark-list.c
diff options
context:
space:
mode:
authorJohn Sullivan <sullivan@src.gnome.org>2000-06-16 02:01:05 +0000
committerJohn Sullivan <sullivan@src.gnome.org>2000-06-16 02:01:05 +0000
commit22c0f773a8faaa08a0dc3f3e9d2dcb840cbf6700 (patch)
tree400dc522566aa415936c01d9f7eeba98cfb591ef /src/nautilus-bookmark-list.c
parent2cefd51ed98f7cbc9d4f8e6622114f3b5a1c6b93 (diff)
downloadnautilus-22c0f773a8faaa08a0dc3f3e9d2dcb840cbf6700.tar.gz
Fixed bug 705 (Need to avoid network hit on startup for
each remote bookmark). Bookmarks now get their icon only when they're initially created, and then store a text version of it to disk for future sessions. We might have to update the icon at certain times later (maybe when it's used?). * libnautilus-extensions/nautilus-bookmark.h, * libnautilus-extensions/nautilus-bookmark.c: (nautilus_bookmark_copy), (nautilus_bookmark_get_pixbuf), (nautilus_bookmark_get_icon), (get_icon_for_uri), (nautilus_bookmark_new), (nautilus_bookmark_new_with_icon): Changed guts of NautilusBookmark to keep a NautilusScalableIcon around. Also some miscellaneous cleanup in this ancient file (need to do more). * libnautilus-extensions/nautilus-icon-factory.h, * libnautilus-extensions/nautilus-icon-factory.c: (get_themed_icon_file_path): Added icon != NULL assert. (get_icon_file_path): Handle NULL icon name by returning NULL; some style fixes. (nautilus_scalable_icon_get_text_pieces): New function, returns all four pieces of text used to define a NautilusScalableIcon. (nautilus_scalable_icon_new_from_text_pieces): Renamed from nautilus_scalable_icon_get and made public. (nautilus_icon_factory_get_icon_for_file), (nautilus_icon_factory_get_emblem_icon_by_name), (load_image_with_embedded_text): Updated for function renaming. * src/nautilus-bookmark-list.c: (append_bookmark_node), (make_bookmark_from_node), (nautilus_bookmark_list_load_file): Save & restore NautilusScalableIcon with each bookmark. Added custom error message when trying to open a location fails with GNOME_VFS_LOGINFAILED * src/nautilus-applicable-views.h: Define NAUTILUS_NAVIGATION_RESULT_LOGIN_FAILED * src/nautilus-applicable-views.c: (get_nautilus_navigation_result_from_gnome_vfs_result): Support GNOME_VFS_LOGINFAILED, and tweak message for unhandled case. * src/nautilus-window-manage-views.c: (nautilus_window_end_location_change_callback): Support NAUTILUS_NAVIGATION_RESULT_LOGIN_FAILED and remove message for unhandled case since complaining about unhandled cases is done elsewhere.
Diffstat (limited to 'src/nautilus-bookmark-list.c')
-rw-r--r--src/nautilus-bookmark-list.c64
1 files changed, 50 insertions, 14 deletions
diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c
index 5c84f6592..28af22fa1 100644
--- a/src/nautilus-bookmark-list.c
+++ b/src/nautilus-bookmark-list.c
@@ -32,6 +32,7 @@
#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
#include <libnautilus-extensions/nautilus-gtk-extensions.h>
+#include <libnautilus-extensions/nautilus-icon-factory.h>
#include <libnautilus-extensions/nautilus-xml-extensions.h>
#include <parser.h>
@@ -98,6 +99,8 @@ append_bookmark_node (gpointer data, gpointer user_data)
{
xmlNodePtr root_node, bookmark_node;
NautilusBookmark *bookmark;
+ NautilusScalableIcon *icon;
+ char *icon_uri, *icon_name;
g_assert (NAUTILUS_IS_BOOKMARK (data));
@@ -107,6 +110,17 @@ append_bookmark_node (gpointer data, gpointer user_data)
bookmark_node = xmlNewChild (root_node, NULL, "bookmark", NULL);
xmlSetProp (bookmark_node, "name", nautilus_bookmark_get_name (bookmark));
xmlSetProp (bookmark_node, "uri", nautilus_bookmark_get_uri (bookmark));
+
+ icon = nautilus_bookmark_get_icon (bookmark);
+ if (icon != NULL) {
+ /* Don't bother storing modifier or embedded text for bookmarks. */
+ nautilus_scalable_icon_get_text_pieces (icon, &icon_uri, &icon_name, NULL, NULL);
+ xmlSetProp (bookmark_node, "icon_uri", icon_uri);
+ xmlSetProp (bookmark_node, "icon_name", icon_name);
+ nautilus_scalable_icon_unref (icon);
+ g_free (icon_uri);
+ g_free (icon_name);
+ }
}
/**
@@ -314,6 +328,38 @@ nautilus_bookmark_list_length (NautilusBookmarkList *bookmarks)
return g_list_length (bookmarks->list);
}
+static NautilusBookmark *
+make_bookmark_from_node (xmlNodePtr node)
+{
+ xmlChar *xml_name;
+ xmlChar *xml_uri;
+ xmlChar *xml_icon_uri;
+ xmlChar *xml_icon_name;
+ NautilusScalableIcon *icon;
+ NautilusBookmark *new_bookmark;
+
+ /* Maybe should only accept bookmarks with both a name and uri? */
+ xml_name = xmlGetProp (node, "name");
+ xml_uri = xmlGetProp (node, "uri");
+ xml_icon_uri = xmlGetProp (node, "icon_uri");
+ xml_icon_name = xmlGetProp (node, "icon_name");
+
+ if (xml_icon_uri == NULL && xml_icon_name == NULL) {
+ icon = NULL;
+ } else {
+ icon = nautilus_scalable_icon_new_from_text_pieces
+ (xml_icon_uri, xml_icon_name, NULL, NULL);
+ }
+ new_bookmark = nautilus_bookmark_new_with_icon (xml_uri, xml_name, icon);
+
+ xmlFree (xml_name);
+ xmlFree (xml_uri);
+ xmlFree (xml_icon_uri);
+ xmlFree (xml_icon_name);
+
+ return new_bookmark;
+}
+
/**
* nautilus_bookmark_list_load_file:
*
@@ -325,6 +371,7 @@ nautilus_bookmark_list_load_file (NautilusBookmarkList *bookmarks)
{
xmlDocPtr doc;
xmlNodePtr node;
+ NautilusBookmark *new_bookmark;
/* Wipe out old list. */
nautilus_gtk_object_list_free (bookmarks->list);
@@ -336,20 +383,9 @@ nautilus_bookmark_list_load_file (NautilusBookmarkList *bookmarks)
node != NULL;
node = node->next) {
- if (strcmp(node->name, "bookmark") == 0) {
- xmlChar *xml_name;
- xmlChar *xml_uri;
-
- /* Maybe should only accept bookmarks with both a name and uri? */
- xml_name = xmlGetProp (node, "name");
- xml_uri = xmlGetProp (node, "uri");
-
- bookmarks->list = g_list_append
- (bookmarks->list,
- nautilus_bookmark_new (xml_uri, xml_name));
-
- xmlFree (xml_name);
- xmlFree (xml_uri);
+ if (strcmp (node->name, "bookmark") == 0) {
+ new_bookmark = make_bookmark_from_node (node);
+ bookmarks->list = g_list_append (bookmarks->list, new_bookmark);
} else if (strcmp (node->name, "window") == 0) {
xmlChar *geometry_string;