diff options
author | Andy Hertzfeld <andy@src.gnome.org> | 2001-03-30 08:08:03 +0000 |
---|---|---|
committer | Andy Hertzfeld <andy@src.gnome.org> | 2001-03-30 08:08:03 +0000 |
commit | a55fbe5bd79bf9baba28fdcde3d9697881cd8e4b (patch) | |
tree | 43efd991fe29c229733ea728da3d32275e460537 | |
parent | 9ebbce2b7df674831a6e612db3622522cf943e2e (diff) | |
download | nautilus-a55fbe5bd79bf9baba28fdcde3d9697881cd8e4b.tar.gz |
more work toward adding and saving annotations
* libnautilus-extensions/nautilus-annotation.c:
(save_local_annotations), (nautilus_annotation_add_annotation):
more work toward adding and saving annotations
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-annotation.c | 21 | ||||
-rw-r--r-- | libnautilus-private/nautilus-annotation.c | 21 |
3 files changed, 49 insertions, 0 deletions
@@ -1,3 +1,10 @@ +2001-03-30 Andy Hertzfeld <andy@eazel.com> + + + * libnautilus-extensions/nautilus-annotation.c: + (save_local_annotations), (nautilus_annotation_add_annotation): + more work toward adding and saving annotations + 2001-03-29 Andy Hertzfeld <andy@eazel.com> * libnautilus-extensions/nautilus-annotation.c: diff --git a/libnautilus-extensions/nautilus-annotation.c b/libnautilus-extensions/nautilus-annotation.c index 9c02348e5..b05aeb04c 100644 --- a/libnautilus-extensions/nautilus-annotation.c +++ b/libnautilus-extensions/nautilus-annotation.c @@ -675,6 +675,12 @@ has_local_annotation (const char *digest) return has_annotation; } +/* utility routine to save the passed-in xml document as a local annotations file */ +static void +save_local_annotations (xmlDocPtr document, const char *digest) +{ +} + /* utility routine to add the passed-in xml node to the file associated with the passed-in * digest. If there isn't a file, create one */ @@ -1031,6 +1037,7 @@ void nautilus_annotation_add_annotation (NautilusFile *file, char *digest; char *annotations; xmlDocPtr xml_document; + xmlNodePtr root_node, node; /* we can't handle directories yet, so just return. */ if (nautilus_file_is_directory (file)) { @@ -1056,20 +1063,34 @@ void nautilus_annotation_add_annotation (NautilusFile *file, if (annotations == NULL || strlen (annotations) == 0) { xml_document = xmlNewDoc ("1.0"); /* create the header node, with the digest attribute */ + root_node = xmlNewDocNode (xml_document, NULL, "annotations", NULL); + xmlDocSetRootElement (xml_document, root_node); + xmlSetProp (root_node, "digest", digest); } else { /* open the existing annotation and load it */ xml_document = xmlParseMemory (annotations, strlen (annotations)); + root_node = xmlDocGetRootElement (xml_document); } /* add the new entry. For now, we only support one entry per file, so we replace the old * one, if it exists, but this will change soon as we support multiple notes per file */ + if (root_node->childs == NULL) { + node = xmlNewChild (root_node, NULL, "annotation", NULL); + xmlSetProp (node, "type", annotation_type); + } else { + node = root_node->childs; + } + + xmlNodeSetContent (node, annotation_text); /* save the modified xml document back to the local repository */ + save_local_annotations (xml_document, digest); /* update the metadata date and count */ /* issue file changed symbol to update the emblem */ + nautilus_file_emit_changed (file); /* if the access is global, send it to the server */ diff --git a/libnautilus-private/nautilus-annotation.c b/libnautilus-private/nautilus-annotation.c index 9c02348e5..b05aeb04c 100644 --- a/libnautilus-private/nautilus-annotation.c +++ b/libnautilus-private/nautilus-annotation.c @@ -675,6 +675,12 @@ has_local_annotation (const char *digest) return has_annotation; } +/* utility routine to save the passed-in xml document as a local annotations file */ +static void +save_local_annotations (xmlDocPtr document, const char *digest) +{ +} + /* utility routine to add the passed-in xml node to the file associated with the passed-in * digest. If there isn't a file, create one */ @@ -1031,6 +1037,7 @@ void nautilus_annotation_add_annotation (NautilusFile *file, char *digest; char *annotations; xmlDocPtr xml_document; + xmlNodePtr root_node, node; /* we can't handle directories yet, so just return. */ if (nautilus_file_is_directory (file)) { @@ -1056,20 +1063,34 @@ void nautilus_annotation_add_annotation (NautilusFile *file, if (annotations == NULL || strlen (annotations) == 0) { xml_document = xmlNewDoc ("1.0"); /* create the header node, with the digest attribute */ + root_node = xmlNewDocNode (xml_document, NULL, "annotations", NULL); + xmlDocSetRootElement (xml_document, root_node); + xmlSetProp (root_node, "digest", digest); } else { /* open the existing annotation and load it */ xml_document = xmlParseMemory (annotations, strlen (annotations)); + root_node = xmlDocGetRootElement (xml_document); } /* add the new entry. For now, we only support one entry per file, so we replace the old * one, if it exists, but this will change soon as we support multiple notes per file */ + if (root_node->childs == NULL) { + node = xmlNewChild (root_node, NULL, "annotation", NULL); + xmlSetProp (node, "type", annotation_type); + } else { + node = root_node->childs; + } + + xmlNodeSetContent (node, annotation_text); /* save the modified xml document back to the local repository */ + save_local_annotations (xml_document, digest); /* update the metadata date and count */ /* issue file changed symbol to update the emblem */ + nautilus_file_emit_changed (file); /* if the access is global, send it to the server */ |