summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-directory-metafile.c
diff options
context:
space:
mode:
authorDarin Adler <darin@src.gnome.org>2000-12-14 23:17:36 +0000
committerDarin Adler <darin@src.gnome.org>2000-12-14 23:17:36 +0000
commitced5102634eb3d547531b7d800b8ba694c2336f0 (patch)
tree8bc61a2e06a55631572260d171e5a0fd9e1aff51 /libnautilus-private/nautilus-directory-metafile.c
parent7d699bbccc04b34e180ffd6d832f3de0ed5f8b95 (diff)
downloadnautilus-ced5102634eb3d547531b7d800b8ba694c2336f0.tar.gz
reviewed by: John Sullivan <sullivan@eazel.com>
Fix bug 2807 (support metadata removal for cases where we move/delete files) by implementing metadata removal. Fix bug 2199 (Saved icon positions ruin desktop layout features) by testing and fixing other bugs now that metadata removal is implemented. Fix bug 5164 (exception trying to drag file) by fixing a few placeholders in XML files that were still transparent and should not be. Fix bug where we don't reveal the New Folder icon (reintroduced by my changes yesterday) by computing the icon position in a way that works even before the canvas item is updated. * libnautilus-extensions/nautilus-directory-metafile.c: (get_file_node): Small change (not used for now) that might help unify the "before metafile is read" case with the code after the metafile is read. (nautilus_directory_rename_file_metadata): Remove the old file metadata before renaming the new data. Also change code to avoid looking up things in the hash table twice. (nautilus_directory_copy_file_metadata): Updated and added FIXME comments. (nautilus_directory_remove_file_metadata): Add code to remove metadata, similar to the existing rename code. * libnautilus-extensions/nautilus-directory.c: (nautilus_directory_schedule_metadata_copy), (nautilus_directory_schedule_metadata_move), (nautilus_directory_schedule_metadata_remove): Fix code that was using file names instead of relative URIs (essentially escaped file names). This code was missed when we made the switchover. Without this, changes to files with spaces in their names didn't update metadata properly. * libnautilus-extensions/nautilus-file-operations.c: (build_error_string): Added blank line between the intro sentence and the rest of the error message. (handle_xfer_overwrite): Added blank line between the intro sentence and the rest of the error message. (sync_xfer_callback): Fix metadata code to remove the metadata when creating a new file, just as it copies metadata when copying a file. This change helps the New Folder case, but requires a fix in gnome-vfs to set the top level boolean for the New Folder case. (handle_new_folder_vfs_error): Added blank line between the intro sentence and the rest of the error message. (nautilus_self_check_file_operations): Changed the self-check to use the standard way of testing functions that return text instead of rolling its own. * libnautilus-extensions/nautilus-gnome-extensions.h: * libnautilus-extensions/nautilus-gnome-extensions.c: (nautilus_gnome_canvas_item_get_canvas_bounds): Added a function that's like nautilus_gnome_canvas_item_get_current_canvas_bounds but is accurate even before the icon is updated. * libnautilus-extensions/nautilus-icon-container.c: (reveal_icon): Use nautilus_gnome_canvas_item_get_canvas_bounds instead of nautilus_gnome_canvas_item_get_current_canvas_bounds. Fixes the bug I reintroduced where New Folder icons would not be revealed. * libnautilus-extensions/nautilus-xml-extensions.h: * libnautilus-extensions/nautilus-xml-extensions.c: (nautilus_xml_remove_node): Add a remove-node function. This is needed because gnome-xml doesn't have xmlRemoveNode implemented. This implementation is not quite complete, but probably good enough for our purposes. A complete implementation might have to have some handling for removing the root node and perhaps some stuff to remove unused namespaces. Maybe this can be rolled into gnome-xml. * src/file-manager/nautilus-directory-view-ui.xml: * src/nautilus-shell-ui.xml: Added some more delimit="none" entries to make it so that the actual placeholder definitions are not "transparent". * libnautilus-extensions/nautilus-glib-extensions.c (nautilus_self_check_glib_extensions): Marked some strings that are part of a test translatable since the result might be different in some locales. Translating the strings to the right result makes "make check" work properly in that locale.
Diffstat (limited to 'libnautilus-private/nautilus-directory-metafile.c')
-rw-r--r--libnautilus-private/nautilus-directory-metafile.c89
1 files changed, 60 insertions, 29 deletions
diff --git a/libnautilus-private/nautilus-directory-metafile.c b/libnautilus-private/nautilus-directory-metafile.c
index d3305bc27..865b94eb9 100644
--- a/libnautilus-private/nautilus-directory-metafile.c
+++ b/libnautilus-private/nautilus-directory-metafile.c
@@ -98,26 +98,30 @@ get_file_node (NautilusDirectory *directory,
const char *file_name,
gboolean create)
{
- xmlNode *root, *child;
+ xmlNode *root, *node;
g_assert (NAUTILUS_IS_DIRECTORY (directory));
if (directory->details->metafile_node_hash != NULL) {
- child = g_hash_table_lookup (directory->details->metafile_node_hash,
+ node = g_hash_table_lookup (directory->details->metafile_node_hash,
file_name);
- if (child != NULL) {
- return child;
+ if (node != NULL) {
+ return node;
}
}
if (create) {
- root = create_metafile_root (directory);
- child = xmlNewChild (root, NULL, "FILE", NULL);
- xmlSetProp (child, "NAME", file_name);
+ if (directory->details->metafile_read) {
+ root = create_metafile_root (directory);
+ node = xmlNewChild (root, NULL, "FILE", NULL);
+ } else {
+ node = xmlNewNode (NULL, "FILE");
+ }
+ xmlSetProp (node, "NAME", file_name);
g_hash_table_insert (directory->details->metafile_node_hash,
xmlMemStrdup (file_name),
- child);
- return child;
+ node);
+ return node;
}
return NULL;
@@ -550,8 +554,6 @@ nautilus_directory_get_file_metadata (NautilusDirectory *directory,
}
}
-
-
GList *
nautilus_directory_get_file_metadata_list (NautilusDirectory *directory,
const char *file_name,
@@ -575,7 +577,6 @@ nautilus_directory_get_file_metadata_list (NautilusDirectory *directory,
}
}
-
gboolean
nautilus_directory_set_file_metadata (NautilusDirectory *directory,
const char *file_name,
@@ -633,27 +634,27 @@ nautilus_directory_rename_file_metadata (NautilusDirectory *directory,
const char *old_file_name,
const char *new_file_name)
{
- xmlNode *file_node;
- GHashTable *directory_table;
gboolean found;
gpointer key, value;
+ xmlNode *file_node;
+ GHashTable *directory_table;
char *old_file_uri, *new_file_uri;
+ nautilus_directory_remove_file_metadata (directory, new_file_name);
+
if (directory->details->metafile_read) {
/* Move data in XML document if present. */
- file_node = get_file_node (directory, old_file_name, FALSE);
- if (file_node != NULL) {
- xmlSetProp (file_node, "NAME", new_file_name);
- found = g_hash_table_lookup_extended (directory->details->metafile_node_hash,
- old_file_name, &key, &value);
- g_assert (found);
+ found = g_hash_table_lookup_extended (directory->details->metafile_node_hash,
+ old_file_name, &key, &value);
+ if (found) {
g_assert (strcmp (key, old_file_name) == 0);
- g_assert (value == file_node);
+ file_node = value;
g_hash_table_remove (directory->details->metafile_node_hash,
old_file_name);
xmlFree (key);
g_hash_table_insert (directory->details->metafile_node_hash,
xmlMemStrdup (new_file_name), value);
+ xmlSetProp (file_node, "NAME", new_file_name);
nautilus_directory_request_write_metafile (directory);
}
} else {
@@ -741,8 +742,6 @@ nautilus_directory_metafile_apply_pending_changes (NautilusDirectory *directory)
directory->details->metadata_changes = NULL;
}
-
-
gboolean
nautilus_directory_get_boolean_file_metadata (NautilusDirectory *directory,
const char *file_name,
@@ -833,8 +832,6 @@ nautilus_directory_set_integer_file_metadata (NautilusDirectory *directory,
g_free (default_as_string);
}
-
-
static void
copy_file_metadata_for_key (NautilusDirectory *source_directory,
const char *source_file_name,
@@ -859,10 +856,13 @@ nautilus_directory_copy_file_metadata (NautilusDirectory *source_directory,
NautilusDirectory *destination_directory,
const char *destination_file_name)
{
- /* FIXME bugzilla.eazel.com 2808: This hard-coded set of keys is not right. */
/* FIXME bugzilla.eazel.com 3343: This does nothing to ensure
* the source directory metadata is read in.
*/
+
+ /* FIXME bugzilla.eazel.com 2808: Change this to copy all the
+ * metadata, not just a hard-coded set of keys.
+ */
copy_file_metadata_for_key
(source_directory, source_file_name,
destination_directory, destination_file_name,
@@ -883,19 +883,50 @@ nautilus_directory_copy_file_metadata (NautilusDirectory *source_directory,
(source_directory, source_file_name,
destination_directory, destination_file_name,
NAUTILUS_METADATA_KEY_CUSTOM_ICON);
+
+ /* FIXME: Do we want to copy the thumbnail here like in the
+ * rename and remove cases?
+ */
}
void
nautilus_directory_remove_file_metadata (NautilusDirectory *directory,
const char *file_name)
{
+ gboolean found;
+ gpointer key, value;
+ xmlNode *file_node;
+ GHashTable *directory_table;
char *file_uri;
- file_uri = nautilus_directory_get_file_uri (directory, file_name);
-
- /* FIXME bugzilla.eazel.com 2807: This is not implemented. */
+ if (directory->details->metafile_read) {
+ /* Remove data in XML document if present. */
+ found = g_hash_table_lookup_extended (directory->details->metafile_node_hash,
+ file_name, &key, &value);
+ if (found) {
+ g_assert (strcmp (key, file_name) == 0);
+ file_node = value;
+ g_hash_table_remove (directory->details->metafile_node_hash,
+ file_name);
+ xmlFree (key);
+ nautilus_xml_remove_node (file_node);
+ xmlFreeNode (file_node);
+ nautilus_directory_request_write_metafile (directory);
+ }
+ } else {
+ /* Remove data from hash table. */
+ directory_table = directory->details->metadata_changes;
+ found = g_hash_table_lookup_extended
+ (directory_table, file_name, &key, &value);
+ if (found) {
+ g_hash_table_remove (directory_table, file_name);
+ g_free (key);
+ metadata_value_destroy (value);
+ }
+ }
/* delete the thumbnails for the file, if any */
+ file_uri = nautilus_directory_get_file_uri (directory, file_name);
nautilus_remove_thumbnail_for_file (file_uri);
g_free (file_uri);
}