summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2005-06-23 08:27:28 +0000
committerAlexander Larsson <alexl@src.gnome.org>2005-06-23 08:27:28 +0000
commit199f10b46d760d3578179bf469fcf36520991a12 (patch)
tree4090a227bb5954f4c503ee592d6df84da787ecb6
parent5a0426d093a78234fcbf128a6d011180a761cf70 (diff)
downloadnautilus-199f10b46d760d3578179bf469fcf36520991a12.tar.gz
Patch from Jamie McCracken <jamiemcc@blueyonder.co.uk>
2005-06-23 Alexander Larsson <alexl@redhat.com> Patch from Jamie McCracken <jamiemcc@blueyonder.co.uk> * src/nautilus-bookmark-list.[ch]: Share bookmarks with gtk+. * libnautilus-private/nautilus-file-utilities.[ch]: * src/nautilus-window.c: (real_get_title): Move compute_default_title to nautilus_compute_title_for_uri. * libnautilus-private/nautilus-bookmark.[ch]: * src/nautilus-bookmarks-window.c: Add has_custom_name boolean to NautilusBookmark * src/Makefile.am: * src/nautilus-bookmark-parsing.[ch]: * src/nautilus-navigation-window-menus.c: Remove no longer needed files nautilus-bookmark-parsing.[ch].
-rw-r--r--ChangeLog20
-rw-r--r--libnautilus-private/nautilus-bookmark.c24
-rw-r--r--libnautilus-private/nautilus-bookmark.h4
-rw-r--r--libnautilus-private/nautilus-file-utilities.c37
-rw-r--r--libnautilus-private/nautilus-file-utilities.h2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/nautilus-bookmark-list.c323
-rw-r--r--src/nautilus-bookmark-list.h4
-rw-r--r--src/nautilus-bookmark-parsing.c55
-rw-r--r--src/nautilus-bookmark-parsing.h36
-rw-r--r--src/nautilus-bookmarks-window.c6
-rw-r--r--src/nautilus-navigation-window-menus.c1
-rw-r--r--src/nautilus-window.c35
13 files changed, 323 insertions, 226 deletions
diff --git a/ChangeLog b/ChangeLog
index 73f300154..cf47fa750 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2005-06-23 Alexander Larsson <alexl@redhat.com>
+
+ Patch from Jamie McCracken <jamiemcc@blueyonder.co.uk>
+
+ * src/nautilus-bookmark-list.[ch]:
+ Share bookmarks with gtk+.
+
+ * libnautilus-private/nautilus-file-utilities.[ch]:
+ * src/nautilus-window.c: (real_get_title):
+ Move compute_default_title to nautilus_compute_title_for_uri.
+
+ * libnautilus-private/nautilus-bookmark.[ch]:
+ * src/nautilus-bookmarks-window.c:
+ Add has_custom_name boolean to NautilusBookmark
+
+ * src/Makefile.am:
+ * src/nautilus-bookmark-parsing.[ch]:
+ * src/nautilus-navigation-window-menus.c:
+ Remove no longer needed files nautilus-bookmark-parsing.[ch].
+
2005-06-20 Kjartan Maraas <kmaraas@gnome.org>
* src/file-manager/fm-directory-view.c: (reset_open_with_menu),
diff --git a/libnautilus-private/nautilus-bookmark.c b/libnautilus-private/nautilus-bookmark.c
index 3335453c2..c71e3cf55 100644
--- a/libnautilus-private/nautilus-bookmark.c
+++ b/libnautilus-private/nautilus-bookmark.c
@@ -55,6 +55,7 @@ static guint signals[LAST_SIGNAL];
struct NautilusBookmarkDetails
{
char *name;
+ gboolean has_custom_name;
char *uri;
char *icon;
NautilusFile *file;
@@ -192,6 +193,7 @@ nautilus_bookmark_copy (NautilusBookmark *bookmark)
return nautilus_bookmark_new_with_icon (
bookmark->details->uri,
bookmark->details->name,
+ bookmark->details->has_custom_name,
bookmark->details->icon);
}
@@ -203,6 +205,16 @@ nautilus_bookmark_get_name (NautilusBookmark *bookmark)
return g_strdup (bookmark->details->name);
}
+
+gboolean
+nautilus_bookmark_get_has_custom_name (NautilusBookmark *bookmark)
+{
+ g_return_val_if_fail(NAUTILUS_IS_BOOKMARK (bookmark), FALSE);
+
+ return (bookmark->details->has_custom_name);
+}
+
+
GdkPixbuf *
nautilus_bookmark_get_pixbuf (NautilusBookmark *bookmark,
guint icon_size,
@@ -282,6 +294,12 @@ nautilus_bookmark_set_name (NautilusBookmark *bookmark, const char *new_name)
return TRUE;
}
+void
+nautilus_bookmark_set_has_custom_name (NautilusBookmark *bookmark, gboolean has_custom_name)
+{
+ bookmark->details->has_custom_name = has_custom_name;
+}
+
static gboolean
nautilus_bookmark_icon_is_different (NautilusBookmark *bookmark,
char *new_icon)
@@ -408,7 +426,7 @@ nautilus_bookmark_set_icon_to_default (NautilusBookmark *bookmark)
NautilusBookmark *
nautilus_bookmark_new (const char *uri, const char *name)
{
- return nautilus_bookmark_new_with_icon (uri, name, NULL);
+ return nautilus_bookmark_new_with_icon (uri, name, FALSE, NULL);
}
static void
@@ -458,7 +476,7 @@ nautilus_bookmark_connect_file (NautilusBookmark *bookmark)
}
NautilusBookmark *
-nautilus_bookmark_new_with_icon (const char *uri, const char *name,
+nautilus_bookmark_new_with_icon (const char *uri, const char *name, gboolean has_custom_name,
const char *icon)
{
NautilusBookmark *new_bookmark;
@@ -469,7 +487,7 @@ nautilus_bookmark_new_with_icon (const char *uri, const char *name,
new_bookmark->details->name = g_strdup (name);
new_bookmark->details->uri = g_strdup (uri);
-
+ new_bookmark->details->has_custom_name = has_custom_name;
new_bookmark->details->icon = g_strdup (icon);
nautilus_bookmark_connect_file (new_bookmark);
diff --git a/libnautilus-private/nautilus-bookmark.h b/libnautilus-private/nautilus-bookmark.h
index c82a4c4b5..3a408e9be 100644
--- a/libnautilus-private/nautilus-bookmark.h
+++ b/libnautilus-private/nautilus-bookmark.h
@@ -71,13 +71,17 @@ NautilusBookmark * nautilus_bookmark_new (const char
const char *name);
NautilusBookmark * nautilus_bookmark_new_with_icon (const char *uri,
const char *name,
+ gboolean has_custom_name,
const char *icon);
NautilusBookmark * nautilus_bookmark_copy (NautilusBookmark *bookmark);
char * nautilus_bookmark_get_name (NautilusBookmark *bookmark);
char * nautilus_bookmark_get_uri (NautilusBookmark *bookmark);
char * nautilus_bookmark_get_icon (NautilusBookmark *bookmark);
+gboolean nautilus_bookmark_get_has_custom_name (NautilusBookmark *bookmark);
gboolean nautilus_bookmark_set_name (NautilusBookmark *bookmark,
const char *new_name);
+void nautilus_bookmark_set_has_custom_name (NautilusBookmark *bookmark,
+ gboolean has_custom_name);
gboolean nautilus_bookmark_uri_known_not_to_exist (NautilusBookmark *bookmark);
int nautilus_bookmark_compare_with (gconstpointer a,
gconstpointer b);
diff --git a/libnautilus-private/nautilus-file-utilities.c b/libnautilus-private/nautilus-file-utilities.c
index 4227eef9f..25ebf13be 100644
--- a/libnautilus-private/nautilus-file-utilities.c
+++ b/libnautilus-private/nautilus-file-utilities.c
@@ -29,6 +29,7 @@
#include "nautilus-lib-self-check-functions.h"
#include "nautilus-metadata.h"
#include "nautilus-metafile.h"
+#include "nautilus-file.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
@@ -47,6 +48,42 @@
#define LEGACY_DESKTOP_DIRECTORY_NAME ".gnome-desktop"
#define DEFAULT_DESKTOP_DIRECTORY_MODE (0755)
+
+char *
+nautilus_compute_title_for_uri (const char *text_uri)
+{
+ NautilusFile *file;
+ GnomeVFSURI *uri;
+ char *title, *displayname;
+ const char *hostname;
+
+ hostname = NULL;
+
+ if (text_uri) {
+ file = nautilus_file_get (text_uri);
+ uri = gnome_vfs_uri_new (text_uri);
+ if (uri && !gnome_vfs_uri_is_local (uri)) {
+ hostname = gnome_vfs_uri_get_host_name (uri);
+ }
+ displayname = nautilus_file_get_display_name (file);
+ if (hostname) {
+ title = g_strdup_printf (_("%s on %s"), displayname, hostname);
+ g_free (displayname);
+ } else {
+ title = displayname;
+ }
+ if (uri) {
+ gnome_vfs_uri_unref (uri);
+ }
+ nautilus_file_unref (file);
+ } else {
+ title = g_strdup ("");
+ }
+
+ return title;
+}
+
+
gboolean
nautilus_file_name_matches_hidden_pattern (const char *name_or_relative_uri)
{
diff --git a/libnautilus-private/nautilus-file-utilities.h b/libnautilus-private/nautilus-file-utilities.h
index 7e3a6ed82..15b04c68c 100644
--- a/libnautilus-private/nautilus-file-utilities.h
+++ b/libnautilus-private/nautilus-file-utilities.h
@@ -49,6 +49,8 @@ char * nautilus_get_templates_directory (void);
char * nautilus_get_templates_directory_uri (void);
void nautilus_create_templates_directory (void);
+char * nautilus_compute_title_for_uri (const char *text_uri);
+
/* This function returns something that needs to be freed with g_free,
* is not NULL, but is not garaunteed to exist */
char * nautilus_get_desktop_directory_uri_no_create (void);
diff --git a/src/Makefile.am b/src/Makefile.am
index 723ae2236..81b2fcee4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -57,8 +57,6 @@ nautilus_SOURCES = \
nautilus-application.h \
nautilus-bookmark-list.c \
nautilus-bookmark-list.h \
- nautilus-bookmark-parsing.c \
- nautilus-bookmark-parsing.h \
nautilus-bookmarks-window.c \
nautilus-bookmarks-window.h \
nautilus-connect-server-dialog.c \
diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c
index e57bc5399..78fc81b8e 100644
--- a/src/nautilus-bookmark-list.c
+++ b/src/nautilus-bookmark-list.c
@@ -28,7 +28,6 @@
#include <config.h>
#include "nautilus-bookmark-list.h"
-#include "nautilus-bookmark-parsing.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-macros.h>
#include <eel/eel-string.h>
@@ -36,10 +35,19 @@
#include <gtk/gtksignal.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-icon-factory.h>
+#include <libgnome/gnome-macros.h>
+#include <libgnome/gnome-util.h>
+#include <libgnomevfs/gnome-vfs-types.h>
+#include <libgnomevfs/gnome-vfs-uri.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
+#include <libgnomevfs/gnome-vfs-ops.h>
+#include <libgnomevfs/gnome-vfs-volume-monitor.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <stdlib.h>
+#define MAX_BOOKMARK_LENGTH 80
+
enum {
CONTENTS_CHANGED,
LAST_SIGNAL
@@ -49,15 +57,80 @@ static guint signals[LAST_SIGNAL];
static char *window_geometry;
/* forward declarations */
-static void append_bookmark_node (gpointer list_element,
- gpointer user_data);
+
static void destroy (GtkObject *object);
-static const char *nautilus_bookmark_list_get_file_path (NautilusBookmarkList *bookmarks);
+static char * nautilus_bookmark_list_get_file_path ();
+static void nautilus_bookmark_list_class_init (NautilusBookmarkListClass *class);
static void nautilus_bookmark_list_load_file (NautilusBookmarkList *bookmarks);
static void nautilus_bookmark_list_save_file (NautilusBookmarkList *bookmarks);
static void set_window_geometry_internal (const char *string);
static void stop_monitoring_bookmark (NautilusBookmarkList *bookmarks,
NautilusBookmark *bookmark);
+static void bookmark_monitor_notify_cb (GnomeVFSMonitorHandle *handle,
+ const gchar *monitor_uri,
+ const gchar *info_uri,
+ GnomeVFSMonitorEventType event_type,
+ gpointer user_data);
+
+
+static char *
+get_default_bookmark_name (const char *text_uri)
+{
+ char *title;
+
+ title = nautilus_compute_title_for_uri (text_uri);
+ title = eel_str_middle_truncate (title, MAX_BOOKMARK_LENGTH);
+ return title;
+
+}
+
+static NautilusBookmark *
+new_bookmark_from_uri (const char *uri, const char *label)
+{
+ NautilusBookmark *new_bookmark;
+ NautilusFile *file;
+ char *name, *icon_name;
+ gboolean has_label;
+
+ has_label = FALSE;
+ if (!label) {
+ name = get_default_bookmark_name (uri);
+ } else {
+ name = g_strdup (label);
+ has_label = TRUE;
+ }
+
+ if (uri) {
+ file = nautilus_file_get (uri);
+ icon_name = NULL;
+ if (nautilus_icon_factory_is_icon_ready_for_file (file)) {
+ icon_name = nautilus_icon_factory_get_icon_for_file (file, FALSE);
+ }
+ if (!icon_name) {
+ icon_name = g_strdup ("gnome-fs-directory");
+ }
+
+ new_bookmark = nautilus_bookmark_new_with_icon (uri, name, has_label, icon_name);
+ nautilus_file_unref (file);
+ g_free (icon_name);
+ g_free (name);
+
+ return new_bookmark;
+ }
+
+ g_free (name);
+ return NULL;
+}
+
+static char *
+nautilus_bookmark_list_get_file_path ()
+{
+ char *file_path;
+ file_path = g_build_filename (g_get_home_dir (),
+ ".gtk-bookmarks",
+ NULL);
+ return file_path;
+}
/* Initialization. */
@@ -83,8 +156,18 @@ nautilus_bookmark_list_class_init (NautilusBookmarkListClass *class)
static void
nautilus_bookmark_list_init (NautilusBookmarkList *bookmarks)
-{
+{
+
+ char *uri;
+
nautilus_bookmark_list_load_file (bookmarks);
+ uri = nautilus_bookmark_list_get_file_path ();
+ gnome_vfs_monitor_add ( &bookmarks->handle,
+ uri,
+ GNOME_VFS_MONITOR_FILE,
+ bookmark_monitor_notify_cb,
+ bookmarks);
+ g_free (uri);
}
EEL_CLASS_BOILERPLATE (NautilusBookmarkList, nautilus_bookmark_list, GTK_TYPE_OBJECT)
@@ -110,46 +193,14 @@ clear (NautilusBookmarkList *bookmarks)
static void
destroy (GtkObject *object)
{
+ if (NAUTILUS_BOOKMARK_LIST (object)->handle != NULL) {
+ gnome_vfs_monitor_cancel (NAUTILUS_BOOKMARK_LIST (object)->handle);
+ NAUTILUS_BOOKMARK_LIST (object)->handle = NULL;
+ }
clear (NAUTILUS_BOOKMARK_LIST (object));
}
-/**
- * append_bookmark_node:
- *
- * Foreach function; add a single bookmark xml node to a root node.
- * @data: a NautilusBookmark * that is the data of a GList node
- * @user_data: the xmlNodePtr to add a node to.
- **/
-static void
-append_bookmark_node (gpointer data, gpointer user_data)
-{
- xmlNodePtr root_node, bookmark_node;
- NautilusBookmark *bookmark;
- char *icon;
- char *bookmark_uri, *bookmark_name;
-
- g_assert (NAUTILUS_IS_BOOKMARK (data));
-
- bookmark = NAUTILUS_BOOKMARK (data);
- root_node = (xmlNodePtr) user_data;
-
- bookmark_name = nautilus_bookmark_get_name (bookmark);
- bookmark_uri = nautilus_bookmark_get_uri (bookmark);
-
- bookmark_node = xmlNewChild (root_node, NULL, "bookmark", NULL);
- xmlSetProp (bookmark_node, "name", bookmark_name);
- xmlSetProp (bookmark_node, "uri", bookmark_uri);
- g_free (bookmark_name);
- g_free (bookmark_uri);
-
- icon = nautilus_bookmark_get_icon (bookmark);
- if (icon != NULL) {
- /* Don't bother storing modifier or embedded text for bookmarks. */
- xmlSetProp (bookmark_node, "icon_name", icon);
- g_free (icon);
- }
-}
static void
bookmark_in_list_changed_callback (NautilusBookmark *bookmark,
@@ -310,22 +361,7 @@ nautilus_bookmark_list_delete_items_with_uri (NautilusBookmarkList *bookmarks,
}
}
-static const char *
-nautilus_bookmark_list_get_file_path (NautilusBookmarkList *bookmarks)
-{
- /* currently hardwired */
-
- static char *file_path = NULL;
- char *user_directory;
- if (file_path == NULL) {
- user_directory = nautilus_get_user_directory ();
- file_path = g_build_filename (user_directory, "bookmarks.xml", NULL);
- g_free (user_directory);
- }
-
- return file_path;
-}
/**
* nautilus_bookmark_list_get_window_geometry:
@@ -409,41 +445,50 @@ nautilus_bookmark_list_length (NautilusBookmarkList *bookmarks)
static void
nautilus_bookmark_list_load_file (NautilusBookmarkList *bookmarks)
{
- xmlDocPtr doc;
- xmlNodePtr node;
+ char *filename, *contents;
+
+ filename = nautilus_bookmark_list_get_file_path ();
/* Wipe out old list. */
clear (bookmarks);
- if (!g_file_test (nautilus_bookmark_list_get_file_path (bookmarks),
+ if (!g_file_test (filename,
G_FILE_TEST_EXISTS)) {
+ g_free (filename);
return;
}
/* Read new list from file */
- doc = xmlParseFile (nautilus_bookmark_list_get_file_path (bookmarks));
- for (node = eel_xml_get_root_children (doc);
- node != NULL;
- node = node->next) {
-
- if (node->type != XML_ELEMENT_NODE) {
- continue;
- }
-
- if (strcmp (node->name, "bookmark") == 0) {
- insert_bookmark_internal (bookmarks,
- nautilus_bookmark_new_from_node (node),
- -1);
- } else if (strcmp (node->name, "window") == 0) {
- xmlChar *geometry_string;
-
- geometry_string = xmlGetProp (node, "geometry");
- set_window_geometry_internal (geometry_string);
- xmlFree (geometry_string);
+ GError **error = NULL;
+ if (g_file_get_contents (filename, &contents, NULL, error)) {
+ char **lines;
+ int i;
+ lines = g_strsplit (contents, "\n", -1);
+ for (i = 0; lines[i]; i++) {
+ if (lines[i][0]) {
+ /* gtk 2.7/2.8 might have labels appended to bookmarks which are separated by a space */
+ /* we must seperate the bookmark uri and the potential label */
+ char *space, *label;
+
+ label = NULL;
+ space = strchr (lines[i], ' ');
+ if (space) {
+ *space = '\0';
+ label = g_strdup (space + 1);
+ }
+ insert_bookmark_internal (bookmarks,
+ new_bookmark_from_uri (lines[i], label),
+ -1);
+
+ if (label) {
+ g_free (label);
+ }
+ }
}
+ g_free (contents);
+ g_strfreev (lines);
}
-
- xmlFreeDoc(doc);
+ g_free (filename);
}
/**
@@ -474,26 +519,100 @@ nautilus_bookmark_list_new (void)
static void
nautilus_bookmark_list_save_file (NautilusBookmarkList *bookmarks)
{
- xmlDocPtr doc;
- xmlNodePtr root, node;
+ char *tmp_filename, *filename;
+ NautilusBookmark *bookmark;
+ FILE *file;
+ int fd;
+ int saved_errno;
+
+ filename = nautilus_bookmark_list_get_file_path ();
+ tmp_filename = g_strconcat(filename, "XXXXXX", NULL);
+
+ /* First, write a temporary file */
+ fd = g_mkstemp (tmp_filename);
+ if (fd == -1) {
+ g_warning ("make %s failed", tmp_filename);
+ saved_errno = errno;
+ goto io_error;
+ }
+
+ if ((file = fdopen (fd, "w")) != NULL) {
+ GList *l;
+
+ for (l = bookmarks->list; l; l = l->next) {
+ char *bookmark_string;
+ bookmark = NAUTILUS_BOOKMARK (l->data);
+
+ /* make sure we save label if it has one for compatibility with GTK 2.7 and 2.8 */
+ if (nautilus_bookmark_get_has_custom_name (bookmark)) {
+ char *label, *uri;
+ label = nautilus_bookmark_get_name (bookmark);
+ uri = nautilus_bookmark_get_uri (bookmark);
+ bookmark_string = g_strconcat (uri, " ", label, NULL);
+ g_free (uri);
+ g_free (label);
+ } else {
+ bookmark_string = nautilus_bookmark_get_uri (bookmark);
+ }
+ if (fputs (bookmark_string, file) == EOF || fputs ("\n", file) == EOF) {
+ saved_errno = errno;
+ g_warning ("writing %s to file failed", bookmark_string);
+ g_free (bookmark_string);
+ goto io_error;
+ }
+ g_free (bookmark_string);
+ }
+
+ if (fclose (file) == EOF) {
+ saved_errno = errno;
+ g_warning ("fclose file failed");
+ goto io_error;
+ }
- doc = xmlNewDoc ("1.0");
- root = xmlNewDocNode (doc, NULL, "bookmarks", NULL);
- xmlDocSetRootElement (doc, root);
- /* save window position */
- if (window_geometry != NULL) {
- node = xmlNewChild (root, NULL, "window", NULL);
- xmlSetProp (node, "geometry", window_geometry);
- }
+ /* temporarily disable bookmark file monitoring when writing file */
+ if (bookmarks->handle != NULL) {
+ gnome_vfs_monitor_cancel (bookmarks->handle);
+ }
+
+ if (rename (tmp_filename, filename) == -1) {
+ g_warning ("rename failed");
+ saved_errno = errno;
+ goto io_error;
+ }
- /* save bookmarks */
- g_list_foreach (bookmarks->list, append_bookmark_node, root);
+ goto out;
+ } else {
+ saved_errno = errno;
+
+ /* fdopen() failed, so we can't do much error checking here anyway */
+ close (fd);
+ }
+
+io_error:
+ g_warning ("Bookmark saving failed (%d)", saved_errno );
+
+
+ if (fd != -1) {
+ unlink (tmp_filename); /* again, not much error checking we can do here */
+ }
+
+out:
+
+
+ /* re-enable bookmark file monitoring */
+ gnome_vfs_monitor_add (&bookmarks->handle,
+ filename,
+ GNOME_VFS_MONITOR_FILE,
+ bookmark_monitor_notify_cb,
+ bookmarks);
+
+ g_free (filename);
+ g_free (tmp_filename);
- xmlSaveFile (nautilus_bookmark_list_get_file_path (bookmarks), doc);
- xmlFreeDoc (doc);
}
+
/**
* nautilus_bookmark_list_set_window_geometry:
*
@@ -521,3 +640,19 @@ set_window_geometry_internal (const char *string)
g_free (window_geometry);
window_geometry = g_strdup (string);
}
+
+static void
+bookmark_monitor_notify_cb (GnomeVFSMonitorHandle *handle,
+ const gchar *monitor_uri,
+ const gchar *info_uri,
+ GnomeVFSMonitorEventType event_type,
+ gpointer user_data)
+{
+ if (event_type == GNOME_VFS_MONITOR_EVENT_CHANGED) {
+ g_return_if_fail (NAUTILUS_IS_BOOKMARK_LIST (NAUTILUS_BOOKMARK_LIST(user_data)));
+ nautilus_bookmark_list_load_file (NAUTILUS_BOOKMARK_LIST(user_data));
+ g_signal_emit (user_data,
+ signals[CONTENTS_CHANGED], 0);
+ }
+}
+
diff --git a/src/nautilus-bookmark-list.h b/src/nautilus-bookmark-list.h
index 9743937fc..eb4854d91 100644
--- a/src/nautilus-bookmark-list.h
+++ b/src/nautilus-bookmark-list.h
@@ -29,6 +29,7 @@
#define NAUTILUS_BOOKMARK_LIST_H
#include <libnautilus-private/nautilus-bookmark.h>
+#include <libgnomevfs/gnome-vfs-ops.h>
typedef struct NautilusBookmarkList NautilusBookmarkList;
typedef struct NautilusBookmarkListClass NautilusBookmarkListClass;
@@ -46,7 +47,8 @@ typedef struct NautilusBookmarkListClass NautilusBookmarkListClass;
struct NautilusBookmarkList {
GtkObject object;
- GList *list;
+ GList *list;
+ GnomeVFSMonitorHandle *handle;
};
struct NautilusBookmarkListClass {
diff --git a/src/nautilus-bookmark-parsing.c b/src/nautilus-bookmark-parsing.c
deleted file mode 100644
index e1c1914b3..000000000
--- a/src/nautilus-bookmark-parsing.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/*
- * Nautilus
- *
- * Copyright (C) 1999, 2000 Eazel, Inc.
- *
- * Nautilus is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * Nautilus 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Authors: John Sullivan <sullivan@eazel.com>
- */
-
-/* nautilus-bookmark-parsing.c - routines to parse bookmarks from XML data.
- */
-
-#include <config.h>
-#include "nautilus-bookmark-parsing.h"
-
-#include <eel/eel-xml-extensions.h>
-#include <libxml/globals.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
-#include <stdlib.h>
-
-NautilusBookmark *
-nautilus_bookmark_new_from_node (xmlNodePtr node)
-{
- xmlChar *name, *uri;
- xmlChar *icon_name;
- NautilusBookmark *new_bookmark;
-
- /* Maybe should only accept bookmarks with both a name and uri? */
- name = eel_xml_get_property_translated (node, "name");
- uri = xmlGetProp (node, "uri");
- icon_name = xmlGetProp (node, "icon_name");
-
- new_bookmark = nautilus_bookmark_new_with_icon (uri, name, icon_name);
-
- xmlFree (name);
- xmlFree (uri);
- xmlFree (icon_name);
-
- return new_bookmark;
-}
diff --git a/src/nautilus-bookmark-parsing.h b/src/nautilus-bookmark-parsing.h
deleted file mode 100644
index 25301f937..000000000
--- a/src/nautilus-bookmark-parsing.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/*
- * Nautilus
- *
- * Copyright (C) 1999, 2000 Eazel, Inc.
- *
- * Nautilus is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * Nautilus 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Authors: John Sullivan <sullivan@eazel.com>
- */
-
-/* nautilus-bookmark-parsing.h - routines to parse bookmarks from XML data.
- */
-
-#ifndef NAUTILUS_BOOKMARK_PARSING_H
-#define NAUTILUS_BOOKMARK_PARSING_H
-
-#include <libnautilus-private/nautilus-bookmark.h>
-#include <libxml/tree.h>
-
-NautilusBookmark *nautilus_bookmark_new_from_node (xmlNodePtr node);
-
-#endif /* NAUTILUS_BOOKMARK_PARSING_H */
diff --git a/src/nautilus-bookmarks-window.c b/src/nautilus-bookmarks-window.c
index 04742c71e..2619f1fa7 100644
--- a/src/nautilus-bookmarks-window.c
+++ b/src/nautilus-bookmarks-window.c
@@ -57,6 +57,7 @@ static int name_field_changed_signal_id;
static GtkWidget *remove_button = NULL;
static GtkWidget *jump_button = NULL;
static gboolean text_changed = FALSE;
+static gboolean name_text_changed = FALSE;
static GtkWidget *uri_field = NULL;
static int uri_field_changed_signal_id;
static int row_changed_signal_id;
@@ -302,6 +303,7 @@ create_bookmarks_window (NautilusBookmarkList *list, GObject *undo_manager_sourc
GTK_TREE_SELECTION (gtk_tree_view_get_selection (bookmark_list_widget));
name_field = nautilus_entry_new ();
+
gtk_widget_show (name_field);
gtk_box_pack_start (GTK_BOX (glade_xml_get_widget (gui, "bookmark_name_placeholder")),
name_field, TRUE, TRUE, 0);
@@ -529,6 +531,7 @@ on_name_field_changed (GtkEditable *editable,
gtk_entry_get_text (GTK_ENTRY (name_field)),
-1);
text_changed = TRUE;
+ name_text_changed = TRUE;
}
static void
@@ -765,6 +768,7 @@ on_selection_changed (GtkTreeSelection *treeselection,
g_signal_handler_unblock (uri_field, uri_field_changed_signal_id);
text_changed = FALSE;
+ name_text_changed = FALSE;
g_free (name);
g_free (uri);
@@ -786,6 +790,8 @@ update_bookmark_from_text (void)
(gtk_entry_get_text (GTK_ENTRY (uri_field)),
gtk_entry_get_text (GTK_ENTRY (name_field)));
+ nautilus_bookmark_set_has_custom_name (bookmark, name_text_changed);
+
selected_row = get_selected_row ();
/* turn off list updating 'cuz otherwise the list-reordering code runs
diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c
index d103992b8..fb165193c 100644
--- a/src/nautilus-navigation-window-menus.c
+++ b/src/nautilus-navigation-window-menus.c
@@ -33,7 +33,6 @@
#include "nautilus-navigation-action.h"
#include "nautilus-application.h"
#include "nautilus-bookmark-list.h"
-#include "nautilus-bookmark-parsing.h"
#include "nautilus-bookmarks-window.h"
#include "nautilus-file-management-properties.h"
#include "nautilus-property-browser.h"
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 944fa9bef..a79b040bd 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -959,39 +959,6 @@ nautilus_window_display_error (NautilusWindow *window, const char *error_msg)
gtk_widget_show (dialog);
}
-static char *
-compute_default_title (const char *text_uri)
-{
- NautilusFile *file;
- GnomeVFSURI *uri;
- char *title, *displayname;
- const char *hostname;
-
- hostname = NULL;
-
- if (text_uri) {
- file = nautilus_file_get (text_uri);
- uri = gnome_vfs_uri_new (text_uri);
- if (uri && !gnome_vfs_uri_is_local (uri)) {
- hostname = gnome_vfs_uri_get_host_name (uri);
- }
- displayname = nautilus_file_get_display_name (file);
- if (hostname) {
- title = g_strdup_printf (_("%s on %s"), displayname, hostname);
- g_free (displayname);
- } else {
- title = displayname;
- }
- if (uri) {
- gnome_vfs_uri_unref (uri);
- }
- nautilus_file_unref (file);
- } else {
- title = g_strdup ("");
- }
-
- return title;
-}
static char *
real_get_title (NautilusWindow *window)
@@ -1007,7 +974,7 @@ real_get_title (NautilusWindow *window)
}
if (title == NULL) {
- title = compute_default_title (window->details->location);
+ title = nautilus_compute_title_for_uri (window->details->location);
}
return title;