summaryrefslogtreecommitdiff
path: root/src/nautilus-bookmark-parsing.c
diff options
context:
space:
mode:
authorJohn Sullivan <sullivan@src.gnome.org>2000-07-28 18:34:13 +0000
committerJohn Sullivan <sullivan@src.gnome.org>2000-07-28 18:34:13 +0000
commit0430cc6d73028613d1d3a4214085f57f13bbaa7e (patch)
tree2c669f26e04b91a93f37d886c26eeec881b38751 /src/nautilus-bookmark-parsing.c
parent0d92144b4266746817aeb19081ae5fd5ae93b3fe (diff)
downloadnautilus-0430cc6d73028613d1d3a4214085f57f13bbaa7e.tar.gz
Finished task 1793 (Display hierarchical pre-canned set of bookmarks)
There's now a "static_bookmarks.xml" file that gets installed into the Nautilus data directory. Its contents are parsed into menu items that appear above the user's dynamic items. The static items can include hierarchy and separators. I put in silly content; someone else will have to figure out what content we want to ship. * data/static_bookmarks.xml: New file, tree of bookmarks to display. * data/Makefile.am: Install the bookmarks file into data directory. * src/nautilus-bookmark-parsing.h, * src/nautilus-bookmark-parsing.c: New files, contain xml-bookmark- parsing code that's used by both the static and dynamic bookmarks. * src/Makefile.am: tell build about new files. * src/nautilus-bookmark-list.c: (make_bookmark_from_node): Moved and renamed this into new file. (nautilus_bookmark_list_load_file): Call renamed function. * src/nautilus-window-menus.c: Renamed BookmarkHolder "in_bookmarks_menu" field to "prompt_for_removal" to clarify its use. (bookmark_holder_new), (show_bogus_bookmark_window): Accounted for name changes. (append_separator): Just moved this function. (get_static_bookmarks_file_path): New function, returns path for static bookmarks file if found. (create_menu_item_from_node): New function, creates a menu item from an xml node, recursing into folders. (append_static_bookmarks): New function, reads xml document and starts the menu-item-creation recursion. (nautilus_window_initialize_bookmarks_menu): Now calls append_static_bookmarks before handling the dynamic ones. * src/nautilus-window-private.h: New last_static_bookmark_path field in Details struct. * src/nautilus-window.c: (nautilus_window_destroy): free last_static_bookmark_path field.
Diffstat (limited to 'src/nautilus-bookmark-parsing.c')
-rw-r--r--src/nautilus-bookmark-parsing.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/nautilus-bookmark-parsing.c b/src/nautilus-bookmark-parsing.c
new file mode 100644
index 000000000..a103c6d77
--- /dev/null
+++ b/src/nautilus-bookmark-parsing.c
@@ -0,0 +1,62 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+/* nautilus-bookmark-parsing.c - routines to parse bookmarks from XML data.
+
+ Copyright (C) 2000 Eazel, Inc.
+
+ The Gnome Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The Gnome Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the Gnome Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Authors: John Sullivan <sullivan@eazel.com>
+*/
+
+#include <config.h>
+#include "nautilus-bookmark-parsing.h"
+
+#include <libnautilus-extensions/nautilus-icon-factory.h>
+
+#include <xmlmemory.h>
+
+NautilusBookmark *
+nautilus_bookmark_new_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, FALSE);
+ }
+ 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;
+}