Remove utf8 validate check (gnome_wp_props_wp_set): If the filename we

2005-10-01  Rodney Dawes  <dobey@novell.com>

	* gnome-wp-capplet.c (gnome_wp_add_image): Remove utf8 validate check
	(gnome_wp_props_wp_set): If the filename we have for the image is not
	valid utf8, convert it to utf8 before setting the key in gconf
	(gnome_wp_load_stuffs, gnome_wp_file_changed): Make sure that the
	filename is valid utf8 and the file exists with utf8 encoding, or fall
	back to filename encoding as specified by the user with glib's
	environment variables

	* gnome-wpitem.c (gnome_wp_item_new): Make sure that the name field
	is always utf8 for displaying to the user with the tree view

	* gnome-wp-xml.c (gnome_wp_xml_load_xml): Make sure that the
	filename is valid utf8 and the file exists with utf8 encoding, or fall
	back to filename encoding as specified by the user with glib's
	environment variables
	(gnome_wp_xml_save_list): If the filename is not valid utf8, then
	convert to utf8 for storing in the XML file

	Fixes #168604
This commit is contained in:
Rodney Dawes 2005-10-01 21:29:39 +00:00 committed by Rodney Dawes
parent 3d5e4d4e75
commit 95aec817a6
4 changed files with 74 additions and 12 deletions

View file

@ -122,7 +122,16 @@ static void gnome_wp_xml_load_xml (GnomeWPCapplet * capplet,
for (wpa = list->children; wpa != NULL; wpa = wpa->next) {
if (!strcmp (wpa->name, "filename")) {
if (wpa->last != NULL && wpa->last->content != NULL) {
wp->filename = g_strdup (g_strstrip (wpa->last->content));
const char * none = "(none)";
gchar *content = g_strstrip (wpa->last->content);
if (!strncmp (content, none, strlen (none)))
wp->filename = g_strdup (content);
else if (g_utf8_validate (content, -1, NULL) &&
g_file_test (content, G_FILE_TEST_EXISTS))
wp->filename = g_strdup (content);
else
wp->filename = g_filename_from_utf8 (content, -1, NULL, NULL, NULL);
} else {
break;
}
@ -361,15 +370,25 @@ void gnome_wp_xml_save_list (GnomeWPCapplet * capplet) {
for (wp = list; wp != NULL; wp = wp->next) {
GnomeWPItem * wpitem = wp->data;
const char * none = "(none)";
gchar * filename;
if (!strncmp (wpitem->filename, none, strlen (none)) ||
(g_utf8_validate (wpitem->filename, -1, NULL) &&
g_file_test (wpitem->filename, G_FILE_TEST_EXISTS)))
filename = g_strdup (wpitem->filename);
else
filename = g_filename_to_utf8 (wpitem->filename, -1, NULL, NULL, NULL);
wallpaper = xmlNewChild (root, NULL, "wallpaper", NULL);
gnome_wp_xml_set_bool (wallpaper, "deleted", wpitem->deleted);
item = xmlNewTextChild (wallpaper, NULL, "name", wpitem->name);
item = xmlNewTextChild (wallpaper, NULL, "filename", wpitem->filename);
item = xmlNewTextChild (wallpaper, NULL, "filename", filename);
item = xmlNewTextChild (wallpaper, NULL, "options", wpitem->options);
item = xmlNewTextChild (wallpaper, NULL, "shade_type", wpitem->shade_type);
item = xmlNewTextChild (wallpaper, NULL, "pcolor", wpitem->pri_color);
item = xmlNewTextChild (wallpaper, NULL, "scolor", wpitem->sec_color);
g_free (filename);
}
xmlSaveFormatFile (wpfile, wplist, 1);
xmlFreeDoc (wplist);