diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-08-03 06:36:11 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-08-03 06:36:11 +0800 |
commit | 405ef3bcf3cf661a017fd133a0771c3cb1b78b3a (patch) | |
tree | 95d06ff9cf7ec13c2cffd25f5164408e295b1c3c | |
parent | 784fe19dd5554f138a4f24695060ada980665136 (diff) | |
download | gsoc2013-evolution-405ef3bcf3cf661a017fd133a0771c3cb1b78b3a.tar gsoc2013-evolution-405ef3bcf3cf661a017fd133a0771c3cb1b78b3a.tar.gz gsoc2013-evolution-405ef3bcf3cf661a017fd133a0771c3cb1b78b3a.tar.bz2 gsoc2013-evolution-405ef3bcf3cf661a017fd133a0771c3cb1b78b3a.tar.lz gsoc2013-evolution-405ef3bcf3cf661a017fd133a0771c3cb1b78b3a.tar.xz gsoc2013-evolution-405ef3bcf3cf661a017fd133a0771c3cb1b78b3a.tar.zst gsoc2013-evolution-405ef3bcf3cf661a017fd133a0771c3cb1b78b3a.zip |
Updated to use the new Follow-Up tags. Instead of storing a string
2002-08-02 Jeffrey Stedfast <fejj@ximian.com>
* mail-display.c (mail_display_render): Updated to use the new
Follow-Up tags. Instead of storing a string containing the
follow-up tag value, we now have to store the CamelMessageInfo.
(mail_display_destroy): Unref the folder and the message-info.
* folder-browser.c (followup_tag_complete): No longer needed.
(on_right_clicked): Use the individual follow-up tags to decide
whether or not to enable something.
* message-list.c (ml_tree_value_at): Update to use the new
Follow-Up tags.
* mail-callbacks.c (flag_for_followup): Update to use the new
MessageTagEditor API.
(tag_editor_ok): Update this too.
(flag_followup_completed): Updated this too.
(flag_followup_clear): Set all the follow-up tag values to "".
svn path=/trunk/; revision=17691
-rw-r--r-- | mail/ChangeLog | 20 | ||||
-rw-r--r-- | mail/folder-browser.c | 33 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 73 | ||||
-rw-r--r-- | mail/mail-display.c | 79 | ||||
-rw-r--r-- | mail/mail-display.h | 11 | ||||
-rw-r--r-- | mail/message-list.c | 53 | ||||
-rw-r--r-- | mail/message-tag-editor.c | 48 | ||||
-rw-r--r-- | mail/message-tag-editor.h | 11 | ||||
-rw-r--r-- | mail/message-tag-followup.c | 258 | ||||
-rw-r--r-- | mail/message-tag-followup.h | 40 | ||||
-rw-r--r-- | mail/message-tags.glade | 63 |
11 files changed, 290 insertions, 399 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index a7567fa5d6..c0f5cf76da 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,23 @@ +2002-08-02 Jeffrey Stedfast <fejj@ximian.com> + + * mail-display.c (mail_display_render): Updated to use the new + Follow-Up tags. Instead of storing a string containing the + follow-up tag value, we now have to store the CamelMessageInfo. + (mail_display_destroy): Unref the folder and the message-info. + + * folder-browser.c (followup_tag_complete): No longer needed. + (on_right_clicked): Use the individual follow-up tags to decide + whether or not to enable something. + + * message-list.c (ml_tree_value_at): Update to use the new + Follow-Up tags. + + * mail-callbacks.c (flag_for_followup): Update to use the new + MessageTagEditor API. + (tag_editor_ok): Update this too. + (flag_followup_completed): Updated this too. + (flag_followup_clear): Set all the follow-up tag values to "". + 2002-08-01 Ettore Perazzoli <ettore@ximian.com> * component-factory.c (create_component): Use diff --git a/mail/folder-browser.c b/mail/folder-browser.c index c104cc2c17..bff73f9922 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -65,7 +65,6 @@ #include "mail-mt.h" #include "mail-folder-cache.h" #include "folder-browser-ui.h" -#include "message-tag-followup.h" #include "mail-local.h" #include "mail-config.h" @@ -1074,7 +1073,7 @@ folder_browser_set_message_preview (FolderBrowser *folder_browser, gboolean show } else { e_paned_set_position (E_PANED (folder_browser->vpaned), 10000); gtk_widget_hide (GTK_WIDGET (folder_browser->mail_display)); - mail_display_set_message (folder_browser->mail_display, NULL, NULL); + mail_display_set_message (folder_browser->mail_display, NULL, NULL, NULL); folder_browser_ui_message_loaded(folder_browser); } } @@ -1803,19 +1802,6 @@ context_menu_position_func (GtkMenu *menu, gint *x, gint *y, *y += ty + th / 2; } -static gboolean -followup_tag_complete (const char *tag_value) -{ - struct _FollowUpTag *tag; - gboolean ret; - - tag = message_tag_followup_decode (tag_value); - ret = tag->completed != (time_t) 0 ? TRUE : FALSE; - g_free (tag); - - return ret; -} - static void setup_popup_icons (void) { @@ -1935,9 +1921,11 @@ on_right_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event else have_unimportant = TRUE; - if ((tag = camel_tag_get (&info->user_tags, "follow-up"))) { + tag = camel_tag_get (&info->user_tags, "follow-up"); + if (tag && *tag) { have_flag_for_followup = TRUE; - if (followup_tag_complete (tag)) + tag = camel_tag_get (&info->user_tags, "completed-on"); + if (tag && *tag) have_flag_completed = TRUE; else have_flag_incomplete = TRUE; @@ -2343,15 +2331,16 @@ static void done_message_selected (CamelFolder *folder, const char *uid, CamelMimeMessage *msg, void *data) { FolderBrowser *fb = data; + CamelMessageInfo *info; int timeout = mail_config_get_mark_as_seen_timeout (); - const char *followup; if (folder != fb->folder || fb->mail_display == NULL) return; - followup = camel_folder_get_message_user_tag (folder, uid, "follow-up"); - - mail_display_set_message (fb->mail_display, (CamelMedium *) msg, followup); + info = camel_folder_get_message_info (fb->folder, uid); + mail_display_set_message (fb->mail_display, (CamelMedium *) msg, fb->folder, info); + if (info) + camel_folder_free_message_info (fb->folder, info); /* FIXME: should this signal be emitted here?? */ gtk_signal_emit (GTK_OBJECT (fb), folder_browser_signals [MESSAGE_LOADED], uid); @@ -2401,7 +2390,7 @@ do_message_selected (FolderBrowser *fb) fb->loading_uid = g_strdup (fb->new_uid); mail_get_message (fb->folder, fb->loading_uid, done_message_selected, fb, mail_thread_new); } else { - mail_display_set_message (fb->mail_display, NULL, NULL); + mail_display_set_message (fb->mail_display, NULL, NULL, NULL); } } diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index ef3660fa43..18dcc6b206 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -1939,23 +1939,29 @@ static void tag_editor_ok (GtkWidget *button, gpointer user_data) { struct _tag_editor_data *data = user_data; - const char *name, *value; + CamelFolder *folder; + CamelTag *tags, *t; + GPtrArray *uids; int i; if (FOLDER_BROWSER_IS_DESTROYED (data->fb)) goto done; - name = message_tag_editor_get_name (data->editor); - if (!name) + tags = message_tag_editor_get_tag_list (data->editor); + if (tags == NULL) goto done; - value = message_tag_editor_get_value (data->editor); + folder = data->fb->folder; + uids = data->uids; - camel_folder_freeze (data->fb->folder); - for (i = 0; i < data->uids->len; i++) { - camel_folder_set_message_user_tag (data->fb->folder, data->uids->pdata[i], name, value); + camel_folder_freeze (folder); + for (i = 0; i < uids->len; i++) { + for (t = tags; t; t = t->next) + camel_folder_set_message_user_tag (folder, uids->pdata[i], t->name, t->value); } - camel_folder_thaw (data->fb->folder); + camel_folder_thaw (folder); + + camel_tag_list_free (&tags); done: gtk_widget_destroy (GTK_WIDGET (data->editor)); @@ -2017,11 +2023,14 @@ flag_for_followup (BonoboUIComponent *uih, void *user_data, const char *path) /* special-case... */ if (uids->len == 1) { - const char *tag_value; + CamelMessageInfo *info; - tag_value = camel_folder_get_message_user_tag (fb->folder, uids->pdata[0], "follow-up"); - if (tag_value) - message_tag_editor_set_value (MESSAGE_TAG_EDITOR (editor), tag_value); + info = camel_folder_get_message_info (fb->folder, uids->pdata[0]); + if (info) { + if (info->user_tags) + message_tag_editor_set_tag_list (MESSAGE_TAG_EDITOR (editor), info->user_tags); + camel_folder_free_message_info (fb->folder, info); + } } gtk_signal_connect (GTK_OBJECT (editor), "destroy", @@ -2035,7 +2044,7 @@ flag_followup_completed (BonoboUIComponent *uih, void *user_data, const char *pa { FolderBrowser *fb = FOLDER_BROWSER (user_data); GPtrArray *uids; - time_t now; + char *now; int i; if (FOLDER_BROWSER_IS_DESTROYED (fb)) @@ -2044,29 +2053,22 @@ flag_followup_completed (BonoboUIComponent *uih, void *user_data, const char *pa uids = g_ptr_array_new (); message_list_foreach (fb->message_list, enumerate_msg, uids); - now = time (NULL); + now = header_format_date (time (NULL), 0); camel_folder_freeze (fb->folder); for (i = 0; i < uids->len; i++) { - struct _FollowUpTag *tag; - const char *tag_value; - char *value; + const char *tag; - tag_value = camel_folder_get_message_user_tag (fb->folder, uids->pdata[i], "follow-up"); - if (!tag_value) + tag = camel_folder_get_message_user_tag (fb->folder, uids->pdata[i], "follow-up"); + if (tag == NULL || *tag == '\0') continue; - tag = message_tag_followup_decode (tag_value); - tag->completed = now; - - value = message_tag_followup_encode (tag); - g_free (tag); - - camel_folder_set_message_user_tag (fb->folder, uids->pdata[i], "follow-up", value); - g_free (value); + camel_folder_set_message_user_tag (fb->folder, uids->pdata[i], "completed-on", now); } camel_folder_thaw (fb->folder); + g_free (now); + g_ptr_array_free (uids, TRUE); } @@ -2085,7 +2087,9 @@ flag_followup_clear (BonoboUIComponent *uih, void *user_data, const char *path) camel_folder_freeze (fb->folder); for (i = 0; i < uids->len; i++) { - camel_folder_set_message_user_tag (fb->folder, uids->pdata[i], "follow-up", NULL); + camel_folder_set_message_user_tag (fb->folder, uids->pdata[i], "follow-up", ""); + camel_folder_set_message_user_tag (fb->folder, uids->pdata[i], "due-by", ""); + camel_folder_set_message_user_tag (fb->folder, uids->pdata[i], "completed-on", ""); } camel_folder_thaw (fb->folder); @@ -2761,7 +2765,7 @@ expunge_folder (BonoboUIComponent *uih, void *user_data, const char *path) info = camel_folder_get_message_info (fb->folder, fb->loaded_uid); if (!info || info->flags & CAMEL_MESSAGE_DELETED) - mail_display_set_message (fb->mail_display, NULL, NULL); + mail_display_set_message (fb->mail_display, NULL, NULL, NULL); } fb->expunging = fb->folder; @@ -3024,13 +3028,14 @@ done_message_selected (CamelFolder *folder, const char *uid, CamelMimeMessage *m struct blarg_this_sucks *blarg = data; FolderBrowser *fb = blarg->fb; gboolean preview = blarg->preview; - const char *followup; + CamelMessageInfo *info; g_free (blarg); - followup = camel_folder_get_message_user_tag (folder, uid, "follow-up"); - - mail_display_set_message (fb->mail_display, (CamelMedium *) msg, followup); + info = camel_folder_get_message_info (fb->folder, uid); + mail_display_set_message (fb->mail_display, (CamelMedium *) msg, fb->folder, info); + if (info) + camel_folder_free_message_info (fb->folder, info); g_free (fb->loaded_uid); fb->loaded_uid = fb->loading_uid; @@ -3063,7 +3068,7 @@ do_mail_fetch_and_print (FolderBrowser *fb, gboolean preview) fb->loading_uid = g_strdup (fb->new_uid); mail_get_message (fb->folder, fb->loading_uid, done_message_selected, blarg, mail_thread_new); } else { - mail_display_set_message (fb->mail_display, NULL, NULL); + mail_display_set_message (fb->mail_display, NULL, NULL, NULL); g_free (blarg); } } diff --git a/mail/mail-display.c b/mail/mail-display.c index 3a934e1b75..7a5249b6de 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -65,7 +65,6 @@ #include "e-searching-tokenizer.h" #include "folder-browser-factory.h" #include "mail-stream-gtkhtml.h" -#include "message-tag-followup.h" #include "folder-browser.h" #include "mail-display.h" #include "mail-config.h" @@ -1673,9 +1672,8 @@ mail_error_printf (GtkHTML *html, GtkHTMLStream *stream, void mail_display_render (MailDisplay *md, GtkHTML *html, gboolean reset_scroll) { + const char *flag, *completed; GtkHTMLStream *stream; - char bgcolor[7], fontcolor[7]; - GtkStyle *style = NULL; g_return_if_fail (IS_MAIL_DISPLAY (md)); g_return_if_fail (GTK_IS_HTML (html)); @@ -1692,11 +1690,16 @@ mail_display_render (MailDisplay *md, GtkHTML *html, gboolean reset_scroll) "<head>\n<meta name=\"generator\" content=\"Evolution Mail Component\">\n</head>\n"); mail_html_write (html, stream, "<body marginwidth=0 marginheight=0>\n"); - if (md->followup) { - const char *overdue; - char due_date[100]; + flag = md->info ? camel_tag_get (&md->info->user_tags, "follow-up") : NULL; + completed = md->info ? camel_tag_get (&md->info->user_tags, "completed-on") : NULL; + if ((flag && *flag) && !(completed && *completed)) { + const char *due_by, *overdue = ""; + char bgcolor[7], fontcolor[7]; + time_t target_date, now; + GtkStyle *style = NULL; + char due_date[256]; struct tm due; - time_t now; + int offset; /* my favorite thing to do... muck around with colors so we respect people's stupid themes. */ style = gtk_widget_get_style (GTK_WIDGET (html)); @@ -1730,26 +1733,28 @@ mail_display_render (MailDisplay *md, GtkHTML *html, gboolean reset_scroll) strcpy (fontcolor, "000000"); } - now = time (NULL); - if (now >= md->followup->target_date) - overdue = U_("Overdue:"); - else - overdue = ""; - - /* copy the due date into 'now' because localtime_r destroys the time_t value */ - now = md->followup->target_date; - localtime_r (&now, &due); - - e_strftime (due_date, 100, "%B %d, %Y, %l:%M %P", &due); + due_by = camel_tag_get (&md->info->user_tags, "due-by"); + if (due_by && *due_by) { + target_date = header_decode_date (due_by, &offset); + now = time (NULL); + if (now >= target_date) + overdue = U_("Overdue:"); + + localtime_r (&target_date, &due); + + e_strftime (due_date, sizeof (due_date), _("by %B %d, %Y, %l:%M %P"), &due); + } else { + snprintf (due_date, sizeof (due_date), "%s", _("at your earliest convenience")); + } gtk_html_stream_printf (stream, "<font color=\"#%s\">" "<table cellspacing=1 cellpadding=1 bgcolor=\"#000000\"><tr><td>" "<table cellspacing=0 bgcolor=\"#%s\" cellpadding=2 cellspacing=2>" "<tr><td align=\"left\" width=20><img src=\"%s\" align=\"middle\"></td>" - "<td>%s%s%s%s by %s</td></table></td></tr></table></font>", fontcolor, bgcolor, + "<td>%s%s%s%s %s</td></table></td></tr></table></font>", fontcolor, bgcolor, mail_display_get_url_for_icon (md, EVOLUTION_IMAGES "/flag-for-followup-16.png"), overdue ? "<b>" : "", overdue, overdue ? "</b> " : "", - message_tag_followup_i18n_name (md->followup->type), due_date); + flag, due_date); } if (md->current_message) { @@ -1790,13 +1795,14 @@ mail_display_redisplay (MailDisplay *md, gboolean reset_scroll) * mail_display_set_message: * @mail_display: the mail display object * @medium: the input camel medium, or %NULL - * @followup: followup value + * @folder: CamelFolder + * @info: message info * * Makes the mail_display object show the contents of the medium * param. **/ void -mail_display_set_message (MailDisplay *md, CamelMedium *medium, const char *followup) +mail_display_set_message (MailDisplay *md, CamelMedium *medium, CamelFolder *folder, CamelMessageInfo *info) { /* For the moment, we deal only with CamelMimeMessage, but in * the future, we should be able to deal with any medium. @@ -1806,20 +1812,31 @@ mail_display_set_message (MailDisplay *md, CamelMedium *medium, const char *foll /* Clean up from previous message. */ if (md->current_message) { - fetch_cancel(md); + fetch_cancel (md); camel_object_unref (CAMEL_OBJECT (md->current_message)); g_datalist_clear (md->data); } - g_free (md->followup); - if (medium) { camel_object_ref (medium); md->current_message = (CamelMimeMessage *) medium; } else md->current_message = NULL; - md->followup = followup ? message_tag_followup_decode (followup) : NULL; + if (md->folder && md->info) { + camel_folder_free_message_info (md->folder, md->info); + camel_object_unref (md->folder); + } + + if (folder && info) { + md->info = info; + md->folder = folder; + camel_object_ref (folder); + camel_folder_ref_message_info (folder, info); + } else { + md->info = NULL; + md->folder = NULL; + } g_datalist_init (md->data); mail_display_redisplay (md, TRUE); @@ -1871,8 +1888,9 @@ mail_display_init (GtkObject *object) mail_display->idle_id = 0; mail_display->selection = NULL; mail_display->charset = NULL; - mail_display->followup = NULL; mail_display->current_message = NULL; + mail_display->folder = NULL; + mail_display->info = NULL; mail_display->data = NULL; mail_display->invisible = gtk_invisible_new (); @@ -1901,7 +1919,12 @@ mail_display_destroy (GtkObject *object) g_free (mail_display->charset); g_free (mail_display->selection); - g_free (mail_display->followup); + + if (mail_display->folder) { + if (mail_display->info) + camel_folder_free_message_info (mail_display->folder, mail_display->info); + camel_object_unref (mail_display->folder); + } g_free (mail_display->data); mail_display->data = NULL; diff --git a/mail/mail-display.h b/mail/mail-display.h index d7b940f330..bd27001150 100644 --- a/mail/mail-display.h +++ b/mail/mail-display.h @@ -12,6 +12,7 @@ #include <camel/camel-stream.h> #include <camel/camel-mime-message.h> #include <camel/camel-medium.h> +#include <camel/camel-folder.h> #include "mail-types.h" #include "mail-config.h" /*display_style*/ @@ -26,7 +27,7 @@ struct _MailDisplay { GtkVBox parent; struct _MailDisplayPrivate *priv; - + EScrollFrame *scroll; GtkHTML *html; /* GtkHTMLStream *stream; */ @@ -38,15 +39,16 @@ struct _MailDisplay { char *selection; - struct _FollowUpTag *followup; CamelMimeMessage *current_message; + CamelMessageInfo *info; + CamelFolder *folder; GData **data; /* stack of Content-Location URLs used for combining with a relative URL Content-Location on a leaf part in order to construct the full URL */ struct _location_url_stack *urls; - + GHashTable *related; /* related parts not displayed yet */ /* Sigh. This shouldn't be needed. I haven't figured out why it is @@ -85,7 +87,8 @@ void mail_display_stream_write_when_loaded (MailDisplay *md, void mail_display_set_message (MailDisplay *mail_display, CamelMedium *medium, - const char *followup); + CamelFolder *folder, + CamelMessageInfo *info); void mail_display_set_charset (MailDisplay *mail_display, const char *charset); diff --git a/mail/message-list.c b/mail/message-list.c index ddfbe0b465..ab2e95a0b0 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -46,8 +46,6 @@ #include "mail-ops.h" #include "Mail.h" -#include "message-tag-followup.h" - #include "art/mail-new.xpm" #include "art/mail-read.xpm" #include "art/mail-replied.xpm" @@ -910,42 +908,25 @@ ml_tree_value_at (ETreeModel *etm, ETreePath path, int col, void *model_data) const char *tag; tag = camel_tag_get ((CamelTag **) &msg_info->user_tags, "follow-up"); - if (tag) + if (tag && *tag) return GINT_TO_POINTER (TRUE); else return GINT_TO_POINTER (FALSE); } case COL_FOLLOWUP_DUE_BY: { - struct _FollowUpTag *tag; - const char *tag_value; + const char *tag; time_t due_by; - tag_value = camel_tag_get ((CamelTag **) &msg_info->user_tags, "follow-up"); - if (tag_value) { - tag = message_tag_followup_decode (tag_value); - due_by = tag->target_date; - g_free (tag); + tag = camel_tag_get ((CamelTag **) &msg_info->user_tags, "due-by"); + if (tag && *tag) { + due_by = header_decode_date (tag, NULL); return GINT_TO_POINTER (due_by); } else { return GINT_TO_POINTER (0); } } - case COL_FOLLOWUP_FLAG: { - struct _FollowUpTag *tag; - const char *tag_value; - int flag_type; - - tag_value = camel_tag_get ((CamelTag **) &msg_info->user_tags, "follow-up"); - if (tag_value) { - tag = message_tag_followup_decode (tag_value); - flag_type = tag ? tag->type : FOLLOWUP_FLAG_NONE; - g_free (tag); - - return (void *) message_tag_followup_i18n_name (flag_type); - } else { - return NULL; - } - } + case COL_FOLLOWUP_FLAG: + return (void *) camel_tag_get ((CamelTag **) &msg_info->user_tags, "follow-up"); case COL_ATTACHMENT: return GINT_TO_POINTER ((msg_info->flags & CAMEL_MESSAGE_ATTACHMENTS) != 0); case COL_FROM: @@ -980,32 +961,32 @@ 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, *label; + const char *colour, *due_by, *completed, *label; - /* Priority: colour tag; label tag; important flag; follow-up tag */ + /* Priority: colour tag; label tag; important flag; due-by tag */ colour = camel_tag_get ((CamelTag **) &msg_info->user_tags, "colour"); - followup = camel_tag_get ((CamelTag **) &msg_info->user_tags, "follow-up"); + due_by = camel_tag_get ((CamelTag **) &msg_info->user_tags, "due-by"); + completed = camel_tag_get ((CamelTag **) &msg_info->user_tags, "completed-on"); label = camel_tag_get ((CamelTag **) &msg_info->user_tags, "label"); if (colour == NULL) { if (label != NULL) { - colour = mail_config_get_label_color_string (filter_label_index(label)); + colour = mail_config_get_label_color_string (filter_label_index (label)); } else if (msg_info->flags & CAMEL_MESSAGE_FLAGGED) { /* FIXME: extract from the xpm somehow. */ colour = "#A7453E"; - } else if (followup != NULL) { - struct _FollowUpTag *tag; + } else if ((due_by && *due_by) && !(completed && *completed)) { time_t now = time (NULL); + time_t target_date; - tag = message_tag_followup_decode (followup); - if (tag && now >= tag->target_date) { + target_date = header_decode_date (due_by, NULL); + if (now >= target_date) { /* FIXME: extract from the xpm somehow. */ colour = "#A7453E"; } - g_free (tag); } } - return (void *)colour; + return (void *) colour; } case COL_LOCATION: { CamelFolder *folder; diff --git a/mail/message-tag-editor.c b/mail/message-tag-editor.c index 506bd6b666..3622611fec 100644 --- a/mail/message-tag-editor.c +++ b/mail/message-tag-editor.c @@ -34,11 +34,12 @@ static void message_tag_editor_class_init (MessageTagEditorClass *class); static void message_tag_editor_init (MessageTagEditor *editor); static void message_tag_editor_finalise (GtkObject *obj); -static const char *tag_get_name (MessageTagEditor *editor); -static const char *tag_get_value (MessageTagEditor *editor); -static void tag_set_value (MessageTagEditor *editor, const char *value); +static CamelTag *get_tag_list (MessageTagEditor *editor); +static void set_tag_list (MessageTagEditor *editor, CamelTag *value); + + +static GnomeDialogClass *parent_class = NULL; -static GnomeDialogClass *parent_class; GtkType message_tag_editor_get_type (void) @@ -72,9 +73,8 @@ message_tag_editor_class_init (MessageTagEditorClass *klass) object_class->finalize = message_tag_editor_finalise; - klass->get_name = tag_get_name; - klass->get_value = tag_get_value; - klass->set_value = tag_set_value; + klass->get_tag_list = get_tag_list; + klass->set_tag_list = set_tag_list; } static void @@ -99,49 +99,33 @@ message_tag_editor_finalise (GtkObject *obj) ((GtkObjectClass *)(parent_class))->finalize (obj); } - -static const char * -tag_get_name (MessageTagEditor *editor) -{ - return NULL; -} - -const char * -message_tag_editor_get_name (MessageTagEditor *editor) -{ - g_return_val_if_fail (IS_MESSAGE_TAG_EDITOR (editor), NULL); - - return ((MessageTagEditorClass *)((GtkObject *) editor)->klass)->get_name (editor); -} - - -static const char * -tag_get_value (MessageTagEditor *editor) +static CamelTag * +get_tag_list (MessageTagEditor *editor) { return NULL; } -const char * -message_tag_editor_get_value (MessageTagEditor *editor) +CamelTag * +message_tag_editor_get_tag_list (MessageTagEditor *editor) { g_return_val_if_fail (IS_MESSAGE_TAG_EDITOR (editor), NULL); - return ((MessageTagEditorClass *)((GtkObject *) editor)->klass)->get_value (editor); + return ((MessageTagEditorClass *)((GtkObject *) editor)->klass)->get_tag_list (editor); } static void -tag_set_value (MessageTagEditor *editor, const char *value) +set_tag_list (MessageTagEditor *editor, CamelTag *tags) { /* no-op */ ; } void -message_tag_editor_set_value (MessageTagEditor *editor, const char *value) +message_tag_editor_set_tag_list (MessageTagEditor *editor, CamelTag *tags) { g_return_if_fail (IS_MESSAGE_TAG_EDITOR (editor)); - g_return_if_fail (value != NULL); + g_return_if_fail (tags != NULL); - ((MessageTagEditorClass *)((GtkObject *) editor)->klass)->set_value (editor, value); + ((MessageTagEditorClass *)((GtkObject *) editor)->klass)->set_tag_list (editor, tags); } diff --git a/mail/message-tag-editor.h b/mail/message-tag-editor.h index 0dd20aa07e..5602489656 100644 --- a/mail/message-tag-editor.h +++ b/mail/message-tag-editor.h @@ -51,10 +51,8 @@ struct _MessageTagEditorClass { GnomeDialogClass parent_class; /* virtual methods */ - const char * (*get_name) (MessageTagEditor *editor); - - const char * (*get_value) (MessageTagEditor *editor); - void (*set_value) (MessageTagEditor *editor, const char *value); + CamelTag * (*get_tag_list) (MessageTagEditor *editor); + void (*set_tag_list) (MessageTagEditor *editor, CamelTag *tags); /* signals */ }; @@ -63,9 +61,8 @@ struct _MessageTagEditorClass { GtkType message_tag_editor_get_type (void); /* methods */ -const char *message_tag_editor_get_name (MessageTagEditor *editor); -const char *message_tag_editor_get_value (MessageTagEditor *editor); -void message_tag_editor_set_value (MessageTagEditor *editor, const char *value); +CamelTag *message_tag_editor_get_tag_list (MessageTagEditor *editor); +void message_tag_editor_set_tag_list (MessageTagEditor *editor, CamelTag *tags); #ifdef __cplusplus } diff --git a/mail/message-tag-followup.c b/mail/message-tag-followup.c index 2d855c7d7b..073fb484ab 100644 --- a/mail/message-tag-followup.c +++ b/mail/message-tag-followup.c @@ -44,30 +44,29 @@ static void message_tag_followup_class_init (MessageTagFollowUpClass *class); static void message_tag_followup_init (MessageTagFollowUp *followup); static void message_tag_followup_finalise (GtkObject *obj); -static const char *tag_get_name (MessageTagEditor *editor); -static const char *tag_get_value (MessageTagEditor *editor); -static void tag_set_value (MessageTagEditor *editor, const char *value); +static CamelTag *get_tag_list (MessageTagEditor *editor); +static void set_tag_list (MessageTagEditor *editor, CamelTag *tags); + + +#define DEFAULT_FLAG 2 /* Follow-Up */ +static char *available_flags[] = { + N_("Call"), + N_("Do Not Forward"), + N_("Follow-Up"), + N_("For Your Information"), + N_("Forward"), + N_("No Response Necessary"), + N_("Read"), + N_("Reply"), + N_("Reply to All"), + N_("Review"), +}; +static int num_available_flags = sizeof (available_flags) / sizeof (available_flags[0]); -static struct { - const char *i18n_name; - const char *name; - int value; -} available_flags[] = { - { N_("Call"), "call", FOLLOWUP_FLAG_CALL }, - { N_("Do Not Forward"), "do-not-forward", FOLLOWUP_FLAG_DO_NOT_FORWARD }, - { N_("Follow-Up"), "follow-up", FOLLOWUP_FLAG_FOLLOWUP }, - { N_("For Your Information"), "fyi", FOLLOWUP_FLAG_FYI }, - { N_("Forward"), "forward", FOLLOWUP_FLAG_FORWARD }, - { N_("No Response Necessary"), "no-response", FOLLOWUP_FLAG_NO_RESPONSE_NECESSARY }, - { N_("Read"), "read", FOLLOWUP_FLAG_READ }, - { N_("Reply"), "reply", FOLLOWUP_FLAG_REPLY }, - { N_("Reply to All"), "reply-all", FOLLOWUP_FLAG_REPLY_ALL }, - { N_("Review"), "review", FOLLOWUP_FLAG_REVIEW }, - { N_("None"), NULL, FOLLOWUP_FLAG_NONE } -}; -static MessageTagEditorClass *parent_class; +static MessageTagEditorClass *parent_class = NULL; + GtkType message_tag_followup_get_type (void) @@ -103,26 +102,18 @@ message_tag_followup_class_init (MessageTagFollowUpClass *klass) object_class->finalize = message_tag_followup_finalise; - editor_class->get_name = tag_get_name; - editor_class->get_value = tag_get_value; - editor_class->set_value = tag_set_value; + editor_class->get_tag_list = get_tag_list; + editor_class->set_tag_list = set_tag_list; } static void message_tag_followup_init (MessageTagFollowUp *editor) { - editor->tag = g_new (struct _FollowUpTag, 1); - editor->tag->type = FOLLOWUP_FLAG_NONE; - editor->tag->target_date = time (NULL); - editor->tag->completed = 0; - - editor->value = NULL; - - editor->type = NULL; - editor->none = NULL; + editor->combo = NULL; editor->target_date = NULL; editor->completed = NULL; editor->clear = NULL; + editor->completed_date = 0; } @@ -131,119 +122,71 @@ message_tag_followup_finalise (GtkObject *obj) { MessageTagFollowUp *editor = (MessageTagFollowUp *) obj; - g_free (editor->tag); - g_free (editor->value); + editor->completed_date = 0; ((GtkObjectClass *)(parent_class))->finalize (obj); } -static const char * -tag_get_name (MessageTagEditor *editor) -{ - return "follow-up"; -} - -static const char * -tag_get_value (MessageTagEditor *editor) +static CamelTag * +get_tag_list (MessageTagEditor *editor) { MessageTagFollowUp *followup = (MessageTagFollowUp *) editor; + CamelTag *tags = NULL; + time_t date; + char *text; + + text = e_utf8_gtk_entry_get_text (GTK_ENTRY (followup->combo->entry)); + camel_tag_set (&tags, "follow-up", text); + g_free (text); + + date = e_date_edit_get_time (followup->target_date); + if (date != (time_t) -1) { + text = header_format_date (date, 0); + camel_tag_set (&tags, "due-by", text); + g_free (text); + } else { + camel_tag_set (&tags, "due-by", ""); + } - g_free (followup->value); - followup->value = message_tag_followup_encode (followup->tag); - - return followup->value; -} - -static void -set_widget_values (MessageTagFollowUp *followup) -{ - time_t completed; - - gtk_option_menu_set_history (followup->type, followup->tag->type); - - e_date_edit_set_time (followup->target_date, followup->tag->target_date); + if (gtk_toggle_button_get_active (followup->completed)) { + text = header_format_date (followup->completed_date, 0); + camel_tag_set (&tags, "completed-on", text); + g_free (text); + } else { + camel_tag_set (&tags, "completed-on", ""); + } - completed = followup->tag->completed; - gtk_toggle_button_set_active (followup->completed, completed ? TRUE : FALSE); - if (completed) - followup->tag->completed = completed; + return tags; } static void -tag_set_value (MessageTagEditor *editor, const char *value) +set_tag_list (MessageTagEditor *editor, CamelTag *tags) { MessageTagFollowUp *followup = (MessageTagFollowUp *) editor; + const char *text; + time_t date; - g_free (followup->tag); - followup->tag = message_tag_followup_decode (value); - - set_widget_values (followup); -} - - -struct _FollowUpTag * -message_tag_followup_decode (const char *value) -{ - struct _FollowUpTag *tag; - const char *inptr; - int len, i; - - tag = g_new (struct _FollowUpTag, 1); - - inptr = strchr (value, ':'); - if (!inptr) - inptr = value + strlen (value); - - len = inptr - value; - - for (i = 0; i < FOLLOWUP_FLAG_NONE; i++) { - if (!strncmp (value, available_flags[i].name, len)) - break; - } - - tag->type = i; + text = camel_tag_get (&tags, "follow-up"); + if (text) + e_utf8_gtk_entry_set_text (GTK_ENTRY (followup->combo->entry), text); - if (*inptr == ':') { - inptr++; - tag->target_date = strtoul (inptr, (char **) &inptr, 16); - if (*inptr == ':') { - inptr++; - tag->completed = strtoul (inptr, (char **) &inptr, 16); - } else - tag->completed = 0; + text = camel_tag_get (&tags, "due-by"); + if (text && *text) { + date = header_decode_date (text, NULL); + e_date_edit_set_time (followup->target_date, date); } else { - tag->target_date = time (NULL); - tag->completed = 0; + e_date_edit_set_time (followup->target_date, (time_t) -1); } - return tag; -} - - -char * -message_tag_followup_encode (struct _FollowUpTag *tag) -{ - g_return_val_if_fail (tag != NULL, NULL); - - if (tag->type == FOLLOWUP_FLAG_NONE) - return NULL; - - return g_strdup_printf ("%s:%lx:%lx", available_flags[tag->type].name, - (unsigned long) tag->target_date, - (unsigned long) tag->completed); -} - - -const char * -message_tag_followup_i18n_name (int type) -{ - g_return_val_if_fail (type >= 0 && type <= FOLLOWUP_FLAG_NONE, NULL); - - if (type != FOLLOWUP_FLAG_NONE) - return U_(available_flags[type].i18n_name); - else - return NULL; + text = camel_tag_get (&tags, "completed-on"); + if (text && *text) { + date = header_decode_date (text, NULL); + if (date != (time_t) 0) { + gtk_toggle_button_set_active (followup->completed, TRUE); + followup->completed_date = date; + } + } } static void @@ -251,11 +194,9 @@ clear_clicked (GtkButton *button, gpointer user_data) { MessageTagFollowUp *followup = user_data; - gtk_widget_show (followup->none); - gtk_option_menu_set_history (followup->type, FOLLOWUP_FLAG_NONE); - gtk_signal_emit_by_name (GTK_OBJECT (followup->none), "activate", followup); + gtk_list_select_item (GTK_LIST (followup->combo->list), DEFAULT_FLAG); - e_date_edit_set_time (followup->target_date, time (NULL)); + e_date_edit_set_time (followup->target_date, (time_t) -1); gtk_toggle_button_set_active (followup->completed, FALSE); } @@ -265,28 +206,9 @@ completed_toggled (GtkToggleButton *button, gpointer user_data) MessageTagFollowUp *followup = user_data; if (gtk_toggle_button_get_active (followup->completed)) - followup->tag->completed = time (NULL); + followup->completed_date = time (NULL); else - followup->tag->completed = 0; -} - -static void -type_changed (GtkWidget *item, gpointer user_data) -{ - MessageTagFollowUp *followup = user_data; - - followup->tag->type = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (item), "value")); - - if (item != followup->none) - gtk_widget_hide (followup->none); -} - -static void -target_date_changed (EDateEdit *widget, gpointer user_data) -{ - MessageTagFollowUp *followup = user_data; - - followup->tag->target_date = e_date_edit_get_time (widget); + followup->completed_date = 0; } GtkWidget *target_date_new (const char *s1, const char *s2, int i1, int i2); @@ -302,7 +224,7 @@ target_date_new (const char *s1, const char *s2, int i1, int i2) e_date_edit_set_week_start_day (E_DATE_EDIT (widget), 6); /* FIXME: make this locale dependant?? */ e_date_edit_set_use_24_hour_format (E_DATE_EDIT (widget), FALSE); - e_date_edit_set_allow_no_date_set (E_DATE_EDIT (widget), FALSE); + e_date_edit_set_allow_no_date_set (E_DATE_EDIT (widget), TRUE); e_date_edit_set_time_popup_range (E_DATE_EDIT (widget), 0, 24); return widget; @@ -312,7 +234,8 @@ static void construct (MessageTagEditor *editor) { MessageTagFollowUp *followup = (MessageTagFollowUp *) editor; - GtkWidget *widget, *menu, *item; + GtkWidget *widget; + GList *strings; GladeXML *gui; int i; @@ -331,27 +254,16 @@ construct (MessageTagEditor *editor) followup->message_list = GTK_CLIST (glade_xml_get_widget (gui, "message_list")); - followup->type = GTK_OPTION_MENU (glade_xml_get_widget (gui, "followup_type")); - gtk_option_menu_remove_menu (followup->type); - menu = gtk_menu_new (); - for (i = 0; i <= FOLLOWUP_FLAG_NONE; i++) { - item = gtk_menu_item_new_with_label (_(available_flags[i].i18n_name)); - gtk_object_set_data (GTK_OBJECT (item), "value", - GINT_TO_POINTER (available_flags[i].value)); - gtk_signal_connect (GTK_OBJECT (item), "activate", - type_changed, followup); - gtk_menu_append (GTK_MENU (menu), item); - gtk_widget_show (item); - } - followup->none = item; - gtk_option_menu_set_menu (followup->type, menu); - gtk_signal_emit_by_name (GTK_OBJECT (item), "activate", followup); - gtk_option_menu_set_history (followup->type, FOLLOWUP_FLAG_NONE); + followup->combo = GTK_COMBO (glade_xml_get_widget (gui, "combo")); + gtk_combo_set_case_sensitive (followup->combo, FALSE); + strings = NULL; + for (i = 0; i < num_available_flags; i++) + strings = g_list_append (strings, (char *) _(available_flags[i])); + gtk_combo_set_popdown_strings (followup->combo, strings); + g_list_free (strings); followup->target_date = E_DATE_EDIT (glade_xml_get_widget (gui, "target_date")); - e_date_edit_set_time (followup->target_date, time (NULL)); - gtk_signal_connect (GTK_OBJECT (followup->target_date), "changed", - target_date_changed, followup); + e_date_edit_set_time (followup->target_date, (time_t) -1); followup->completed = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "completed")); gtk_signal_connect (GTK_OBJECT (followup->completed), "toggled", diff --git a/mail/message-tag-followup.h b/mail/message-tag-followup.h index d7a369e75f..025e3d4cba 100644 --- a/mail/message-tag-followup.h +++ b/mail/message-tag-followup.h @@ -36,29 +36,10 @@ extern "C" { #pragma } #endif /* __cplusplus */ -#define MESSAGE_TAG_FOLLOWUP(obj) GTK_CHECK_CAST (obj, message_tag_followup_get_type (), MessageTagFollowUp) -#define MESSAGE_TAG_FOLLOWUP_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, message_tag_followup_get_type (), MessageTagFollowUpClass) -#define IS_MESSAGE_TAG_FOLLOWUP(obj) GTK_CHECK_TYPE (obj, message_tag_followup_get_type ()) - -enum { - FOLLOWUP_FLAG_CALL, - FOLLOWUP_FLAG_DO_NOT_FORWARD, - FOLLOWUP_FLAG_FOLLOWUP, - FOLLOWUP_FLAG_FYI, - FOLLOWUP_FLAG_FORWARD, - FOLLOWUP_FLAG_NO_RESPONSE_NECESSARY, - FOLLOWUP_FLAG_READ, - FOLLOWUP_FLAG_REPLY, - FOLLOWUP_FLAG_REPLY_ALL, - FOLLOWUP_FLAG_REVIEW, - FOLLOWUP_FLAG_NONE -}; - -struct _FollowUpTag { - int type; - time_t target_date; - time_t completed; -}; +#define MESSAGE_TAG_FOLLOWUP_TYPE (message_tag_followup_get_type ()) +#define MESSAGE_TAG_FOLLOWUP(obj) (GTK_CHECK_CAST (obj, MESSAGE_TAG_FOLLOWUP_TYPE, MessageTagFollowUp)) +#define MESSAGE_TAG_FOLLOWUP_CLASS(klass) (GTK_CHECK_CLASS_CAST (klass, MESSAGE_TAG_FOLLOWUP_TYPE, MessageTagFollowUpClass)) +#define IS_MESSAGE_TAG_FOLLOWUP(obj) (GTK_CHECK_TYPE (obj, MESSAGE_TAG_FOLLOWUP_TYPE)) typedef struct _MessageTagFollowUp MessageTagFollowUp; typedef struct _MessageTagFollowUpClass MessageTagFollowUpClass; @@ -66,17 +47,15 @@ typedef struct _MessageTagFollowUpClass MessageTagFollowUpClass; struct _MessageTagFollowUp { MessageTagEditor parent; - struct _FollowUpTag *tag; - char *value; - GtkCList *message_list; - GtkOptionMenu *type; - GtkWidget *none; + GtkCombo *combo; EDateEdit *target_date; GtkToggleButton *completed; GtkButton *clear; + + time_t completed_date; }; struct _MessageTagFollowUpClass { @@ -89,11 +68,6 @@ struct _MessageTagFollowUpClass { GtkType message_tag_followup_get_type (void); -/* utility functions */ -struct _FollowUpTag *message_tag_followup_decode (const char *tag_value); -char *message_tag_followup_encode (struct _FollowUpTag *followup); -const char *message_tag_followup_i18n_name (int type); - MessageTagEditor *message_tag_followup_new (void); void message_tag_followup_append_message (MessageTagFollowUp *editor, diff --git a/mail/message-tags.glade b/mail/message-tags.glade index fbb9076e99..e16f932555 100644 --- a/mail/message-tags.glade +++ b/mail/message-tags.glade @@ -201,7 +201,7 @@ Please select a follow up action from the "Flag" menu.</label> <yalign>0.5</yalign> <xpad>0</xpad> <ypad>0</ypad> - <default_focus_target>followup_type</default_focus_target> + <default_focus_target>combo-entry</default_focus_target> <child> <left_attach>0</left_attach> <right_attach>1</right_attach> @@ -290,27 +290,17 @@ Please select a follow up action from the "Flag" menu.</label> </widget> <widget> - <class>GtkOptionMenu</class> - <name>followup_type</name> - <can_focus>True</can_focus> - <items>None -Call -Do Not Forward -Follow-Up -For Your Information -Forward -No Response Necessary -Read -Reply -Reply to All -Review -</items> - <initial_choice>0</initial_choice> + <class>Custom</class> + <name>target_date</name> + <creation_function>target_date_new</creation_function> + <int1>0</int1> + <int2>0</int2> + <last_modification_time>Sat, 09 Feb 2002 00:20:24 GMT</last_modification_time> <child> <left_attach>1</left_attach> <right_attach>2</right_attach> - <top_attach>0</top_attach> - <bottom_attach>1</bottom_attach> + <top_attach>1</top_attach> + <bottom_attach>2</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>False</xexpand> @@ -318,31 +308,44 @@ Review <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> - <yfill>False</yfill> + <yfill>True</yfill> </child> </widget> <widget> - <class>Custom</class> - <name>target_date</name> - <creation_function>target_date_new</creation_function> - <int1>0</int1> - <int2>0</int2> - <last_modification_time>Sat, 09 Feb 2002 00:20:24 GMT</last_modification_time> + <class>GtkCombo</class> + <name>combo</name> + <value_in_list>False</value_in_list> + <ok_if_empty>True</ok_if_empty> + <case_sensitive>False</case_sensitive> + <use_arrows>True</use_arrows> + <use_arrows_always>False</use_arrows_always> + <items></items> <child> <left_attach>1</left_attach> <right_attach>2</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> + <top_attach>0</top_attach> + <bottom_attach>1</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> - <xexpand>False</xexpand> + <xexpand>True</xexpand> <yexpand>False</yexpand> <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> - <yfill>True</yfill> + <yfill>False</yfill> </child> + + <widget> + <class>GtkEntry</class> + <child_name>GtkCombo:entry</child_name> + <name>combo-entry</name> + <can_focus>True</can_focus> + <editable>True</editable> + <text_visible>True</text_visible> + <text_max_length>0</text_max_length> + <text></text> + </widget> </widget> </widget> </widget> |