BUG44867: multiple colors with same name (patch)
- From: "Daniel Godas Lopez" <siro eurielec etsit upm es>
- To: nautilus-list gnome org
- Subject: BUG44867: multiple colors with same name (patch)
- Date: Sat, 28 Aug 2004 13:18:02 +0200
i solved the problem not letting the user set 2 colors with the same name
if you have a better suggestion please let me know.
PD: the patch has been made today against cvs HEAD
have a nice day :)
Index: src/nautilus-property-browser.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-property-browser.c,v
retrieving revision 1.206
diff -u -p -r1.206 nautilus-property-browser.c
--- src/nautilus-property-browser.c 16 Aug 2004 10:47:02 -0000 1.206
+++ src/nautilus-property-browser.c 28 Aug 2004 11:09:22 -0000
@@ -1177,8 +1177,10 @@ add_new_pattern (NautilusPropertyBrowser
static void
add_color_to_file (NautilusPropertyBrowser *property_browser, const char *color_spec, const char *color_name)
{
- xmlNodePtr cur_node, new_color_node;
+ xmlNodePtr cur_node, new_color_node, children_node;
xmlDocPtr document;
+ xmlChar *child_color_name;
+ gboolean color_name_exists = FALSE;
document = read_browser_xml (property_browser);
if (document == NULL) {
@@ -1188,13 +1190,33 @@ add_color_to_file (NautilusPropertyBrows
/* find the colors category */
cur_node = get_color_category (document);
if (cur_node != NULL) {
- /* add a new color node */
- new_color_node = xmlNewChild (cur_node, NULL, "color", NULL);
- xmlNodeSetContent (new_color_node, color_spec);
- xmlSetProp (new_color_node, "local", "1");
- xmlSetProp (new_color_node, "name", color_name);
+ /* check if theres already a color whith that name */
+ children_node = cur_node->xmlChildrenNode;
+ while (children_node != NULL) {
+ child_color_name = xmlGetProp (children_node, "name");
+ if (xmlStrcmp (color_name, child_color_name) == 0) {
+ color_name_exists = TRUE;
+ xmlFree (child_color_name);
+ break;
+ }
+ xmlFree (child_color_name);
+
+ children_node = children_node->next;
+ }
- write_browser_xml (property_browser, document);
+ /* add a new color node */
+ if (!color_name_exists) {
+ new_color_node = xmlNewChild (cur_node, NULL, "color", NULL);
+ xmlNodeSetContent (new_color_node, color_spec);
+ xmlSetProp (new_color_node, "local", "1");
+ xmlSetProp (new_color_node, "name", color_name);
+
+ write_browser_xml (property_browser, document);
+ } else {
+ eel_show_error_dialog (_("The color cannot be installed."),
+ _("Sorry, but you must specify an unused color name for the new color."),
+ _("Couldn't Install Color"), GTK_WINDOW (property_browser));
+ }
}
xmlFreeDoc (document);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]