aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@ximian.com>2001-07-05 04:03:48 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2001-07-05 04:03:48 +0800
commit834ae55a48b5e6c31e08987447bc7c01075e77d8 (patch)
tree987ede6ab5329bdb4127df0f7ac39b8cab1ffe7f
parentd6e309cac3804858878039f3283b2bcff24658a1 (diff)
downloadgsoc2013-evolution-834ae55a48b5e6c31e08987447bc7c01075e77d8.tar
gsoc2013-evolution-834ae55a48b5e6c31e08987447bc7c01075e77d8.tar.gz
gsoc2013-evolution-834ae55a48b5e6c31e08987447bc7c01075e77d8.tar.bz2
gsoc2013-evolution-834ae55a48b5e6c31e08987447bc7c01075e77d8.tar.lz
gsoc2013-evolution-834ae55a48b5e6c31e08987447bc7c01075e77d8.tar.xz
gsoc2013-evolution-834ae55a48b5e6c31e08987447bc7c01075e77d8.tar.zst
gsoc2013-evolution-834ae55a48b5e6c31e08987447bc7c01075e77d8.zip
load all icons and colors for each category
2001-07-04 Rodrigo Moya <rodrigo@ximian.com> * 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
-rw-r--r--e-util/ChangeLog6
-rw-r--r--e-util/e-categories-config.c61
-rw-r--r--e-util/e-categories-config.h1
-rw-r--r--e-util/e-categories-master-list-wombat.c58
4 files changed, 115 insertions, 11 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 7c10e4ee29..f0557ac098 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,5 +1,11 @@
2001-07-04 Rodrigo Moya <rodrigo@ximian.com>
+ * 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
diff --git a/e-util/e-categories-config.c b/e-util/e-categories-config.c
index eb8e07b0c7..8d84826077 100644
--- a/e-util/e-categories-config.c
+++ b/e-util/e-categories-config.c
@@ -18,6 +18,7 @@
#include "e-categories-master-list-wombat.h"
typedef struct {
+ char *filename;
GdkPixmap *pixmap;
GdkBitmap *mask;
} icon_data_t;
@@ -158,8 +159,8 @@ void
e_categories_config_get_icon_for (const char *category, GdkPixmap **pixmap, GdkBitmap **mask)
{
icon_data_t *icon_data;
- char *tmp;
char *icon_file;
+ char *tmp;
g_return_if_fail (category != NULL);
g_return_if_fail (pixmap != NULL);
@@ -179,13 +180,59 @@ e_categories_config_get_icon_for (const char *category, GdkPixmap **pixmap, GdkB
tmp = g_strdup_printf ("General/Categories/%s/Icon", category);
icon_file = config_get_string (tmp);
g_free (tmp);
+
+ if (icon_file) {
+ /* add new pixmap from file to the list */
+ icon_data = g_new (icon_data_t, 1);
+ icon_data->filename = icon_file;
+ icon_data->pixmap = gdk_pixmap_create_from_xpm (NULL, &icon_data->mask, NULL, icon_file);
+ g_hash_table_insert (cat_icons, (gpointer) category, (gpointer) icon_data);
+
+ *pixmap = icon_data->pixmap;
+ if (*mask)
+ *mask = icon_data->mask;
+ }
+ else {
+ *pixmap = NULL;
+ if (mask != NULL)
+ *mask = NULL;
+ }
+}
+
+/**
+ * e_categories_config_get_icon_file_for
+ * @category: Category for which to get the icon file
+ */
+const char *
+e_categories_config_get_icon_file_for (const char *category)
+{
+ icon_data_t *icon_data;
+ char *icon_file;
+ char *tmp;
+
+ g_return_val_if_fail (category != NULL, NULL);
+
+ if (!initialized)
+ initialize_categories_config ();
+
+ icon_data = g_hash_table_lookup (cat_icons, category);
+ if (icon_data != NULL)
+ return (const char *) icon_data->filename;
+
+ /* not found, so look in the configuration */
+ tmp = g_strdup_printf ("General/Categories/%s/Icon", category);
+ icon_file = config_get_string (tmp);
+ g_free (tmp);
+
if (icon_file) {
- g_free (icon_file);
+ /* add new pixmap from file to the list */
+ icon_data = g_new (icon_data_t, 1);
+ icon_data->filename = icon_file;
+ icon_data->pixmap = gdk_pixmap_create_from_xpm (NULL, &icon_data->mask, NULL, icon_file);
+ g_hash_table_insert (cat_icons, (gpointer) category, (gpointer) icon_data);
}
- *pixmap = NULL;
- if (mask != NULL)
- *mask = NULL;
+ return (const char *) icon_file;
}
/**
@@ -211,11 +258,13 @@ e_categories_config_set_icon_for (const char *category, const char *pixmap_file)
gdk_pixmap_unref (icon_data->pixmap);
gdk_bitmap_unref (icon_data->mask);
+ g_free (icon_data->filename);
g_free (icon_data);
}
/* add new pixmap from file to the list */
icon_data = g_new (icon_data_t, 1);
+ icon_data->filename = g_strdup (pixmap_file);
icon_data->pixmap = gdk_pixmap_create_from_xpm (NULL, &icon_data->mask, NULL, pixmap_file);
g_hash_table_insert (cat_icons, (gpointer) category, (gpointer) icon_data);
@@ -242,8 +291,6 @@ e_categories_config_open_dialog_for_entry (GtkEntry *entry)
char *categories;
GnomeDialog *dialog;
int result;
- GString *cat_icons;
- GString *cat_colors;
ECategoriesMasterList *ecml;
g_return_if_fail (entry != NULL);
diff --git a/e-util/e-categories-config.h b/e-util/e-categories-config.h
index 9ad0b5fe09..0b798e466e 100644
--- a/e-util/e-categories-config.h
+++ b/e-util/e-categories-config.h
@@ -24,6 +24,7 @@ void e_categories_config_set_color_for (const char *category, const char *color)
void e_categories_config_get_icon_for (const char *category,
GdkPixmap **icon,
GdkBitmap **mask);
+const char *e_categories_config_get_icon_file_for (const char *category);
void e_categories_config_set_icon_for (const char *category,
const char *pixmap_file);
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);