aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-05-17 04:56:36 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-05-17 04:56:36 +0800
commit3cedfae4c21b3e2cdd53a74208f38c0e9885055f (patch)
tree33a553001856816f86305966900de187721ddcb6 /mail
parent03c399c656ca3cc0d206d15e2f0d217f045d3ee2 (diff)
downloadgsoc2013-evolution-3cedfae4c21b3e2cdd53a74208f38c0e9885055f.tar.gz
gsoc2013-evolution-3cedfae4c21b3e2cdd53a74208f38c0e9885055f.tar.zst
gsoc2013-evolution-3cedfae4c21b3e2cdd53a74208f38c0e9885055f.zip
Check for a label tag when doing a lookup on the COLOR column.
2002-05-16 Jeffrey Stedfast <fejj@ximian.com> * message-list.c (ml_tree_value_at): Check for a label tag when doing a lookup on the COLOR column. * mail-config.c (mail_config_get_label_color_string): Return the colour in string format. * folder-browser.c (set_msg_label): Replaces colourise_msg and sets the "label" tag rather than the "colour" tag. * mail-preferences.c (mail_preferences_apply): Call mail_config_write() so that the settings get synced to disk. svn path=/trunk/; revision=16938
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog14
-rw-r--r--mail/folder-browser.c100
-rw-r--r--mail/mail-config.c34
-rw-r--r--mail/mail-config.h2
-rw-r--r--mail/mail-preferences.c3
-rw-r--r--mail/message-list.c29
6 files changed, 137 insertions, 45 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 1a04992f4f..f06f514f9e 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,17 @@
+2002-05-16 Jeffrey Stedfast <fejj@ximian.com>
+
+ * message-list.c (ml_tree_value_at): Check for a label tag when
+ doing a lookup on the COLOR column.
+
+ * mail-config.c (mail_config_get_label_color_string): Return the
+ colour in string format.
+
+ * folder-browser.c (set_msg_label): Replaces colourise_msg and
+ sets the "label" tag rather than the "colour" tag.
+
+ * mail-preferences.c (mail_preferences_apply): Call
+ mail_config_write() so that the settings get synced to disk.
+
2002-05-16 Ettore Perazzoli <ettore@ximian.com>
* component-factory.c (request_quit): New.
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index b5d87685eb..c79f74ec70 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -1528,6 +1528,7 @@ hide_sender(GtkWidget *w, FolderBrowser *fb)
}
}
+#if 0
struct _colour_data {
FolderBrowser *fb;
guint32 rgb;
@@ -1557,6 +1558,63 @@ colourise_msg (GtkWidget *widget, gpointer user_data)
g_ptr_array_free (uids, TRUE);
}
+static void
+colour_closures_free (GPtrArray *closures)
+{
+ struct _colour_data *data;
+ int i;
+
+ for (i = 0; i < closures->len; i++) {
+ data = closures->pdata[i];
+ gtk_object_unref (GTK_OBJECT (data->fb));
+ g_free (data);
+ }
+ g_ptr_array_free (closures, TRUE);
+}
+#endif
+
+struct _label_data {
+ FolderBrowser *fb;
+ int label;
+};
+
+static void
+set_msg_label (GtkWidget *widget, gpointer user_data)
+{
+ struct _label_data *data = user_data;
+ GPtrArray *uids;
+ char *label;
+ int i;
+
+ if (data->label != -1)
+ label = g_strdup_printf ("%d", data->label);
+ else
+ label = NULL;
+
+ uids = g_ptr_array_new ();
+ message_list_foreach (data->fb->message_list, enumerate_msg, uids);
+ for (i = 0; i < uids->len; i++) {
+ camel_folder_set_message_user_tag (data->fb->folder, uids->pdata[i], "label", label);
+ }
+ g_ptr_array_free (uids, TRUE);
+
+ g_free (label);
+}
+
+static void
+label_closures_free (GPtrArray *closures)
+{
+ struct _label_data *data;
+ int i;
+
+ for (i = 0; i < closures->len; i++) {
+ data = closures->pdata[i];
+ gtk_object_unref (GTK_OBJECT (data->fb));
+ g_free (data);
+ }
+ g_ptr_array_free (closures, TRUE);
+}
+
enum {
SELECTION_SET = 1<<1,
@@ -1594,13 +1652,13 @@ static EPopupMenu filter_menu[] = {
};
static EPopupMenu label_menu[] = {
- E_POPUP_PIXMAP_WIDGET_ITEM_CC (N_("None"), NULL, GTK_SIGNAL_FUNC (colourise_msg), NULL, 0),
+ E_POPUP_PIXMAP_WIDGET_ITEM_CC (N_("None"), NULL, GTK_SIGNAL_FUNC (set_msg_label), NULL, 0),
E_POPUP_SEPARATOR,
- E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, GTK_SIGNAL_FUNC (colourise_msg), NULL, 0),
- E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, GTK_SIGNAL_FUNC (colourise_msg), NULL, 0),
- E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, GTK_SIGNAL_FUNC (colourise_msg), NULL, 0),
- E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, GTK_SIGNAL_FUNC (colourise_msg), NULL, 0),
- E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, GTK_SIGNAL_FUNC (colourise_msg), NULL, 0),
+ E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, GTK_SIGNAL_FUNC (set_msg_label), NULL, 0),
+ E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, GTK_SIGNAL_FUNC (set_msg_label), NULL, 0),
+ E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, GTK_SIGNAL_FUNC (set_msg_label), NULL, 0),
+ E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, GTK_SIGNAL_FUNC (set_msg_label), NULL, 0),
+ E_POPUP_PIXMAP_WIDGET_ITEM_CC (NULL, NULL, GTK_SIGNAL_FUNC (set_msg_label), NULL, 0),
E_POPUP_TERMINATOR
};
@@ -1742,20 +1800,6 @@ setup_popup_icons (void)
}
}
-static void
-colour_closures_free (GPtrArray *closures)
-{
- struct _colour_data *data;
- int i;
-
- for (i = 0; i < closures->len; i++) {
- data = closures->pdata[i];
- gtk_object_unref (GTK_OBJECT (data->fb));
- g_free (data);
- }
- g_ptr_array_free (closures, TRUE);
-}
-
/* handle context menu over message-list */
static int
on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event, FolderBrowser *fb)
@@ -1941,14 +1985,14 @@ on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event
/* create the label/colour menu */
closures = g_ptr_array_new ();
- label_menu[0].closure = g_new (struct _colour_data, 1);
+ label_menu[0].closure = g_new (struct _label_data, 1);
g_ptr_array_add (closures, label_menu[0].closure);
gtk_object_ref (GTK_OBJECT (fb));
- ((struct _colour_data *) label_menu[0].closure)->fb = fb;
- ((struct _colour_data *) label_menu[0].closure)->rgb = COLOUR_NONE;
+ ((struct _label_data *) label_menu[0].closure)->fb = fb;
+ ((struct _label_data *) label_menu[0].closure)->label = -1;
for (i = 0; i < 5; i++) {
- struct _colour_data *closure;
+ struct _label_data *closure;
GdkPixmap *pixmap;
GdkColormap *map;
GdkColor color;
@@ -1970,10 +2014,10 @@ on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event
gdk_draw_rectangle (pixmap, gc, TRUE, 0, 0, 16, 16);
gdk_gc_unref (gc);
- closure = g_new (struct _colour_data, 1);
+ closure = g_new (struct _label_data, 1);
gtk_object_ref (GTK_OBJECT (fb));
closure->fb = fb;
- closure->rgb = rgb;
+ closure->label = i;
g_ptr_array_add (closures, closure);
@@ -1990,8 +2034,8 @@ on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event
menu = e_popup_menu_create (context_menu, enable_mask, hide_mask, fb);
e_auto_kill_popup_menu_on_hide (menu);
- gtk_object_set_data_full (GTK_OBJECT (menu), "colour_closures",
- closures, (GtkDestroyNotify) colour_closures_free);
+ gtk_object_set_data_full (GTK_OBJECT (menu), "label_closures",
+ closures, (GtkDestroyNotify) label_closures_free);
if (fdata)
gtk_object_set_data_full (GTK_OBJECT (menu), "filter_data",
diff --git a/mail/mail-config.c b/mail/mail-config.c
index ecd0b8487a..316f945d59 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -71,11 +71,11 @@
MailConfigLabel label_defaults[5] = {
- { N_("Important"), 0x00ff0000 }, /* red */
- { N_("Work"), 0x00ff8c00 }, /* orange */
- { N_("Personal"), 0x00008b00 }, /* forest green */
- { N_("To Do"), 0x000000ff }, /* blue */
- { N_("Later"), 0x008b008b } /* magenta */
+ { N_("Important"), 0x00ff0000, NULL }, /* red */
+ { N_("Work"), 0x00ff8c00, NULL }, /* orange */
+ { N_("Personal"), 0x00008b00, NULL }, /* forest green */
+ { N_("To Do"), 0x000000ff, NULL }, /* blue */
+ { N_("Later"), 0x008b008b, NULL } /* magenta */
};
typedef struct {
@@ -375,6 +375,8 @@ mail_config_clear (void)
for (i = 0; i < 5; i++) {
g_free (config->labels[i].name);
config->labels[i].name = NULL;
+ g_free (config->labels[i].string);
+ config->labels[i].string = NULL;
}
}
@@ -2205,9 +2207,31 @@ mail_config_set_label_color (int label, guint32 color)
{
g_return_if_fail (label >= 0 && label < 5);
+ g_free (config->labels[label].string);
+ config->labels[label].string = NULL;
+
config->labels[label].color = color;
}
+const char *
+mail_config_get_label_color_string (int label)
+{
+ g_return_val_if_fail (label >= 0 && label < 5, NULL);
+
+ if (!config->labels[label].string) {
+ guint32 rgb = config->labels[label].color;
+ char *colour;
+
+ colour = g_strdup_printf ("#%.2x%.2x%.2x",
+ (rgb & 0xff0000) >> 16,
+ (rgb & 0xff00) >> 8,
+ rgb & 0xff);
+
+ config->labels[label].string = colour;
+ }
+
+ return config->labels[label].string;
+}
gboolean
mail_config_find_account (const MailConfigAccount *account)
diff --git a/mail/mail-config.h b/mail/mail-config.h
index 6d70a3a120..bfcd442344 100644
--- a/mail/mail-config.h
+++ b/mail/mail-config.h
@@ -125,6 +125,7 @@ typedef enum {
typedef struct {
char *name;
guint32 color;
+ char *string;
} MailConfigLabel;
extern MailConfigLabel label_defaults[5];
@@ -196,6 +197,7 @@ const char *mail_config_get_label_name (int label);
void mail_config_set_label_name (int label, const char *name);
guint32 mail_config_get_label_color (int label);
void mail_config_set_label_color (int label, guint32 color);
+const char *mail_config_get_label_color_string (int label);
gint mail_config_get_do_seen_timeout (void);
void mail_config_set_do_seen_timeout (gboolean do_seen_timeout);
diff --git a/mail/mail-preferences.c b/mail/mail-preferences.c
index ba8f0fe495..949fefc7f4 100644
--- a/mail/mail-preferences.c
+++ b/mail/mail-preferences.c
@@ -429,5 +429,6 @@ mail_preferences_apply (MailPreferences *prefs)
rgb = colorpicker_get_color (prefs->labels[i].color);
mail_config_set_label_color (i, rgb);
}
+
+ mail_config_write ();
}
-
diff --git a/mail/message-list.c b/mail/message-list.c
index 480e9ceb89..f7a363b9f1 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -923,23 +923,30 @@ ml_tree_value_at (ETreeModel *etm, ETreePath path, int col, void *model_data)
return GINT_TO_POINTER (!(msg_info->flags & CAMEL_MESSAGE_SEEN));
}
case COL_COLOUR: {
- const char *colour, *followup;
+ const char *colour, *followup, *label;
+
+ /* Priority: colour tag; label tag; important flag; follow-up tag */
colour = camel_tag_get ((CamelTag **) &msg_info->user_tags, "colour");
followup = camel_tag_get ((CamelTag **) &msg_info->user_tags, "follow-up");
- if (colour == NULL && msg_info->flags & CAMEL_MESSAGE_FLAGGED) {
- /* FIXME: extract from the xpm somehow. */
- colour = "#A7453E";
- } else if (followup != NULL) {
- struct _FollowUpTag *tag;
- time_t now = time (NULL);
-
- tag = message_tag_followup_decode (followup);
- if (tag && now >= tag->target_date) {
+ label = camel_tag_get ((CamelTag **) &msg_info->user_tags, "label");
+ if (colour == NULL) {
+ if (label != NULL) {
+ colour = mail_config_get_label_color_string (atoi (label));
+ } else if (msg_info->flags & CAMEL_MESSAGE_FLAGGED) {
/* FIXME: extract from the xpm somehow. */
colour = "#A7453E";
+ } else if (followup != NULL) {
+ struct _FollowUpTag *tag;
+ time_t now = time (NULL);
+
+ tag = message_tag_followup_decode (followup);
+ if (tag && now >= tag->target_date) {
+ /* FIXME: extract from the xpm somehow. */
+ colour = "#A7453E";
+ }
+ g_free (tag);
}
- g_free (tag);
}
return (void *)colour;
}