From 834ae55a48b5e6c31e08987447bc7c01075e77d8 Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Wed, 4 Jul 2001 20:03:48 +0000 Subject: load all icons and colors for each category 2001-07-04 Rodrigo Moya * e-categories-master-list-wombat.c (ecmlw_load): load all icons and colors for each category (ecmlw_save): save all icons and categories associated with each category * e-categories-config.c: use BonoboConf to store/retrieve settings, and use ECategoriesMasterListWombat when creating a ECategories dialog widget svn path=/trunk/; revision=10781 --- e-util/e-categories-master-list-wombat.c | 58 +++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) (limited to 'e-util/e-categories-master-list-wombat.c') 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 #include "e-categories-master-list-wombat.h" +#include "e-categories-config.h" +#include +#include #include +#include #include #include #include @@ -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); -- cgit