diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-03-16 12:40:07 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-03-16 12:40:07 +0800 |
commit | 0ae3f73824ac55fab40594bc0ee16812d0f3bbf4 (patch) | |
tree | c4808047014183a58436b3740a9bc6b5f8c0836b /mail | |
parent | 4c1a78e6124b25de8bbdd35298d6bd8959b31d0a (diff) | |
download | gsoc2013-evolution-0ae3f73824ac55fab40594bc0ee16812d0f3bbf4.tar gsoc2013-evolution-0ae3f73824ac55fab40594bc0ee16812d0f3bbf4.tar.gz gsoc2013-evolution-0ae3f73824ac55fab40594bc0ee16812d0f3bbf4.tar.bz2 gsoc2013-evolution-0ae3f73824ac55fab40594bc0ee16812d0f3bbf4.tar.lz gsoc2013-evolution-0ae3f73824ac55fab40594bc0ee16812d0f3bbf4.tar.xz gsoc2013-evolution-0ae3f73824ac55fab40594bc0ee16812d0f3bbf4.tar.zst gsoc2013-evolution-0ae3f73824ac55fab40594bc0ee16812d0f3bbf4.zip |
Draw colour rectangles for each of the colour items and set a closure on
2002-03-15 Jeffrey Stedfast <fejj@ximian.com>
* folder-browser.c (on_right_click): Draw colour rectangles for
each of the colour items and set a closure on each.
(colourise_msg): colourise the message, yo.
svn path=/trunk/; revision=16187
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 6 | ||||
-rw-r--r-- | mail/folder-browser.c | 104 | ||||
-rw-r--r-- | mail/mail-accounts.c | 3 | ||||
-rw-r--r-- | mail/mail-config.c | 10 |
4 files changed, 108 insertions, 15 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 6812a1bfe1..c33e4ba7b4 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,5 +1,11 @@ 2002-03-15 Jeffrey Stedfast <fejj@ximian.com> + * folder-browser.c (on_right_click): Draw colour rectangles for + each of the colour items and set a closure on each. + (colourise_msg): colourise the message, yo. + +2002-03-15 Jeffrey Stedfast <fejj@ximian.com> + * mail-callbacks.c (colour_msg): New callback to set a colour on a message. diff --git a/mail/folder-browser.c b/mail/folder-browser.c index c472eb7592..73f3ec0ed5 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -1442,6 +1442,36 @@ hide_sender(GtkWidget *w, FolderBrowser *fb) } } +struct _colour_data { + FolderBrowser *fb; + guint32 rgb; +}; + +#define COLOUR_NONE (~0) + +static void +colourise_msg (GtkWidget *widget, gpointer user_data) +{ + struct _colour_data *data = user_data; + char *colour = NULL; + GPtrArray *uids; + int i; + + if (data->rgb != COLOUR_NONE) { + colour = alloca (8); + sprintf (colour, "#%.2x%.2x%.2x", (data->rgb & 0xff0000) >> 16, + (data->rgb & 0xff00) >> 8, data->rgb & 0xff); + } + + 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], "colour", colour); + } + g_ptr_array_free (uids, TRUE); +} + + enum { SELECTION_SET = 1<<1, CAN_MARK_READ = 1<<2, @@ -1477,11 +1507,13 @@ static EPopupMenu filter_menu[] = { }; static EPopupMenu label_menu[] = { - { NULL, NULL, GTK_SIGNAL_FUNC (colour_msg), NULL, NULL, SELECTION_SET }, - { NULL, NULL, GTK_SIGNAL_FUNC (colour_msg), NULL, NULL, SELECTION_SET }, - { NULL, NULL, GTK_SIGNAL_FUNC (colour_msg), NULL, NULL, SELECTION_SET }, - { NULL, NULL, GTK_SIGNAL_FUNC (colour_msg), NULL, NULL, SELECTION_SET }, - { NULL, NULL, GTK_SIGNAL_FUNC (colour_msg), NULL, NULL, SELECTION_SET }, + { N_("None"), NULL, GTK_SIGNAL_FUNC (colourise_msg), NULL, NULL, 0 }, + E_POPUP_SEPARATOR, + { NULL, NULL, GTK_SIGNAL_FUNC (colourise_msg), NULL, NULL, 0 }, + { NULL, NULL, GTK_SIGNAL_FUNC (colourise_msg), NULL, NULL, 0 }, + { NULL, NULL, GTK_SIGNAL_FUNC (colourise_msg), NULL, NULL, 0 }, + { NULL, NULL, GTK_SIGNAL_FUNC (colourise_msg), NULL, NULL, 0 }, + { NULL, NULL, GTK_SIGNAL_FUNC (colourise_msg), NULL, NULL, 0 }, E_POPUP_TERMINATOR }; @@ -1523,7 +1555,7 @@ static EPopupMenu context_menu[] = { E_POPUP_SEPARATOR, - { N_("Label"), NULL, GTK_SIGNAL_FUNC (NULL), NULL, label_menu, SELECTION_SET }, + { N_("Label"), NULL, GTK_SIGNAL_FUNC (NULL), NULL, label_menu, 0 }, E_POPUP_SEPARATOR, @@ -1623,13 +1655,27 @@ 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) { extern CamelFolder *sent_folder; CamelMessageInfo *info; - GPtrArray *uids; + GPtrArray *uids, *closures; int enable_mask = 0; int hide_mask = 0; int i; @@ -1784,8 +1830,45 @@ 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); + 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; + for (i = 0; i < 5; i++) { - label_menu[i].name = e_utf8_to_locale_string (mail_config_get_label_name (i)); + struct _colour_data *closure; + GdkPixmap *pixmap; + GdkColormap *map; + GdkColor color; + guint32 rgb; + GdkGC *gc; + + rgb = mail_config_get_label_color (i); + + color.red = ((rgb & 0xff0000) >> 8) | 0xff; + color.green = (rgb & 0xff00) | 0xff; + color.blue = ((rgb & 0xff) << 8) | 0xff; + + map = gdk_colormap_get_system (); + gdk_color_alloc (map, &color); + + pixmap = gdk_pixmap_new (GTK_WIDGET (fb)->window, 16, 16, -1); + gc = gdk_gc_new (GTK_WIDGET (fb)->window); + gdk_gc_set_foreground (gc, &color); + gdk_draw_rectangle (pixmap, gc, TRUE, 0, 0, 16, 16); + + closure = g_new (struct _colour_data, 1); + gtk_object_ref (GTK_OBJECT (fb)); + closure->fb = fb; + closure->rgb = rgb; + + g_ptr_array_add (closures, closure); + + label_menu[i + 2].name = e_utf8_to_locale_string (mail_config_get_label_name (i)); + label_menu[i + 2].pixmap = gtk_pixmap_new (pixmap, NULL); + label_menu[i + 2].closure = closure; } setup_popup_icons (); @@ -1793,6 +1876,9 @@ 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", + (GtkDestroyNotify) closures, colour_closures_free); + if (event->type == GDK_KEY_PRESS) { struct cmpf_data closure; @@ -1811,7 +1897,7 @@ on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event /* free the label/colour menu */ for (i = 0; i < 5; i++) { - g_free (label_menu[i].name); + g_free (label_menu[i + 2].name); } return TRUE; diff --git a/mail/mail-accounts.c b/mail/mail-accounts.c index 6b8d654f99..c5a1c208b0 100644 --- a/mail/mail-accounts.c +++ b/mail/mail-accounts.c @@ -658,7 +658,7 @@ static void label_color_set (GnomeColorPicker *cp, guint r, guint g, guint b, guint a, gpointer user_data) { MailAccountsDialog *dialog = user_data; - guint32 rgb; + guint32 rgb = 0; int label; for (label = 0; label < 5; label++) { @@ -692,6 +692,7 @@ restore_labels_clicked (GtkButton *button, gpointer user_data) for (i = 0; i < 5; i++) { e_utf8_gtk_entry_set_text (dialog->labels[i].name, U_(label_defaults[i].name)); set_color (dialog->labels[i].color, label_defaults[i].color); + mail_config_set_label_color (i, label_defaults[i].color); } } diff --git a/mail/mail-config.c b/mail/mail-config.c index b036e389da..e6396ab7cf 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -71,11 +71,11 @@ MailConfigLabel label_defaults[5] = { - { N_("Important"), 0xff0000 }, /* red */ - { N_("Work"), 0xff8c00 }, /* orange */ - { N_("Personal"), 0x008b00 }, /* forest green */ - { N_("To Do"), 0x0000ff }, /* blue */ - { N_("Later"), 0x8b008b } /* magenta */ + { N_("Important"), 0x00ff0000 }, /* red */ + { N_("Work"), 0x00ff8c00 }, /* orange */ + { N_("Personal"), 0x00008b00 }, /* forest green */ + { N_("To Do"), 0x000000ff }, /* blue */ + { N_("Later"), 0x008b008b } /* magenta */ }; typedef struct { |