aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filter/ChangeLog6
-rw-r--r--filter/filter-label.c55
2 files changed, 39 insertions, 22 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index d22286fb6c..95e18e332b 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,9 @@
+2007-12-17 Srinivasa Ragavan <sragavan@novell.com>
+
+ * filter-label.c: (filter_label_count), (filter_label_label),
+ (filter_label_index), (xml_create): Removing cyclic dependency caused
+ by mail_config_get_labels.
+
2007-12-14 Milan Crha <mcrha@redhat.com>
** Part of fix for bug #211353
diff --git a/filter/filter-label.c b/filter/filter-label.c
index c95b06173b..ca0ae005fe 100644
--- a/filter/filter-label.c
+++ b/filter/filter-label.c
@@ -38,7 +38,6 @@
#include "filter-label.h"
#include <libedataserver/e-sexp.h>
#include "e-util/e-util.h"
-#include "mail/mail-config.h"
#define d(x)
@@ -115,36 +114,38 @@ filter_label_new (void)
return (FilterLabel *) g_object_new (FILTER_TYPE_LABEL, NULL, NULL);
}
+static struct {
+ char *title;
+ char *value;
+} labels[] = {
+ { N_("Important"), "important" },
+ { N_("Work"), "work" },
+ { N_("Personal"), "personal" },
+ { N_("To Do"), "todo" },
+ { N_("Later"), "later" },
+};
+
int filter_label_count (void)
{
- GSList *labels = mail_config_get_labels ();
-
- return g_slist_length (labels);
+ return sizeof (labels) / sizeof (labels[0]);
}
const char *
filter_label_label (int i)
{
- GSList *labels = mail_config_get_labels ();
-
- if (i < 0 || i >= g_slist_length (labels))
+ if (i < 0 || i >= sizeof (labels) / sizeof (labels[0]))
return NULL;
else
- /* the return value is always without preceding "$Label" */
- return ((MailConfigLabel *) g_slist_nth (labels, i))->tag + 6;
+ return labels[i].value;
}
int
filter_label_index (const char *label)
{
int i;
- GSList *labels = mail_config_get_labels ();
-
- for (i = 0; labels; i++, labels = labels->next) {
- MailConfigLabel *lbl = labels->data;
- /* the return value is always without preceding "$Label" */
- if (lbl && lbl->tag && strcmp (lbl->tag + 6, label) == 0)
+ for (i = 0; i < sizeof (labels) / sizeof (labels[0]); i++) {
+ if (strcmp (labels[i].value, label) == 0)
return i;
}
@@ -155,20 +156,30 @@ static void
xml_create (FilterElement *fe, xmlNodePtr node)
{
FilterOption *fo = (FilterOption *) fe;
+ GConfClient *gconf;
GSList *list, *l;
+ char *title, *p, *nounderscores_title;
+ int i = 0;
FILTER_ELEMENT_CLASS (parent_class)->xml_create (fe, node);
- list = mail_config_get_labels ();
+ gconf = gconf_client_get_default ();
- for (l = list; l; l = l->next) {
- MailConfigLabel *label = l->data;
- char *title;
+ l = list = gconf_client_get_list (gconf, "/apps/evolution/mail/labels", GCONF_VALUE_STRING, NULL);
+ while (l != NULL) {
+ title = (char *) l->data;
+ if ((p = strrchr (title, ':')))
+ *p++ = '\0';
- title = e_str_without_underscores (label->name);
-
- filter_option_add (fo, label->tag + 6, title, NULL);
+ nounderscores_title = e_str_without_underscores (title);
+ filter_option_add (fo, i < 5 ? labels[i++].value : (p ? p : "#ffffff"), nounderscores_title, NULL);
g_free (title);
+ g_free (nounderscores_title);
+
+ l = l->next;
}
+ g_slist_free (list);
+
+ g_object_unref (gconf);
}