From 2093e3100243fb209ceb2c3a26d917124903dd8a Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 17 Dec 2007 05:40:53 +0000 Subject: ** Fix for bug #211353 2007-12-14 Milan Crha ** Fix for bug #211353 * message-list.etspec: * message-list.h: * message-list.c: Added new column to show labels. * filtertypes.xml: * vfoldertypes.xml: Code for label filters/search folders has been changed. * mail-config.glade: * em-folder-view.c: (emfv_set_label), (emfv_unset_label), (emfv_popup_label_clear), (emfv_popup_label_set), (emfv_popup_labels_get_state_for_tag), (emfv_popup): Labels popup submenu is now shown with checkboxes so one can set more than one label to the message and unset only one label from message. There has been added new function, because of this. * mail-config.h: * mail-config.c: New "interface" functions to work with labels. * em-mailer-prefs.h: * em-mailer-prefs.c: Editing labels in tree. * em-folder-browser.c: Labels in show menu reflect changes in preferences. 2007-12-14 Milan Crha ** Part of fix for bug #211353 * filter-label.c: Use global label's setup, not its own copy. 2007-12-14 Milan Crha ** Part of fix for bug #211353 * e-popup.h: * e-popup.c: (ep_build_tree): Toggles can be in inconsistent state now, and can also contain an image, which is a pointer to GtkImage widget. 2007-12-14 Milan Crha ** Part of fix for bug #211353 * e-search-bar.c: (e_search_bar_get_viewitem_id): Return -1 if no viewmenu is setup yet. svn path=/trunk/; revision=34715 --- filter/ChangeLog | 6 ++++++ filter/filter-label.c | 55 +++++++++++++++++++++------------------------------ 2 files changed, 28 insertions(+), 33 deletions(-) (limited to 'filter') diff --git a/filter/ChangeLog b/filter/ChangeLog index e44841b8cb..d22286fb6c 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,9 @@ +2007-12-14 Milan Crha + + ** Part of fix for bug #211353 + + * filter-label.c: Use global label's setup, not its own copy. + 2007-12-07 Bob Mauchin ** Fix for bug #438769 diff --git a/filter/filter-label.c b/filter/filter-label.c index ca0ae005fe..c95b06173b 100644 --- a/filter/filter-label.c +++ b/filter/filter-label.c @@ -38,6 +38,7 @@ #include "filter-label.h" #include #include "e-util/e-util.h" +#include "mail/mail-config.h" #define d(x) @@ -114,38 +115,36 @@ 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) { - return sizeof (labels) / sizeof (labels[0]); + GSList *labels = mail_config_get_labels (); + + return g_slist_length (labels); } const char * filter_label_label (int i) { - if (i < 0 || i >= sizeof (labels) / sizeof (labels[0])) + GSList *labels = mail_config_get_labels (); + + if (i < 0 || i >= g_slist_length (labels)) return NULL; else - return labels[i].value; + /* the return value is always without preceding "$Label" */ + return ((MailConfigLabel *) g_slist_nth (labels, i))->tag + 6; } 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; - for (i = 0; i < sizeof (labels) / sizeof (labels[0]); i++) { - if (strcmp (labels[i].value, label) == 0) + /* the return value is always without preceding "$Label" */ + if (lbl && lbl->tag && strcmp (lbl->tag + 6, label) == 0) return i; } @@ -156,30 +155,20 @@ 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); - gconf = gconf_client_get_default (); + list = mail_config_get_labels (); - 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'; + for (l = list; l; l = l->next) { + MailConfigLabel *label = l->data; + char *title; - nounderscores_title = e_str_without_underscores (title); + title = e_str_without_underscores (label->name); - filter_option_add (fo, i < 5 ? labels[i++].value : (p ? p : "#ffffff"), nounderscores_title, NULL); - g_free (title); - g_free (nounderscores_title); + filter_option_add (fo, label->tag + 6, title, NULL); - l = l->next; + g_free (title); } - g_slist_free (list); - - g_object_unref (gconf); } -- cgit