diff options
author | John Sullivan <sullivan@src.gnome.org> | 2000-06-16 02:01:05 +0000 |
---|---|---|
committer | John Sullivan <sullivan@src.gnome.org> | 2000-06-16 02:01:05 +0000 |
commit | 22c0f773a8faaa08a0dc3f3e9d2dcb840cbf6700 (patch) | |
tree | 400dc522566aa415936c01d9f7eeba98cfb591ef /libnautilus-extensions/nautilus-bookmark.c | |
parent | 2cefd51ed98f7cbc9d4f8e6622114f3b5a1c6b93 (diff) | |
download | nautilus-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 'libnautilus-extensions/nautilus-bookmark.c')
-rw-r--r-- | libnautilus-extensions/nautilus-bookmark.c | 87 |
1 files changed, 69 insertions, 18 deletions
diff --git a/libnautilus-extensions/nautilus-bookmark.c b/libnautilus-extensions/nautilus-bookmark.c index 7ee32b5f8..62ea2aa73 100644 --- a/libnautilus-extensions/nautilus-bookmark.c +++ b/libnautilus-extensions/nautilus-bookmark.c @@ -40,6 +40,7 @@ struct NautilusBookmarkDetails { char *name; char *uri; + NautilusScalableIcon *icon; }; @@ -129,9 +130,10 @@ nautilus_bookmark_copy (const NautilusBookmark *bookmark) { g_return_val_if_fail (NAUTILUS_IS_BOOKMARK (bookmark), NULL); - return nautilus_bookmark_new ( - nautilus_bookmark_get_uri (bookmark), - nautilus_bookmark_get_name (bookmark)); + return nautilus_bookmark_new_with_icon ( + bookmark->details->uri, + bookmark->details->name, + bookmark->details->icon); } const char * @@ -166,24 +168,25 @@ GdkPixbuf * nautilus_bookmark_get_pixbuf (const NautilusBookmark *bookmark, guint icon_size) { - NautilusFile *file; - GdkPixbuf *pixbuf; - - file = nautilus_file_get (nautilus_bookmark_get_uri (bookmark)); + g_return_val_if_fail (NAUTILUS_IS_BOOKMARK (bookmark), NULL); - /* FIXME bugzilla.eazel.com 461: This might be a bookmark that points - * to nothing, or maybe its uri cannot be converted to a NautilusFile - * for some other reason. It should get some sort of generic icon, but - * for now it gets none. - */ - if (file == NULL) { + if (bookmark->details->icon == NULL) { return NULL; } + + return nautilus_icon_factory_get_pixbuf_for_icon + (bookmark->details->icon, icon_size, icon_size, icon_size, icon_size); +} - pixbuf = nautilus_icon_factory_get_pixbuf_for_file (file, icon_size); - nautilus_file_unref (file); +NautilusScalableIcon * +nautilus_bookmark_get_icon (const NautilusBookmark *bookmark) +{ + g_return_val_if_fail (NAUTILUS_IS_BOOKMARK (bookmark), NULL); - return pixbuf; + if (bookmark->details->icon != NULL) { + nautilus_scalable_icon_ref (bookmark->details->icon); + } + return bookmark->details->icon; } const char * @@ -212,6 +215,29 @@ nautilus_bookmark_set_name (NautilusBookmark *bookmark, const char *new_name) bookmark->details->name = g_strdup (new_name); } +static NautilusScalableIcon * +get_icon_for_uri (const char *uri) +{ + NautilusFile *file; + NautilusScalableIcon *icon; + + file = nautilus_file_get (uri); + + /* FIXME bugzilla.eazel.com 461: This might be a bookmark that points + * to nothing, or maybe its uri cannot be converted to a NautilusFile + * for some other reason. It should get some sort of generic icon, but + * for now it gets none. + */ + if (file == NULL) { + return NULL; + } + + icon = nautilus_icon_factory_get_icon_for_file (file, NULL); + nautilus_file_unref (file); + + return icon; +} + /** * nautilus_bookmark_new: * @@ -225,6 +251,26 @@ nautilus_bookmark_set_name (NautilusBookmark *bookmark, const char *new_name) NautilusBookmark * nautilus_bookmark_new (const char *uri, const char *name) { + NautilusScalableIcon *icon; + NautilusBookmark *result; + + /* FIXME: This needs to do fancy asynch stuff to be + * notified when the icon is ready; we can't just get it + * right away like this. + */ + icon = get_icon_for_uri (uri); + result = nautilus_bookmark_new_with_icon (uri, name, icon); + if (icon != NULL) { + nautilus_scalable_icon_unref (icon); + } + + return result; +} + +NautilusBookmark * +nautilus_bookmark_new_with_icon (const char *uri, const char *name, + NautilusScalableIcon *icon) +{ NautilusBookmark *new_bookmark; new_bookmark = gtk_type_new (NAUTILUS_TYPE_BOOKMARK); @@ -232,8 +278,13 @@ nautilus_bookmark_new (const char *uri, const char *name) new_bookmark->details->name = g_strdup (name); new_bookmark->details->uri = g_strdup (uri); + if (icon != NULL) { + nautilus_scalable_icon_ref (icon); + } + new_bookmark->details->icon = icon; + return new_bookmark; -} +} static GtkWidget * create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark) @@ -252,7 +303,7 @@ create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark) } /** - * nautilus_bookmark_menu_item_new: + * nautilus_bookmarnuk_menu_item_new: * * Return a menu item representing a bookmark. * @bookmark: The bookmark the menu item represents. |