diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-03-16 10:22:54 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-03-16 10:22:54 +0800 |
commit | 4c1a78e6124b25de8bbdd35298d6bd8959b31d0a (patch) | |
tree | 109db090280c02d845dfd109cf08e5af58025269 /mail | |
parent | eaaa45115ffe9382758627bb3747210f8a78788b (diff) | |
download | gsoc2013-evolution-4c1a78e6124b25de8bbdd35298d6bd8959b31d0a.tar gsoc2013-evolution-4c1a78e6124b25de8bbdd35298d6bd8959b31d0a.tar.gz gsoc2013-evolution-4c1a78e6124b25de8bbdd35298d6bd8959b31d0a.tar.bz2 gsoc2013-evolution-4c1a78e6124b25de8bbdd35298d6bd8959b31d0a.tar.lz gsoc2013-evolution-4c1a78e6124b25de8bbdd35298d6bd8959b31d0a.tar.xz gsoc2013-evolution-4c1a78e6124b25de8bbdd35298d6bd8959b31d0a.tar.zst gsoc2013-evolution-4c1a78e6124b25de8bbdd35298d6bd8959b31d0a.zip |
New callback to set a colour on a message.
2002-03-15 Jeffrey Stedfast <fejj@ximian.com>
* mail-callbacks.c (colour_msg): New callback to set a colour on a
message.
* folder-browser.c (on_right_click): Setup our popup icons and
stuff. Also add a submenu for Labels.
* mail-display.c (pixmap_press): Sync up with the new EPopupMenu
API. Note: This code can probably now be fixed to use per-item
closures - yay!
* mail-accounts.c (construct): Connect to the label GtkEntry's and
GnomeColorPickers and also to the Restore Defaults button.
* mail-config.c (mail_config_get_label_name): New function to get
a label's name.
(mail_config_set_label_name): New function to set the label name.
(mail_config_get_label_color): New function to get the label
color.
(mail_config_set_label_color): New function to set the label
color.
(config_read): Read in the config options for the labels and their
colors.
(mail_config_write_on_exit): Save the label options.
svn path=/trunk/; revision=16186
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 26 | ||||
-rw-r--r-- | mail/Makefile.am | 1 | ||||
-rw-r--r-- | mail/folder-browser.c | 147 | ||||
-rw-r--r-- | mail/mail-accounts.c | 97 | ||||
-rw-r--r-- | mail/mail-accounts.h | 21 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 10 | ||||
-rw-r--r-- | mail/mail-callbacks.h | 1 | ||||
-rw-r--r-- | mail/mail-config-druid.c | 5 | ||||
-rw-r--r-- | mail/mail-config.c | 110 | ||||
-rw-r--r-- | mail/mail-config.glade | 301 | ||||
-rw-r--r-- | mail/mail-config.h | 20 | ||||
-rw-r--r-- | mail/mail-display.c | 6 |
12 files changed, 667 insertions, 78 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 089c6468e8..6812a1bfe1 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,29 @@ +2002-03-15 Jeffrey Stedfast <fejj@ximian.com> + + * mail-callbacks.c (colour_msg): New callback to set a colour on a + message. + + * folder-browser.c (on_right_click): Setup our popup icons and + stuff. Also add a submenu for Labels. + + * mail-display.c (pixmap_press): Sync up with the new EPopupMenu + API. Note: This code can probably now be fixed to use per-item + closures - yay! + + * mail-accounts.c (construct): Connect to the label GtkEntry's and + GnomeColorPickers and also to the Restore Defaults button. + + * mail-config.c (mail_config_get_label_name): New function to get + a label's name. + (mail_config_set_label_name): New function to set the label name. + (mail_config_get_label_color): New function to get the label + color. + (mail_config_set_label_color): New function to set the label + color. + (config_read): Read in the config options for the labels and their + colors. + (mail_config_write_on_exit): Save the label options. + 2002-03-15 Larry Ewing <lewing@ximian.com> * mail-display.c: expand the relative urls of the object at the diff --git a/mail/Makefile.am b/mail/Makefile.am index 465094792b..0079ae6e6b 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -21,6 +21,7 @@ INCLUDES = \ -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ -DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\" \ -DEVOLUTION_ICONSDIR=\""$(iconsdir)"\" \ + -DEVOLUTION_IMAGES=\""$(datadir)/images/evolution"\" \ -DEVOLUTION_BUTTONSDIR=\""$(buttonsdir)"\" \ -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ -DCAMEL_PROVIDERDIR=\""$(camel_providerdir)"\" \ diff --git a/mail/folder-browser.c b/mail/folder-browser.c index 910cd51470..c472eb7592 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -38,6 +38,7 @@ #include <gal/widgets/e-unicode.h> #include <libgnomeui/gnome-dialog-util.h> +#include <libgnomeui/gnome-pixmap.h> #include <gtkhtml/htmlengine.h> #include <gtkhtml/htmlobject.h> @@ -1460,67 +1461,119 @@ enum { #define MLIST_FILTER (8) static EPopupMenu filter_menu[] = { - { N_("VFolder on _Subject"), NULL, GTK_SIGNAL_FUNC (vfolder_subject), NULL, SELECTION_SET }, - { N_("VFolder on Se_nder"), NULL, GTK_SIGNAL_FUNC (vfolder_sender), NULL, SELECTION_SET }, - { N_("VFolder on _Recipients"), NULL, GTK_SIGNAL_FUNC (vfolder_recipient), NULL, SELECTION_SET }, - { N_("VFolder on Mailing _List"), NULL, GTK_SIGNAL_FUNC (vfolder_mlist), NULL, SELECTION_SET | IS_MAILING_LIST }, + { N_("VFolder on _Subject"), NULL, GTK_SIGNAL_FUNC (vfolder_subject), NULL, NULL, SELECTION_SET }, + { N_("VFolder on Se_nder"), NULL, GTK_SIGNAL_FUNC (vfolder_sender), NULL, NULL, SELECTION_SET }, + { N_("VFolder on _Recipients"), NULL, GTK_SIGNAL_FUNC (vfolder_recipient), NULL, NULL, SELECTION_SET }, + { N_("VFolder on Mailing _List"), NULL, GTK_SIGNAL_FUNC (vfolder_mlist), NULL, NULL, SELECTION_SET | IS_MAILING_LIST }, E_POPUP_SEPARATOR, - { N_("Filter on Sub_ject"), NULL, GTK_SIGNAL_FUNC (filter_subject), NULL, SELECTION_SET }, - { N_("Filter on Sen_der"), NULL, GTK_SIGNAL_FUNC (filter_sender), NULL, SELECTION_SET }, - { N_("Filter on Re_cipients"), NULL, GTK_SIGNAL_FUNC (filter_recipient), NULL, SELECTION_SET }, - { N_("Filter on _Mailing List"), NULL, GTK_SIGNAL_FUNC (filter_mlist), NULL, SELECTION_SET | IS_MAILING_LIST }, + { N_("Filter on Sub_ject"), NULL, GTK_SIGNAL_FUNC (filter_subject), NULL, NULL, SELECTION_SET }, + { N_("Filter on Sen_der"), NULL, GTK_SIGNAL_FUNC (filter_sender), NULL, NULL, SELECTION_SET }, + { N_("Filter on Re_cipients"), NULL, GTK_SIGNAL_FUNC (filter_recipient), NULL, NULL, SELECTION_SET }, + { N_("Filter on _Mailing List"), NULL, GTK_SIGNAL_FUNC (filter_mlist), NULL, NULL, SELECTION_SET | IS_MAILING_LIST }, E_POPUP_TERMINATOR }; +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 }, + E_POPUP_TERMINATOR +}; static EPopupMenu context_menu[] = { - { N_("_Open"), NULL, GTK_SIGNAL_FUNC (open_msg), NULL, 0 }, - { N_("_Edit as New Message..."), NULL, GTK_SIGNAL_FUNC (resend_msg), NULL, CAN_RESEND }, - { N_("_Save As..."), NULL, GTK_SIGNAL_FUNC (save_msg), NULL, 0 }, - { N_("_Print"), NULL, GTK_SIGNAL_FUNC (print_msg), NULL, 0 }, + { N_("_Open"), NULL, GTK_SIGNAL_FUNC (open_msg), NULL, NULL, 0 }, + { N_("_Edit as New Message..."), NULL, GTK_SIGNAL_FUNC (resend_msg), NULL, NULL, CAN_RESEND }, + { N_("_Save As..."), NULL, GTK_SIGNAL_FUNC (save_msg), NULL, NULL, 0 }, + { N_("_Print"), NULL, GTK_SIGNAL_FUNC (print_msg), NULL, NULL, 0 }, E_POPUP_SEPARATOR, - { N_("_Reply to Sender"), NULL, GTK_SIGNAL_FUNC (reply_to_sender), NULL, 0 }, - { N_("Reply to _List"), NULL, GTK_SIGNAL_FUNC (reply_to_list), NULL, 0 }, - { N_("Reply to _All"), NULL, GTK_SIGNAL_FUNC (reply_to_all), NULL, 0 }, - { N_("_Forward"), NULL, GTK_SIGNAL_FUNC (forward), NULL, 0 }, + { N_("_Reply to Sender"), NULL, GTK_SIGNAL_FUNC (reply_to_sender), NULL, NULL, 0 }, + { N_("Reply to _List"), NULL, GTK_SIGNAL_FUNC (reply_to_list), NULL, NULL, 0 }, + { N_("Reply to _All"), NULL, GTK_SIGNAL_FUNC (reply_to_all), NULL, NULL, 0 }, + { N_("_Forward"), NULL, GTK_SIGNAL_FUNC (forward), NULL, NULL, 0 }, E_POPUP_SEPARATOR, - { N_("Follo_w Up..."), NULL, GTK_SIGNAL_FUNC (flag_for_followup), NULL, CAN_FLAG_FOR_FOLLOWUP }, - { N_("Fla_g Completed"), NULL, GTK_SIGNAL_FUNC (flag_followup_completed), NULL, CAN_FLAG_COMPLETED }, - { N_("Cl_ear Flag"), NULL, GTK_SIGNAL_FUNC (flag_followup_clear), NULL, CAN_CLEAR_FLAG }, + { N_("Follo_w Up..."), NULL, GTK_SIGNAL_FUNC (flag_for_followup), NULL, NULL, CAN_FLAG_FOR_FOLLOWUP }, + { N_("Fla_g Completed"), NULL, GTK_SIGNAL_FUNC (flag_followup_completed), NULL, NULL, CAN_FLAG_COMPLETED }, + { N_("Cl_ear Flag"), NULL, GTK_SIGNAL_FUNC (flag_followup_clear), NULL, NULL, CAN_CLEAR_FLAG }, /* separator here? */ - { N_("Mar_k as Read"), NULL, GTK_SIGNAL_FUNC (mark_as_seen), NULL, CAN_MARK_READ }, - { N_("Mark as _Unread"), NULL, GTK_SIGNAL_FUNC (mark_as_unseen), NULL, CAN_MARK_UNREAD }, - { N_("Mark as _Important"), NULL, GTK_SIGNAL_FUNC (mark_as_important), NULL, CAN_MARK_IMPORTANT }, - { N_("_Mark as Unimportant"), NULL, GTK_SIGNAL_FUNC (mark_as_unimportant), NULL, CAN_MARK_UNIMPORTANT }, + { N_("Mar_k as Read"), NULL, GTK_SIGNAL_FUNC (mark_as_seen), NULL, NULL, CAN_MARK_READ }, + { N_("Mark as _Unread"), NULL, GTK_SIGNAL_FUNC (mark_as_unseen), NULL, NULL, CAN_MARK_UNREAD }, + { N_("Mark as _Important"), NULL, GTK_SIGNAL_FUNC (mark_as_important), NULL, NULL, CAN_MARK_IMPORTANT }, + { N_("_Mark as Unimportant"), NULL, GTK_SIGNAL_FUNC (mark_as_unimportant), NULL, NULL, CAN_MARK_UNIMPORTANT }, + + E_POPUP_SEPARATOR, + + { N_("_Delete"), NULL, GTK_SIGNAL_FUNC (delete_msg), NULL, NULL, CAN_DELETE }, + { N_("U_ndelete"), NULL, GTK_SIGNAL_FUNC (undelete_msg), NULL, NULL, CAN_UNDELETE }, + + E_POPUP_SEPARATOR, + + { N_("Mo_ve to Folder..."), NULL, GTK_SIGNAL_FUNC (move_msg_cb), NULL, NULL, 0 }, + { N_("_Copy to Folder..."), NULL, GTK_SIGNAL_FUNC (copy_msg_cb), NULL, NULL, 0 }, E_POPUP_SEPARATOR, - { N_("Mo_ve to Folder..."), NULL, GTK_SIGNAL_FUNC (move_msg_cb), NULL, 0 }, - { N_("_Copy to Folder..."), NULL, GTK_SIGNAL_FUNC (copy_msg_cb), NULL, 0 }, - { N_("_Delete"), NULL, GTK_SIGNAL_FUNC (delete_msg), NULL, CAN_DELETE }, - { N_("U_ndelete"), NULL, GTK_SIGNAL_FUNC (undelete_msg), NULL, CAN_UNDELETE }, + { N_("Label"), NULL, GTK_SIGNAL_FUNC (NULL), NULL, label_menu, SELECTION_SET }, E_POPUP_SEPARATOR, - { N_("Add Sender to Address_book"), NULL, GTK_SIGNAL_FUNC (addrbook_sender), NULL, SELECTION_SET }, - { "", NULL, GTK_SIGNAL_FUNC (NULL), NULL, 0 }, + { N_("Add Sender to Address_book"), NULL, GTK_SIGNAL_FUNC (addrbook_sender), NULL, NULL, SELECTION_SET }, - { N_("Appl_y Filters"), NULL, GTK_SIGNAL_FUNC (apply_filters), NULL, 0 }, - { "", NULL, GTK_SIGNAL_FUNC (NULL), NULL, 0 }, - { N_("Crea_te Rule From Message"), NULL, GTK_SIGNAL_FUNC (NULL), filter_menu, SELECTION_SET }, + E_POPUP_SEPARATOR, + + { N_("Appl_y Filters"), NULL, GTK_SIGNAL_FUNC (apply_filters), NULL, NULL, 0 }, + + E_POPUP_SEPARATOR, + + { N_("Crea_te Rule From Message"), NULL, GTK_SIGNAL_FUNC (NULL), NULL, filter_menu, SELECTION_SET }, E_POPUP_TERMINATOR }; +/* Note: this must be kept in sync with the context_menu!!! */ +static char *context_pixmaps[] = { + NULL, /* Open */ + NULL, /* Edit */ + "save-as-16.png", + "print.xpm", + NULL, + "reply.xpm", + NULL, /* Reply to List */ + "reply_to_all.xpm", + "forward.xpm", + NULL, + "flag-for-followup-16.png", + NULL, /* Flag */ + NULL, /* Clear */ + "mail-read.xpm", + "mail-new.xpm", + "priority-high.xpm", + NULL, /* Mark as Unimportant */ + NULL, + "evolution-trash-mini.png", + "undelete_message-16.png", + NULL, + "move_message.xpm", + "copy_16_message.xpm", + NULL, + NULL, /* Label */ + NULL, + NULL, /* Add Sender to Addressbook */ + NULL, + NULL, /* Apply Filters */ + NULL, + NULL, /* Create Rule from Message */ +}; struct cmpf_data { ETree *tree; @@ -1533,7 +1586,7 @@ context_menu_position_func (GtkMenu *menu, gint *x, gint *y, { int tx, ty, tw, th; struct cmpf_data *closure = user_data; - + gdk_window_get_origin (GTK_WIDGET (closure->tree)->window, x, y); e_tree_get_cell_geometry (closure->tree, closure->row, closure->col, &tx, &ty, &tw, &th); @@ -1554,6 +1607,22 @@ followup_tag_complete (const char *tag_value) return ret; } +static void +setup_popup_icons (void) +{ + int i; + + for (i = 0; context_menu[i].name; i++) { + if (context_pixmaps[i]) { + char *filename; + + filename = g_strdup_printf ("%s/%s", EVOLUTION_IMAGES, context_pixmaps[i]); + context_menu[i].pixmap = gnome_pixmap_new_from_file (filename); + g_free (filename); + } + } +} + /* handle context menu over message-list */ static int on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event, FolderBrowser *fb) @@ -1714,6 +1783,13 @@ on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event filter_menu[MLIST_VFOLDER].name = g_strdup_printf (_("VFolder on M_ailing List (%s)"), mlist); } + /* create the label/colour menu */ + for (i = 0; i < 5; i++) { + label_menu[i].name = e_utf8_to_locale_string (mail_config_get_label_name (i)); + } + + setup_popup_icons (); + menu = e_popup_menu_create (context_menu, enable_mask, hide_mask, fb); e_auto_kill_popup_menu_on_hide (menu); @@ -1733,6 +1809,11 @@ on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event g_free (filter_menu[MLIST_FILTER].name); g_free (filter_menu[MLIST_VFOLDER].name); + /* free the label/colour menu */ + for (i = 0; i < 5; i++) { + g_free (label_menu[i].name); + } + return TRUE; } diff --git a/mail/mail-accounts.c b/mail/mail-accounts.c index 08e198d13c..6b8d654f99 100644 --- a/mail/mail-accounts.c +++ b/mail/mail-accounts.c @@ -33,6 +33,7 @@ #include <camel/camel-pgp-context.h> #include <gal/widgets/e-unicode.h> +#include <gal/util/e-unicode-i18n.h> #include <gal/widgets/e-gui-utils.h> #include "widgets/misc/e-charset-picker.h" @@ -57,6 +58,8 @@ static void mail_accounts_dialog_finalise (GtkObject *obj); static void mail_unselect (GtkCList *clist, int row, int column, GdkEventButton *event, gpointer data); static void mail_able (GtkButton *button, gpointer data); + + static MailConfigDruid *druid = NULL; static MailAccountEditor *editor = NULL; #ifdef ENABLE_NNTP @@ -632,6 +635,66 @@ citation_color_set (GnomeColorPicker *cp, guint r, guint g, guint b, guint a) mail_config_set_citation_color (rgb); } +static void +label_name_changed (GtkEntry *entry, gpointer user_data) +{ + MailAccountsDialog *dialog = user_data; + char *label_name; + int label; + + for (label = 0; label < 5; label++) { + if (entry == dialog->labels[label].name) + break; + } + + g_assert (label < 5); + + label_name = e_utf8_gtk_entry_get_text (entry); + mail_config_set_label_name (label, label_name); + g_free (label_name); +} + +static void +label_color_set (GnomeColorPicker *cp, guint r, guint g, guint b, guint a, gpointer user_data) +{ + MailAccountsDialog *dialog = user_data; + guint32 rgb; + int label; + + for (label = 0; label < 5; label++) { + if (cp == dialog->labels[label].color) + break; + } + + g_assert (label < 5); + + rgb = r >> 8; + rgb <<= 8; + rgb |= g >> 8; + rgb <<= 8; + rgb |= b >> 8; + + mail_config_set_label_color (label, rgb); +} + +static void +set_color (GnomeColorPicker *cp, guint32 rgb) +{ + gnome_color_picker_set_i8 (cp, (rgb & 0xff0000) >> 16, (rgb & 0xff00) >> 8, rgb & 0xff, 0xff); +} + +static void +restore_labels_clicked (GtkButton *button, gpointer user_data) +{ + MailAccountsDialog *dialog = user_data; + int i; + + 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); + } +} + /* FIXME: */ static void @@ -670,14 +733,6 @@ filter_log_path_changed (GtkEntry *entry, gpointer data) } static void -set_color (GnomeColorPicker *cp) -{ - guint32 rgb = mail_config_get_citation_color (); - - gnome_color_picker_set_i8 (cp, (rgb & 0xff0000) >> 16, (rgb & 0xff00) >> 8, rgb & 0xff, 0xff); -} - -static void images_radio_toggled (GtkWidget *radio, gpointer data) { MailAccountsDialog *dialog = data; @@ -1231,8 +1286,9 @@ construct (MailAccountsDialog *dialog) { GladeXML *gui; GtkWidget *notebook, *menu; + char *widget_name; const char *text; - int num; + int i, num; gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", NULL); dialog->gui = gui; @@ -1301,7 +1357,7 @@ construct (MailAccountsDialog *dialog) gtk_signal_connect (GTK_OBJECT (dialog->citation_highlight), "toggled", GTK_SIGNAL_FUNC (citation_highlight_toggled), dialog); dialog->citation_color = GNOME_COLOR_PICKER (glade_xml_get_widget (gui, "colorpickerCitations")); - set_color (dialog->citation_color); + set_color (dialog->citation_color, mail_config_get_citation_color ()); gtk_signal_connect (GTK_OBJECT (dialog->citation_color), "color_set", GTK_SIGNAL_FUNC (citation_color_set), dialog); @@ -1433,6 +1489,27 @@ construct (MailAccountsDialog *dialog) gtk_signal_connect (GTK_OBJECT (gnome_file_entry_gtk_entry (dialog->notify_sound_file)), "changed", GTK_SIGNAL_FUNC (notify_sound_file_changed), dialog); + for (i = 0; i < 5; i++) { + widget_name = g_strdup_printf ("txtLabel%d", i); + dialog->labels[i].name = GTK_ENTRY (glade_xml_get_widget (gui, widget_name)); + g_free (widget_name); + text = mail_config_get_label_name (i); + e_utf8_gtk_entry_set_text (dialog->labels[i].name, text ? text : ""); + gtk_signal_connect (GTK_OBJECT (dialog->labels[i].name), "changed", + GTK_SIGNAL_FUNC (label_name_changed), dialog); + + widget_name = g_strdup_printf ("colorLabel%d", i); + dialog->labels[i].color = GNOME_COLOR_PICKER (glade_xml_get_widget (gui, widget_name)); + g_free (widget_name); + set_color (dialog->labels[i].color, mail_config_get_label_color (i)); + gtk_signal_connect (GTK_OBJECT (dialog->labels[i].color), "color_set", + GTK_SIGNAL_FUNC (label_color_set), dialog); + } + dialog->restore_labels = GTK_BUTTON (glade_xml_get_widget (gui, "cmdRestoreLabels")); + gtk_signal_connect (GTK_OBJECT (dialog->restore_labels), "clicked", + GTK_SIGNAL_FUNC (restore_labels_clicked), dialog); + + /* now to fill in the clists */ dialog->accounts_row = -1; dialog->accounts = mail_config_get_accounts (); diff --git a/mail/mail-accounts.h b/mail/mail-accounts.h index 8d29746a5b..a294e0d86b 100644 --- a/mail/mail-accounts.h +++ b/mail/mail-accounts.h @@ -52,7 +52,7 @@ struct _MailAccountsDialog { GladeXML *gui; const GSList *accounts; - gint accounts_row; + int accounts_row; /* Accounts page */ GtkCList *mail_accounts; @@ -63,7 +63,7 @@ struct _MailAccountsDialog { GtkButton *mail_able; const GSList *news; - gint news_row; + int news_row; /* News page */ GtkCList *news_accounts; @@ -90,7 +90,7 @@ struct _MailAccountsDialog { /* Signatures page */ GtkWidget *sig_clist; - + GtkWidget *sig_name; GtkWidget *sig_random; GtkWidget *sig_filename; @@ -99,18 +99,18 @@ struct _MailAccountsDialog { GtkWidget *sig_scrolled; GtkWidget *sig_gtk_html; GtkWidget *sig_preview; - + GtkWidget *sig_add; GtkWidget *sig_delete; GtkWidget *sig_edit; - + GtkWidget *sig_simple_button; GtkWidget *sig_advanced_button; GtkWidget *sig_level_bbox; GtkWidget *sig_advanced_table; gboolean sig_switch; - gint sig_row; - + int sig_row; + /* Other page */ GtkToggleButton *empty_trash; GtkToggleButton *filter_log; @@ -121,6 +121,13 @@ struct _MailAccountsDialog { GtkToggleButton *notify_play_sound; GnomeFileEntry *notify_sound_file; + /* Colors/Labels */ + struct { + GtkEntry *name; + GnomeColorPicker *color; + } labels[5]; + GtkButton *restore_labels; + /* PGP page */ GnomeFileEntry *pgp_path; diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index f95a3457cc..806e2a924c 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -68,10 +68,6 @@ #include "evolution-shell-client.h" -#ifndef HAVE_MKSTEMP -#include <fcntl.h> -#include <sys/stat.h> -#endif #define FB_WINDOW(fb) GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (fb), GTK_TYPE_WINDOW)) @@ -2306,6 +2302,12 @@ save_msg (GtkWidget *widget, gpointer user_data) } void +colour_msg (GtkWidget *widget, gpointer user_data) +{ + /* FIXME: implement me? */ +} + +void delete_msg (GtkWidget *button, gpointer user_data) { FolderBrowser *fb = FOLDER_BROWSER (user_data); diff --git a/mail/mail-callbacks.h b/mail/mail-callbacks.h index 103788c584..f160c257c9 100644 --- a/mail/mail-callbacks.h +++ b/mail/mail-callbacks.h @@ -61,6 +61,7 @@ void reply_to_sender (GtkWidget *widget, gpointer user_data); void reply_to_list (GtkWidget *widget, gpointer user_data); void reply_to_all (GtkWidget *widget, gpointer user_data); +void colour_msg (GtkWidget *widget, gpointer user_data); void delete_msg (GtkWidget *widget, gpointer user_data); void undelete_msg (GtkWidget *widget, gpointer user_data); void move_msg_cb (GtkWidget *widget, gpointer user_data); diff --git a/mail/mail-config-druid.c b/mail/mail-config-druid.c index d1c0fabcc1..c9396be6ef 100644 --- a/mail/mail-config-druid.c +++ b/mail/mail-config-druid.c @@ -390,7 +390,6 @@ static void management_check (MailConfigWizard *wizard) { gboolean next_sensitive; - GtkWidget *label; char *text; text = gtk_entry_get_text (wizard->gui->account_name); @@ -418,8 +417,8 @@ management_prepare (EvolutionWizard *wizard, gpointer data) unsigned int i = 1, len; /* length of name + 1 char for ' ' + 1 char - for '(' + 10 chars for %d + 1 char for ')' - + 1 char for nul */ + for '(' + 10 chars for %d + 1 char for ')' + + 1 char for nul */ len = strlen (name); template = alloca (len + 14); strcpy (template, name); diff --git a/mail/mail-config.c b/mail/mail-config.c index 63984cd476..b036e389da 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -69,6 +69,15 @@ #include "Mail.h" + +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 */ +}; + typedef struct { Bonobo_ConfigDatabase db; @@ -114,10 +123,12 @@ typedef struct { char *notify_filename; char *last_filesel_dir; - + GList *signature_list; - gint signatures; - gint signatures_random; + int signatures; + int signatures_random; + + MailConfigLabel labels[5]; } MailConfig; static MailConfig *config = NULL; @@ -329,6 +340,8 @@ mail_config_init (void) void mail_config_clear (void) { + int i; + if (!config) return; @@ -358,6 +371,11 @@ mail_config_clear (void) g_free (config->last_filesel_dir); config->last_filesel_dir = NULL; + + for (i = 0; i < 5; i++) { + g_free (config->labels[i].name); + config->labels[i].name = NULL; + } } static MailConfigSignature * @@ -585,6 +603,7 @@ static void config_read (void) { int len, i, default_num; + char *path, *val, *p; mail_config_clear (); @@ -599,7 +618,6 @@ config_read (void) MailConfigIdentity *id; MailConfigService *source; MailConfigService *transport; - char *path, *val; account = g_new0 (MailConfigAccount, 1); path = g_strdup_printf ("/Mail/Accounts/account_name_%d", i); @@ -945,6 +963,29 @@ config_read (void) /* last filesel dir */ config->last_filesel_dir = bonobo_config_get_string ( config->db, "/Mail/Filesel/last_filesel_dir", NULL); + + /* Color labels */ + /* Note: we avoid having to malloc/free 10 times this way... */ + path = g_malloc (sizeof ("/Mail/Labels/") + sizeof ("label_#") + 1); + strcpy (path, "/Mail/Labels/label_#"); + p = path + strlen (path) - 1; + for (i = 0; i < 5; i++) { + *p = '0' + i; + val = bonobo_config_get_string (config->db, path, NULL); + if (!(val && *val)) { + g_free (val); + val = NULL; + } + config->labels[i].name = val; + } + strcpy (path, "/Mail/Labels/color_#"); + p = path + strlen (path) - 1; + for (i = 0; i < 5; i++) { + *p = '0' + i; + config->labels[i].color = bonobo_config_get_long_with_default (config->db, path, + label_defaults[i].color, NULL); + } + g_free (path); } #define bonobo_config_set_string_wrapper(db, path, val, ev) bonobo_config_set_string (db, path, val ? val : "", ev) @@ -1183,6 +1224,8 @@ mail_config_write_on_exit (void) CORBA_Environment ev; MailConfigAccount *account; const GSList *accounts; + char *path, *p; + int i; /* Show Messages Threaded */ bonobo_config_set_boolean (config->db, "/Mail/Display/thread_list", @@ -1290,9 +1333,28 @@ mail_config_write_on_exit (void) bonobo_config_set_string_wrapper (config->db, "/Mail/Filesel/last_filesel_dir", config->last_filesel_dir, NULL); + /* Color labels */ + /* Note: we avoid having to malloc/free 10 times this way... */ + path = g_malloc (sizeof ("/Mail/Labels/") + sizeof ("label_#") + 1); + strcpy (path, "/Mail/Labels/label_#"); + p = path + strlen (path) - 1; + for (i = 0; i < 5; i++) { + *p = '0' + i; + bonobo_config_set_string_wrapper (config->db, path, config->labels[i].name, NULL); + } + strcpy (path, "/Mail/Labels/color_#"); + p = path + strlen (path) - 1; + for (i = 0; i < 5; i++) { + *p = '0' + i; + bonobo_config_set_long (config->db, path, config->labels[i].color, NULL); + } + g_free (path); + + /* Message Threading */ if (config->threaded_hash) g_hash_table_foreach_remove (config->threaded_hash, hash_save_state, "Threads"); + /* Message Preview */ if (config->preview_hash) g_hash_table_foreach_remove (config->preview_hash, hash_save_state, "Preview"); @@ -2077,6 +2139,46 @@ mail_config_set_new_mail_notify_sound_file (const char *filename) config->notify_filename = g_strdup (filename); } +const char * +mail_config_get_label_name (int label) +{ + g_return_val_if_fail (label >= 0 && label < 5, NULL); + + if (!config->labels[label].name) + config->labels[label].name = g_strdup (U_(label_defaults[label].name)); + + return config->labels[label].name; +} + +void +mail_config_set_label_name (int label, const char *name) +{ + g_return_if_fail (label >= 0 && label < 5); + + if (!name) + name = U_(label_defaults[label].name); + + g_free (config->labels[label].name); + config->labels[label].name = g_strdup (name); +} + +guint32 +mail_config_get_label_color (int label) +{ + g_return_val_if_fail (label >= 0 && label < 5, 0); + + return config->labels[label].color; +} + +void +mail_config_set_label_color (int label, guint32 color) +{ + g_return_if_fail (label >= 0 && label < 5); + + config->labels[label].color = color; +} + + gboolean mail_config_find_account (const MailConfigAccount *account) { diff --git a/mail/mail-config.glade b/mail/mail-config.glade index e00f31e685..5e94edb7b3 100644 --- a/mail/mail-config.glade +++ b/mail/mail-config.glade @@ -2847,8 +2847,8 @@ Kerberos <widget> <class>GtkVBox</class> - <name>vbox38</name> - <border_width>4</border_width> + <name>display_vbox</name> + <border_width>3</border_width> <homogeneous>False</homogeneous> <spacing>4</spacing> @@ -2860,7 +2860,7 @@ Kerberos <child> <padding>0</padding> <expand>False</expand> - <fill>True</fill> + <fill>False</fill> </child> <widget> @@ -2917,7 +2917,7 @@ Kerberos <child> <padding>0</padding> <expand>False</expand> - <fill>True</fill> + <fill>False</fill> </child> <widget> @@ -2977,7 +2977,7 @@ Kerberos <widget> <class>GtkFrame</class> - <name>frame1</name> + <name>html_images_frame</name> <label>In HTML mail</label> <label_xalign>0</label_xalign> <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> @@ -2989,7 +2989,7 @@ Kerberos <widget> <class>GtkVBox</class> - <name>vbox65</name> + <name>html_images_vbox</name> <homogeneous>False</homogeneous> <spacing>0</spacing> @@ -3039,6 +3039,287 @@ Kerberos </widget> </widget> </widget> + + <widget> + <class>GtkFrame</class> + <name>color_frame</name> + <label>Labels and Colors</label> + <label_xalign>0</label_xalign> + <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkTable</class> + <name>color_table</name> + <border_width>4</border_width> + <rows>6</rows> + <columns>3</columns> + <homogeneous>False</homogeneous> + <row_spacing>4</row_spacing> + <column_spacing>4</column_spacing> + + <widget> + <class>GnomeColorPicker</class> + <name>colorLabel0</name> + <can_focus>True</can_focus> + <dither>True</dither> + <use_alpha>False</use_alpha> + <title>Pick a color</title> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>0</top_attach> + <bottom_attach>1</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GnomeColorPicker</class> + <name>colorLabel1</name> + <can_focus>True</can_focus> + <dither>True</dither> + <use_alpha>False</use_alpha> + <title>Pick a color</title> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>1</top_attach> + <bottom_attach>2</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GnomeColorPicker</class> + <name>colorLabel2</name> + <can_focus>True</can_focus> + <dither>True</dither> + <use_alpha>False</use_alpha> + <title>Pick a color</title> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>2</top_attach> + <bottom_attach>3</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GnomeColorPicker</class> + <name>colorLabel3</name> + <can_focus>True</can_focus> + <dither>True</dither> + <use_alpha>False</use_alpha> + <title>Pick a color</title> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>3</top_attach> + <bottom_attach>4</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GnomeColorPicker</class> + <name>colorLabel4</name> + <can_focus>True</can_focus> + <dither>True</dither> + <use_alpha>False</use_alpha> + <title>Pick a color</title> + <child> + <left_attach>1</left_attach> + <right_attach>2</right_attach> + <top_attach>4</top_attach> + <bottom_attach>5</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkButton</class> + <name>cmdRestoreLabels</name> + <can_focus>True</can_focus> + <label>Restore defaults</label> + <relief>GTK_RELIEF_NORMAL</relief> + <child> + <left_attach>2</left_attach> + <right_attach>3</right_attach> + <top_attach>5</top_attach> + <bottom_attach>6</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkEntry</class> + <name>txtLabel0</name> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text>Important</text> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>0</top_attach> + <bottom_attach>1</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkEntry</class> + <name>txtLabel1</name> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text>Work</text> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>1</top_attach> + <bottom_attach>2</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkEntry</class> + <name>txtLabel2</name> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text>Personal</text> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>2</top_attach> + <bottom_attach>3</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkEntry</class> + <name>txtLabel3</name> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text>To Do</text> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>3</top_attach> + <bottom_attach>4</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + + <widget> + <class>GtkEntry</class> + <name>txtLabel4</name> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text>Later</text> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>4</top_attach> + <bottom_attach>5</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> + </widget> + </widget> </widget> <widget> @@ -3056,7 +3337,7 @@ Kerberos <widget> <class>GtkVBox</class> - <name>vbox63</name> + <name>composer_vbox</name> <border_width>4</border_width> <homogeneous>False</homogeneous> <spacing>4</spacing> @@ -3692,7 +3973,7 @@ Quoted <widget> <class>GtkLabel</class> <child_name>Notebook:tab</child_name> - <name>other_config_label</name> + <name>signatures_config_label</name> <label>Signatures</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> @@ -3704,7 +3985,7 @@ Quoted <widget> <class>GtkVBox</class> - <name>vbox64</name> + <name>other_vbox</name> <border_width>4</border_width> <homogeneous>False</homogeneous> <spacing>8</spacing> @@ -4009,7 +4290,7 @@ Quoted <widget> <class>GtkLabel</class> <child_name>Notebook:tab</child_name> - <name>label55</name> + <name>other_config_label</name> <label>Other</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> diff --git a/mail/mail-config.h b/mail/mail-config.h index b9872960ef..beb4ce2815 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -32,10 +32,10 @@ extern "C" { #endif /* __cplusplus */ typedef struct { - gint id; - gchar *name; - gchar *filename; - gchar *script; + int id; + char *name; + char *filename; + char *script; gboolean random; gboolean html; } MailConfigSignature; @@ -109,6 +109,13 @@ typedef enum { MAIL_CONFIG_NOTIFY_PLAY_SOUND, } MailConfigNewMailNotify; +typedef struct { + char *name; + guint32 color; +} MailConfigLabel; + +extern MailConfigLabel label_defaults[5]; + /* signatures */ MailConfigSignature *signature_copy (const MailConfigSignature *sig); void signature_destroy (MailConfigSignature *sig); @@ -172,6 +179,11 @@ void mail_config_set_citation_highlight (gboolean); guint32 mail_config_get_citation_color (void); void mail_config_set_citation_color (guint32); +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); + gint mail_config_get_do_seen_timeout (void); void mail_config_set_do_seen_timeout (gboolean do_seen_timeout); diff --git a/mail/mail-display.c b/mail/mail-display.c index bdf3d87722..70b690723c 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -385,11 +385,11 @@ pixmap_press (GtkWidget *widget, GdkEventButton *event, EScrollFrame *user_data) { EPopupMenu *menu; EPopupMenu save_item = { N_("Save to Disk..."), NULL, - GTK_SIGNAL_FUNC (save_cb), NULL, 0 }; + GTK_SIGNAL_FUNC (save_cb), NULL, NULL, 0 }; EPopupMenu view_item = { N_("View Inline"), NULL, - GTK_SIGNAL_FUNC (inline_cb), NULL, 2 }; + GTK_SIGNAL_FUNC (inline_cb), NULL, NULL, 2 }; EPopupMenu open_item = { N_("Open in %s..."), NULL, - GTK_SIGNAL_FUNC (launch_cb), NULL, 1 }; + GTK_SIGNAL_FUNC (launch_cb), NULL, NULL, 1 }; MailDisplay *md; CamelMimePart *part; MailMimeHandler *handler; |