diff options
Diffstat (limited to 'e-util/e-categories-master-list-wombat.c')
-rw-r--r-- | e-util/e-categories-master-list-wombat.c | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/e-util/e-categories-master-list-wombat.c b/e-util/e-categories-master-list-wombat.c index 4410b6f009..9b42802a2d 100644 --- a/e-util/e-categories-master-list-wombat.c +++ b/e-util/e-categories-master-list-wombat.c @@ -10,8 +10,12 @@ #include <config.h> #include "e-categories-master-list-wombat.h" +#include "e-categories-config.h" +#include <tree.h> +#include <parser.h> #include <gal/util/e-i18n.h> +#include <gal/util/e-xml-utils.h> #include <bonobo-conf/bonobo-config-database.h> #include <bonobo/bonobo-moniker-util.h> #include <bonobo/bonobo-exception.h> @@ -41,10 +45,39 @@ ecmlw_load (ECategoriesMasterListWombat *ecmlw) NULL, &def); - if (!def) - e_categories_master_list_array_from_string - (E_CATEGORIES_MASTER_LIST_ARRAY (ecmlw), - string); + /* parse the XML string */ + if (!def) { + xmlDocPtr doc; + xmlNodePtr node; + xmlNodePtr children; + char *string_copy; + + string_copy = g_strdup (string); + doc = xmlParseMemory (string_copy, strlen (string_copy)); + node = xmlDocGetRootElement (doc); + g_free (string_copy); + + /* add categories and their associated icons/colors */ + for (children = node->xmlChildrenNode; + children != NULL; + children = children->next) { + char *category; + char *icon; + char *color; + + category = e_xml_get_string_prop_by_name (children, "a"); + icon = (char *) e_categories_config_get_icon_file_for (category); + color = (char *) e_categories_config_get_color_for (category); + + e_categories_master_list_append ( + E_CATEGORIES_MASTER_LIST (ecmlw), + category, + color, + icon); + } + + xmlFreeDoc (doc); + } g_print ("load: %s\n", string); @@ -55,6 +88,8 @@ static void ecmlw_save (ECategoriesMasterListWombat *ecmlw) { char *string; + int i; + int count; CORBA_Environment ev; string = e_categories_master_list_array_to_string (E_CATEGORIES_MASTER_LIST_ARRAY (ecmlw)); @@ -68,6 +103,21 @@ ecmlw_save (ECategoriesMasterListWombat *ecmlw) string, &ev); + /* now save all icons and colors for each category */ + count = e_categories_master_list_count (E_CATEGORIES_MASTER_LIST (ecmlw)); + for (i = 0; i < count; i++) { + gchar *category; + gchar *icon; + gchar *color; + + category = e_categories_master_list_nth (E_CATEGORIES_MASTER_LIST (ecmlw), i); + icon = e_categories_master_list_nth_icon (E_CATEGORIES_MASTER_LIST (ecmlw), i); + color = e_categories_master_list_nth_color (E_CATEGORIES_MASTER_LIST (ecmlw), i); + + e_categories_config_set_icon_for (category, icon); + e_categories_config_set_color_for (category, color); + } + CORBA_exception_free (&ev); g_free (string); |