Re: [Nautilus-list] [PATCH] Custom icon patch
- From: Anders Carlsson <andersca gnu org>
- To: Darin Adler <darin bentspoon com>
- Cc: nautilus-list lists eazel com
- Subject: Re: [Nautilus-list] [PATCH] Custom icon patch
- Date: 06 Jun 2001 22:20:56 +0200
On 06 Jun 2001 08:16:42 -0700, Darin Adler wrote:
> On Tuesday, June 5, 2001, at 10:30 PM, Anders Carlsson wrote:
>
> > So, my next solution would probably be to write a special xmlGetProp
> > function that would traverse the xmlAttrPtr tree and unescape any
> > occuring entities. How does that sound?
>
> Sounds good, I think.
>
> If the code to write strings with these characters works and it's just the
> code to read them that doesn't, then working around the libxml bug with
> our own xmlGetProp sounds like a good idea. You should give that a try.
>
Did that, and it seems to work. Patches are attached.
> >> Finally, what would you envision doing for the GNOME 2 time frame when we
> >> have the newer fixed version of libxml?
> >
> > Since xmlGetProp in libxml2 returns the entities unescaped in utf8
> > format this should be no problem.
>
> Even with existing metafiles that have entities that use a local character
> set? That's the part I don't get. How does libxml2 know that these old
> metafiles have characters encoded in the particular character set from a
> locale and not from UTF-8? Also, what about files on disk? How can
> Nautilus tell whether a particular disk's file names are in a
> locale-specific character set like ISO 8859-1 or in UTF-8?
>
I talked to DV about this and unfortunately there's no guarantee that
the escaped characters will be the same. But then, that is the case with
libxml1 too (if you change locale I think) and libxml2 won't have this
problem.
I did some tests writing a document with едц as a node property in
libxml1 and then reading it back with libxml2 and it worked for me,
libxml2 encoded the property in UTF8.
> > For URL cases, functions for converting between utf8 filenames and
> > gnome-vfs uris are probably needed, and for other cases (like the
> > annotations) we should just be fine since we can display such text with
> > gtk+2.
>
> Wouldn't gnome_vfs_get_uri_from_local_path convert a UTF-8 filename to a
> URI properly? And gnome_vfs_uri_new would make a GnomeVFSURI from that. I
> don't understand what you are getting at here.
>
Yes, of course. You're right. We don't need new functions, we just need
to adapt existing functions :)
> -- Darin
//andersca
andersca gnu org
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/eel/ChangeLog,v
retrieving revision 1.103
diff -u -r1.103 ChangeLog
--- ChangeLog 2001/06/05 01:13:53 1.103
+++ ChangeLog 2001/06/06 19:38:58
@@ -1,3 +1,10 @@
+2001-06-06 Anders Carlsson <andersca gnu codefactory se>
+
+ * eel/eel-xml-extensions.h (eel_xml_get_escaped_property): Add declaration.
+
+ * eel/eel-xml-extensions.c (eel_xml_get_escaped_property): New function for
+ getting a node property which contains special characters.
+
2001-06-04 Ramiro Estrugo <ramiro fateware com>
* eel/eel-debug-drawing.h:
@@ -62,6 +69,7 @@
Update for changes in debug function to view pixbufs in external
viewers.
+>>>>>>> 1.103
2001-06-04 Darin Adler <darin bentspoon com>
* eel/eel-font-manager.c: (collect_fonts_from_directory),
Index: eel/eel-xml-extensions.c
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-xml-extensions.c,v
retrieving revision 1.2
diff -u -r1.2 eel-xml-extensions.c
--- eel/eel-xml-extensions.c 2001/03/29 07:19:50 1.2
+++ eel/eel-xml-extensions.c 2001/06/06 19:38:58
@@ -214,3 +214,65 @@
node->next = NULL;
node->prev = NULL;
}
+
+/* FIXME: This function will be unnecessary when nautilus is using libxml2. */
+/**
+ * eel_xml_get_escaped_prop:
+ * @node: an xmlNodePtr
+ * @name: The name of the property to get
+ *
+ * This is a function to work around an issue in libxml1,
+ * where some characters are escaped and encoded as "entity references".
+ * xmlGetProp doesn't read and unescape these entity references.
+ * This function does that.
+ *
+ * Return value: The unescaped property value if it exists or NULL otherwise.
+ *
+ **/
+xmlChar *
+eel_xml_get_escaped_property (xmlNodePtr node, const char *property_name)
+{
+ xmlAttrPtr attrs;
+ xmlNodePtr node_value;
+ GString *result;
+ char *result_string;
+ char entity_char;
+
+ if (node == NULL)
+ return NULL;
+
+ /* Traverse the node properties to see if we have a specific property */
+ for (attrs = node->properties; attrs && attrs->name; attrs = attrs->next) {
+
+ if (strcasecmp (property_name, attrs->name) == 0) {
+
+ result = g_string_new ("");
+
+ for (node_value = attrs->val; node_value; node_value = node_value->next) {
+
+ /* Entity reference nodes consist of a hash sign
+ * followed by a number, this number is the character
+ * number of the entity.
+ */
+ if (node_value->type == XML_ENTITY_REF_NODE &&
+ node_value->name && node_value->name[0] == '#') {
+ entity_char = atoi (node_value->name + 1);
+
+ if (entity_char != 0)
+ g_string_append_c (result, entity_char);
+ }
+ else {
+ g_string_append (result, node_value->content);
+ }
+
+ }
+
+ result_string = result->str;
+ g_string_free (result, FALSE);
+
+ return result_string;
+ }
+ }
+
+ return NULL;
+}
Index: eel/eel-xml-extensions.h
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-xml-extensions.h,v
retrieving revision 1.4
diff -u -r1.4 eel-xml-extensions.h
--- eel/eel-xml-extensions.h 2001/04/04 07:51:37 1.4
+++ eel/eel-xml-extensions.h 2001/06/06 19:38:58
@@ -47,4 +47,7 @@
const char *property_name);
void eel_xml_remove_node (xmlNodePtr node);
+xmlChar *eel_xml_get_escaped_property (xmlNodePtr node,
+ const char *property_name);
+
#endif /* EEL_XML_EXTENSIONS_H */
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.4641
diff -u -r1.4641 ChangeLog
--- ChangeLog 2001/06/06 19:01:05 1.4641
+++ ChangeLog 2001/06/06 20:07:16
@@ -1,3 +1,10 @@
+2001-06-06 Anders Carlsson <andersca codefactory se>
+
+ * libnautilus-private/nautilus-metafile.c (get_metadata_from_node),
+ (set_metadata_list_in_metafile),
+ (nautilus_metafile_set_metafile_contents): replaced all xmlGetProp
+ calls with calls to eel_xml_get_escaped_property.
+
2001-06-06 Darin Adler <darin bentspoon com>
Frederic Devernay <Frederic Devernay sophia inria fr>
@@ -21,6 +28,7 @@
Updated all places where we were using the gnome-vfs file info
calls and not following links.
+>>>>>>> 1.4641
2001-06-03 Seth Nickell <snickell stanford edu>
Added Ben FrantzDale's <bfrantzdale hmc edu> revisions
Index: libnautilus-private/nautilus-metafile.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-metafile.c,v
retrieving revision 1.14
diff -u -r1.14 nautilus-metafile.c
--- libnautilus-private/nautilus-metafile.c 2001/06/06 19:01:15 1.14
+++ libnautilus-private/nautilus-metafile.c 2001/06/06 20:07:16
@@ -802,7 +802,7 @@
g_return_val_if_fail (key != NULL, NULL);
g_return_val_if_fail (key[0] != '\0', NULL);
- property = xmlGetProp (node, key);
+ property = eel_xml_get_escaped_property (node, key);
if (property == NULL) {
result = g_strdup (default_metadata);
} else {
@@ -967,7 +967,7 @@
next = child->next;
if (strcmp (child->name, list_key) == 0) {
- property = xmlGetProp (child, list_subkey);
+ property = eel_xml_get_escaped_property (child, list_subkey);
if (property != NULL && p != NULL
&& strcmp (property, (char *) p->data) == 0) {
p = p->next;
@@ -1639,7 +1639,7 @@
for (node = eel_xml_get_root_children (metafile_contents);
node != NULL; node = node->next) {
if (strcmp (node->name, "file") == 0) {
- name = xmlGetProp (node, "name");
+ name = eel_xml_get_escaped_property (node, "name");
if (g_hash_table_lookup (hash, name) != NULL) {
xmlFree (name);
/* FIXME: Should we delete duplicate nodes as we discover them? */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]