diff options
-rw-r--r-- | composer/ChangeLog | 12 | ||||
-rw-r--r-- | composer/e-msg-composer-hdrs.c | 266 | ||||
-rw-r--r-- | composer/e-msg-composer-hdrs.h | 11 | ||||
-rw-r--r-- | composer/e-msg-composer.c | 251 | ||||
-rw-r--r-- | composer/e-msg-composer.h | 15 |
5 files changed, 490 insertions, 65 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog index fe41dea0de..9daef52ed1 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,15 @@ +2004-01-12 Meilof Veeningen <meilof@wanadoo.nl> + + * e-msg-composer.[ch]: added "View To", "View Post To" menu items, + made it possible to see both at the same time, new + e_msg_composer_new_with_type, only visibility info of headers if + in the visible mask. + + * e-msg-composer.[ch]: replaced folder selection button by entry + with selection button next to it, enabled multiple folder selection, + made it possible to see both To and PostTo fields, disabled + setting the "X-Evolution-PostTo" header. + 2004-01-09 Jeffrey Stedfast <fejj@ximian.com> * e-msg-composer.c (autosave_manager_query_load_orphans): diff --git a/composer/e-msg-composer-hdrs.c b/composer/e-msg-composer-hdrs.c index 4e222b0bfd..fe64e96c5f 100644 --- a/composer/e-msg-composer-hdrs.c +++ b/composer/e-msg-composer-hdrs.c @@ -50,7 +50,10 @@ #include <camel/camel.h> #include "e-msg-composer-hdrs.h" #include "mail/mail-config.h" -#include "mail/em-folder-selection-button.h" +/*#include "mail/em-folder-selection-button.h"*/ +#include "mail/em-folder-selector.h" +#include "mail/mail-component.h" +#include "mail/em-folder-tree.h" @@ -82,6 +85,8 @@ struct _EMsgComposerHdrsPrivate { EAccountList *accounts; GSList *from_options; + gboolean post_custom; + /* Standard headers. */ EMsgComposerHdrPair from, reply_to, to, cc, bcc, post_to, subject; }; @@ -179,6 +184,11 @@ from_changed (GtkWidget *item, gpointer data) { EMsgComposerHdrs *hdrs = E_MSG_COMPOSER_HDRS (data); const char *reply_to; + GList *post_items = NULL; + + /* this will retrieve items relative to the previous account */ + if (!hdrs->priv->post_custom) + post_items = e_msg_composer_hdrs_get_post_to(hdrs); hdrs->account = g_object_get_data ((GObject *) item, "account"); @@ -187,6 +197,13 @@ from_changed (GtkWidget *item, gpointer data) reply_to = hdrs->account->id->reply_to; gtk_entry_set_text (GTK_ENTRY (hdrs->priv->reply_to.entry), reply_to ? reply_to : ""); + /* folders should be made relative to the new from */ + if (!hdrs->priv->post_custom) { + e_msg_composer_hdrs_set_post_to_list (hdrs, post_items); + g_list_foreach (post_items, (GFunc)g_free, NULL); + g_list_free(post_items); + } + g_signal_emit (hdrs, signals [FROM_CHANGED], 0); } @@ -460,6 +477,51 @@ create_addressbook_entry (EMsgComposerHdrs *hdrs, const char *name) return control_widget; } +static void +post_browser_response (EMFolderSelector *emfs, int response, EMsgComposerHdrs *hdrs) +{ + if (response == GTK_RESPONSE_OK) { + GList *uris = em_folder_selector_get_selected_uris (emfs); + e_msg_composer_hdrs_set_post_to_list (hdrs, uris); + hdrs->priv->post_custom = FALSE; + g_list_foreach (uris, (GFunc) g_free, NULL); + g_list_free (uris); + } + + gtk_widget_destroy ((GtkWidget *) emfs); +} + +static void +post_browser_clicked_cb (GtkButton *button, EMsgComposerHdrs *hdrs) +{ + EMFolderTreeModel *model; + EMFolderTree *emft; + GtkWidget *dialog; + GList *post_items; + + model = mail_component_peek_tree_model (mail_component_peek ()); + emft = (EMFolderTree *) em_folder_tree_new_with_model (model); + em_folder_tree_set_multiselect (emft, TRUE); + + dialog = em_folder_selector_new (emft, EM_FOLDER_SELECTOR_CAN_CREATE, + _("Posting destination"), + _("Choose folders to post the message to.")); + + post_items = e_msg_composer_hdrs_get_post_to (hdrs); + em_folder_selector_set_selected_list ((EMFolderSelector *) dialog, post_items); + g_list_foreach (post_items, (GFunc) g_free, NULL); + g_list_free (post_items); + + g_signal_connect (dialog, "response", G_CALLBACK (post_browser_response), hdrs); + gtk_widget_show (dialog); +} + +static void +post_entry_changed_cb (GtkButton *button, EMsgComposerHdrs *hdrs) +{ + hdrs->priv->post_custom = TRUE; +} + static EMsgComposerHdrPair header_new_recipient (EMsgComposerHdrs *hdrs, const char *name, const char *tip) { @@ -544,8 +606,17 @@ create_headers (EMsgComposerHdrs *hdrs) /* * Post-To */ - priv->post_to.label = gtk_label_new (_("Post To:")); - priv->post_to.entry = em_folder_selection_button_new (_("Posting destination"), _("Choose a folder to post the message to.")); + priv->post_to.label = gtk_button_new_with_label (_("Post To:")); + GTK_OBJECT_UNSET_FLAGS (priv->post_to.label, GTK_CAN_FOCUS); + g_signal_connect (priv->post_to.label, "clicked", + G_CALLBACK (post_browser_clicked_cb), hdrs); + gtk_tooltips_set_tip (hdrs->priv->tooltips, priv->post_to.label, + _("Click here to select folders to post to"), + NULL); + + priv->post_to.entry = gtk_entry_new (); + g_signal_connect(priv->post_to.entry, "changed", + G_CALLBACK (post_entry_changed_cb), hdrs); } static void @@ -579,7 +650,7 @@ attach_headers (EMsgComposerHdrs *hdrs) static void set_pair_visibility (EMsgComposerHdrs *h, EMsgComposerHdrPair *pair, int visible) { - if (visible & h->visible_mask) { + if (visible /*& h->visible_mask*/) { gtk_widget_show (pair->label); gtk_widget_show (pair->entry); } else { @@ -611,21 +682,14 @@ headers_set_visibility (EMsgComposerHdrs *h, int visible_flags) static void headers_set_sensitivity (EMsgComposerHdrs *h) { + /* these ones are always on */ bonobo_ui_component_set_prop ( - h->priv->uic, "/commands/ViewFrom", "sensitive", - h->visible_mask & E_MSG_COMPOSER_VISIBLE_FROM ? "1" : "0", NULL); + h->priv->uic, "/commands/ViewTo", "sensitive", + h->visible_mask & E_MSG_COMPOSER_VISIBLE_TO ? "0" : "1", NULL); bonobo_ui_component_set_prop ( - h->priv->uic, "/commands/ViewReplyTo", "sensitive", - h->visible_mask & E_MSG_COMPOSER_VISIBLE_REPLYTO ? "1" : "0", NULL); - - bonobo_ui_component_set_prop ( - h->priv->uic, "/commands/ViewCC", "sensitive", - h->visible_mask & E_MSG_COMPOSER_VISIBLE_CC ? "1" : "0", NULL); - - bonobo_ui_component_set_prop ( - h->priv->uic, "/commands/ViewBCC", "sensitive", - h->visible_mask & E_MSG_COMPOSER_VISIBLE_BCC ? "1" : "0", NULL); + h->priv->uic, "/commands/ViewPostTo", "sensitive", + h->visible_mask & E_MSG_COMPOSER_VISIBLE_POSTTO ? "0" : "1", NULL); } void @@ -775,6 +839,8 @@ init (EMsgComposerHdrs *hdrs) priv->accounts = mail_config_get_accounts (); g_object_ref (priv->accounts); + + priv->post_custom = FALSE; hdrs->priv = priv; } @@ -958,11 +1024,13 @@ e_msg_composer_hdrs_to_message_internal (EMsgComposerHdrs *hdrs, eab_destination_freev (bcc_destv); } +#if 0 if (hdrs->visible_mask & E_MSG_COMPOSER_VISIBLE_POSTTO) { header = e_msg_composer_hdrs_get_post_to (hdrs); camel_medium_set_header (CAMEL_MEDIUM (msg), "X-Evolution-PostTo", header); g_free (header); } +#endif } @@ -1096,12 +1164,144 @@ void e_msg_composer_hdrs_set_post_to (EMsgComposerHdrs *hdrs, const char *post_to) { + GList *list; + g_return_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs)); g_return_if_fail (post_to != NULL); - em_folder_selection_button_set_selection ((EMFolderSelectionButton *) hdrs->priv->post_to.entry, post_to); + list = g_list_append (NULL, g_strdup (post_to)); + + e_msg_composer_hdrs_set_post_to_list (hdrs, list); + + g_free (list->data) + g_list_free (list); } +static GList * +newsgroups_list_split (const char *list) +{ + GList *lst = NULL; + char *tmp; + char **items, **cur_ptr; + + cur_ptr = items = g_strsplit (list, ",", 0); + + while ((tmp = *cur_ptr) != NULL) { + g_strstrip (tmp); + + if (tmp[0]) + lst = g_list_append (lst, g_strdup (tmp)); + + cur_ptr++; + } + + g_strfreev (items); + + return lst; +} + +static char * +get_account_store_url (EMsgComposerHdrs *hdrs) +{ + CamelURL *url; + char *ret = NULL; + + if (hdrs->account->source && hdrs->account->source->url) { + url = camel_url_new (hdrs->account->source->url, NULL); + ret = camel_url_to_string (url, CAMEL_URL_HIDE_ALL); + camel_url_free (url); + } + + return ret; +} + +static char * +folder_name_to_string (EMsgComposerHdrs *hdrs, const char *uri) +{ + char *storeurl = get_account_store_url (hdrs); + int len; + + if (storeurl) { + len = strlen (storeurl); + + if (g_ascii_strncasecmp (uri, storeurl, len) == 0) { + g_free (storeurl); + return g_strdup (uri + len); + } + + g_free (storeurl); + } + + return g_strdup (uri); +} + +void +e_msg_composer_hdrs_set_post_to_list (EMsgComposerHdrs *hdrs, GList *urls) +{ + /* compile the name */ + char *caption, *tmp, *tmp2; + gboolean post_custom; + + if (hdrs->priv->post_to.entry == NULL) + return; + + caption = g_strdup (""); + + while (urls) { + tmp = folder_name_to_string (hdrs, (char *)urls->data); + if (tmp) { + tmp2 = g_strconcat (caption, ", ", tmp, NULL); + g_free (caption); + caption = tmp2; + g_free (tmp); + } + + urls = g_list_next (urls); + } + + post_custom = hdrs->priv->post_custom; + gtk_entry_set_text (GTK_ENTRY (hdrs->priv->post_to.entry), caption[0] ? caption + 2 : ""); + hdrs->priv->post_custom = post_custom; + g_free (caption); +} + +void +e_msg_composer_hdrs_set_post_to_base (EMsgComposerHdrs *hdrs, + const char *base, const char *post_to) +{ + GList *lst, *curlist; + char *hdr_copy = g_strdup (post_to), *caption, *tmp, *tmp2; + gboolean post_custom; + + /* split to newsgroup names */ + lst = newsgroups_list_split (hdr_copy); + curlist = lst; + + /* compile the name */ + caption = g_strdup (""); + + while (curlist) { + tmp2 = g_strdup_printf ("%s/%s", base, (char *)curlist->data); + tmp = folder_name_to_string (hdrs, tmp2); + g_free (tmp2); + if (tmp) { + tmp2 = g_strconcat (caption, ", ", tmp, NULL); + g_free (caption); + caption = tmp2; + g_free (tmp); + } + curlist = g_list_next (curlist); + } + + post_custom = hdrs->priv->post_custom; + gtk_entry_set_text (GTK_ENTRY (hdrs->priv->post_to.entry), caption[0] ? caption + 2 : ""); + hdrs->priv->post_custom = post_custom; + g_free (caption); + + g_list_foreach (lst, (GFunc) g_free, NULL); + g_list_free (lst); + g_free (hdr_copy); +} void e_msg_composer_hdrs_set_subject (EMsgComposerHdrs *hdrs, @@ -1255,16 +1455,40 @@ e_msg_composer_hdrs_get_recipients (EMsgComposerHdrs *hdrs) } -char * +GList * e_msg_composer_hdrs_get_post_to (EMsgComposerHdrs *hdrs) { - const char *uri; + GList *uris, *cur; + char *storeurl = NULL, *tmp; g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL); - uri = em_folder_selection_button_get_selection ((EMFolderSelectionButton *) hdrs->priv->post_to.entry); + if (hdrs->priv->post_to.entry == NULL) + return NULL; - return g_strdup (uri); + tmp = g_strdup (gtk_entry_get_text (GTK_ENTRY (hdrs->priv->post_to.entry))); + uris = newsgroups_list_split (tmp); + g_free (tmp); + + cur = uris; + while (cur) { + if (strstr ((char *) cur->data, "://") == NULL) { + /* relative folder name: convert to absolute */ + if (!storeurl) + storeurl = get_account_store_url (hdrs); + if (!storeurl) + break; + tmp = g_strconcat (storeurl, cur->data, NULL); + g_free (cur->data); + cur->data = tmp; + } + + cur = cur->next; + } + + g_free (storeurl); + + return uris; } diff --git a/composer/e-msg-composer-hdrs.h b/composer/e-msg-composer-hdrs.h index f3bedb1c34..c84b1417f5 100644 --- a/composer/e-msg-composer-hdrs.h +++ b/composer/e-msg-composer-hdrs.h @@ -82,7 +82,6 @@ typedef enum { E_MSG_COMPOSER_VISIBLE_CC = (1 << 3), E_MSG_COMPOSER_VISIBLE_BCC = (1 << 4), E_MSG_COMPOSER_VISIBLE_POSTTO = (1 << 5), /* for posting to folders */ - E_MSG_COMPOSER_VISIBLE_NEWSGROUP = (1 << 6), /* for posting to newsgroups */ E_MSG_COMPOSER_VISIBLE_SUBJECT = (1 << 7) } EMsgComposerHeaderVisibleFlags; @@ -91,7 +90,6 @@ typedef enum { #define E_MSG_COMPOSER_VISIBLE_MASK_RECIPIENTS (E_MSG_COMPOSER_VISIBLE_TO | E_MSG_COMPOSER_VISIBLE_CC | E_MSG_COMPOSER_VISIBLE_BCC) #define E_MSG_COMPOSER_VISIBLE_MASK_MAIL (E_MSG_COMPOSER_VISIBLE_MASK_BASIC | E_MSG_COMPOSER_VISIBLE_MASK_RECIPIENTS) -#define E_MSG_COMPOSER_VISIBLE_MASK_NEWS (E_MSG_COMPOSER_VISIBLE_MASK_BASIC | E_MSG_COMPOSER_VISIBLE_NEWSGROUP) #define E_MSG_COMPOSER_VISIBLE_MASK_POST (E_MSG_COMPOSER_VISIBLE_MASK_BASIC | E_MSG_COMPOSER_VISIBLE_POSTTO) @@ -117,6 +115,11 @@ void e_msg_composer_hdrs_set_bcc (EMsgComposerHdrs *hdrs, EABDestination **bcc_destv); void e_msg_composer_hdrs_set_post_to (EMsgComposerHdrs *hdrs, const char *post_to); +void e_msg_composer_hdrs_set_post_to_list (EMsgComposerHdrs *hdrs, + GList *urls); +void e_msg_composer_hdrs_set_post_to_base (EMsgComposerHdrs *hdrs, + const char *base, + const char *post_to); void e_msg_composer_hdrs_set_subject (EMsgComposerHdrs *hdrs, const char *subject); @@ -127,9 +130,11 @@ EABDestination **e_msg_composer_hdrs_get_to (EMsgComposerHdrs *hdrs); EABDestination **e_msg_composer_hdrs_get_cc (EMsgComposerHdrs *hdrs); EABDestination **e_msg_composer_hdrs_get_bcc (EMsgComposerHdrs *hdrs); EABDestination **e_msg_composer_hdrs_get_recipients (EMsgComposerHdrs *hdrs); -char *e_msg_composer_hdrs_get_post_to (EMsgComposerHdrs *hdrs); const char *e_msg_composer_hdrs_get_subject (EMsgComposerHdrs *hdrs); +/* list of gchar* uris; this data is to be freed by the caller */ +GList *e_msg_composer_hdrs_get_post_to (EMsgComposerHdrs *hdrs); + GtkWidget *e_msg_composer_hdrs_get_from_hbox (EMsgComposerHdrs *hdrs); GtkWidget *e_msg_composer_hdrs_get_from_omenu (EMsgComposerHdrs *hdrs); GtkWidget *e_msg_composer_hdrs_get_reply_to_entry (EMsgComposerHdrs *hdrs); diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 9ec314cb7a..9d1d7906e2 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -1864,6 +1864,32 @@ menu_view_replyto_cb (BonoboUIComponent *component, } static void +menu_view_to_cb (BonoboUIComponent *component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + if (type != Bonobo_UIComponent_STATE_CHANGED) + return; + + e_msg_composer_set_view_to (E_MSG_COMPOSER (user_data), atoi (state)); +} + +static void +menu_view_postto_cb (BonoboUIComponent *component, + const char *path, + Bonobo_UIComponent_EventType type, + const char *state, + gpointer user_data) +{ + if (type != Bonobo_UIComponent_STATE_CHANGED) + return; + + e_msg_composer_set_view_postto (E_MSG_COMPOSER (user_data), atoi (state)); +} + +static void menu_view_cc_cb (BonoboUIComponent *component, const char *path, Bonobo_UIComponent_EventType type, @@ -2109,6 +2135,22 @@ setup_ui (EMsgComposer *composer) composer->uic, "ViewReplyTo", menu_view_replyto_cb, composer); + /* View/To */ + bonobo_ui_component_set_prop ( + composer->uic, "/commands/ViewTo", + "state", composer->view_to ? "1" : "0", NULL); + bonobo_ui_component_add_listener ( + composer->uic, "ViewTo", + menu_view_to_cb, composer); + + /* View/PostTo */ + bonobo_ui_component_set_prop ( + composer->uic, "/commands/ViewPostTo", + "state", composer->view_postto ? "1" : "0", NULL); + bonobo_ui_component_add_listener ( + composer->uic, "ViewPostTo", + menu_view_postto_cb, composer); + /* View/CC */ bonobo_ui_component_set_prop ( composer->uic, "/commands/ViewCC", @@ -2739,7 +2781,7 @@ e_msg_composer_get_type (void) } static void -e_msg_composer_load_config (EMsgComposer *composer) +e_msg_composer_load_config (EMsgComposer *composer, int visible_mask) { GConfClient *gconf; @@ -2747,8 +2789,12 @@ e_msg_composer_load_config (EMsgComposer *composer) composer->view_from = gconf_client_get_bool ( gconf, "/apps/evolution/mail/composer/view/From", NULL); - composer->view_replyto = gconf_client_get_bool ( + composer->view_replyto = gconf_client_get_bool ( gconf, "/apps/evolution/mail/composer/view/ReplyTo", NULL); + composer->view_to = gconf_client_get_bool ( + gconf, "/apps/evolution/mail/composer/view/To", NULL); + composer->view_postto = gconf_client_get_bool ( + gconf, "/apps/evolution/mail/composer/view/PostTo", NULL); composer->view_cc = gconf_client_get_bool ( gconf, "/apps/evolution/mail/composer/view/Cc", NULL); composer->view_bcc = gconf_client_get_bool ( @@ -2756,6 +2802,25 @@ e_msg_composer_load_config (EMsgComposer *composer) composer->view_subject = gconf_client_get_bool ( gconf, "/apps/evolution/mail/composer/view/Subject", NULL); + /* if we're mailing, you cannot disable to so it should appear checked */ + if (visible_mask & E_MSG_COMPOSER_VISIBLE_TO) + composer->view_to = TRUE; + else + composer->view_to = FALSE; + + /* ditto for post-to */ + if (visible_mask & E_MSG_COMPOSER_VISIBLE_POSTTO) + composer->view_postto = TRUE; + else + composer->view_postto = FALSE; + + /* we set these to false initially if we're posting */ + if (!(visible_mask & E_MSG_COMPOSER_VISIBLE_CC)) + composer->view_cc = FALSE; + + if (!(visible_mask & E_MSG_COMPOSER_VISIBLE_BCC)) + composer->view_bcc = FALSE; + g_object_unref (gconf); } @@ -2768,6 +2833,10 @@ e_msg_composer_get_visible_flags (EMsgComposer *composer) flags |= E_MSG_COMPOSER_VISIBLE_FROM; if (composer->view_replyto) flags |= E_MSG_COMPOSER_VISIBLE_REPLYTO; + if (composer->view_to) + flags |= E_MSG_COMPOSER_VISIBLE_TO; + if (composer->view_postto) + flags |= E_MSG_COMPOSER_VISIBLE_POSTTO; if (composer->view_cc) flags |= E_MSG_COMPOSER_VISIBLE_CC; if (composer->view_bcc) @@ -2806,7 +2875,7 @@ map_default_cb (EMsgComposer *composer, gpointer user_data) if (!text || text[0] == '\0') { bonobo_control_frame_control_activate (cf); - + g_free (text); return; } @@ -2970,7 +3039,7 @@ create_composer (int visible_mask) drop_types, num_drop_types, GDK_ACTION_COPY); g_signal_connect (composer, "drag_data_received", G_CALLBACK (drag_data_received), NULL); - e_msg_composer_load_config (composer); + e_msg_composer_load_config (composer, visible_mask); setup_ui (composer); @@ -3154,64 +3223,59 @@ set_editor_signature (EMsgComposer *composer) /* printf ("set_editor_signature end\n"); */ } - /** - * e_msg_composer_new: + * e_msg_composer_new_with_type: + * + * Create a new message composer widget. The type can be + * E_MSG_COMPOSER_MAIL, E_MSG_COMPOSER_POST or E_MSG_COMPOSER_MAIL_POST. * - * Create a new message composer widget. - * * Return value: A pointer to the newly created widget **/ + EMsgComposer * -e_msg_composer_new (void) +e_msg_composer_new_with_type (int type) { gboolean send_html; GConfClient *gconf; EMsgComposer *new; - + gconf = gconf_client_get_default (); send_html = gconf_client_get_bool (gconf, "/apps/evolution/mail/composer/send_html", NULL); g_object_unref (gconf); - - new = create_composer (E_MSG_COMPOSER_VISIBLE_MASK_MAIL); + + switch (type) { + case E_MSG_COMPOSER_MAIL: + new = create_composer (E_MSG_COMPOSER_VISIBLE_MASK_MAIL); + break; + case E_MSG_COMPOSER_POST: + new = create_composer (E_MSG_COMPOSER_VISIBLE_MASK_POST); + break; + default: + new = create_composer (E_MSG_COMPOSER_VISIBLE_MASK_MAIL | E_MSG_COMPOSER_VISIBLE_MASK_POST); + } + if (new) { e_msg_composer_set_send_html (new, send_html); set_editor_text (new, ""); set_editor_signature (new); } - + return new; } /** - * e_msg_composer_new_post: + * e_msg_composer_new: * * Create a new message composer widget. * * Return value: A pointer to the newly created widget **/ EMsgComposer * -e_msg_composer_new_post (void) +e_msg_composer_new (void) { - gboolean send_html; - GConfClient *gconf; - EMsgComposer *new; - - gconf = gconf_client_get_default (); - send_html = gconf_client_get_bool (gconf, "/apps/evolution/mail/composer/send_html", NULL); - g_object_unref (gconf); - - new = create_composer (E_MSG_COMPOSER_VISIBLE_MASK_POST); - if (new) { - e_msg_composer_set_send_html (new, send_html); - set_editor_text (new, ""); - set_editor_signature (new); - } - - return new; + return e_msg_composer_new_with_type (E_MSG_COMPOSER_MAIL); } - static gboolean is_special_header (const char *hdr_name) { @@ -4704,9 +4768,9 @@ e_msg_composer_set_view_from (EMsgComposer *composer, gboolean view_from) /** * e_msg_composer_get_view_replyto: * @composer: A message composer widget - * + * * Get the status of the "View Reply-To header" flag. - * + * * Return value: The status of the "View Reply-To header" flag. **/ gboolean @@ -4740,6 +4804,7 @@ e_msg_composer_set_view_replyto (EMsgComposer *composer, gboolean view_replyto) bonobo_ui_component_set_prop (composer->uic, "/commands/ViewReplyTo", "state", composer->view_replyto ? "1" : "0", NULL); + /* we do this /only/ if the fields is in the visible_mask */ gconf = gconf_client_get_default (); gconf_client_set_bool (gconf, "/apps/evolution/mail/composer/view/ReplyTo", view_replyto, NULL); g_object_unref (gconf); @@ -4750,6 +4815,108 @@ e_msg_composer_set_view_replyto (EMsgComposer *composer, gboolean view_replyto) /** + * e_msg_composer_get_view_to: + * @composer: A message composer widget + * + * Get the status of the "View To header" flag. + * + * Return value: The status of the "View To header" flag. + **/ +gboolean +e_msg_composer_get_view_to (EMsgComposer *composer) +{ + g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE); + + return composer->view_to; +} + + +/** + * e_msg_composer_set_view_to: + * @composer: A message composer widget + * @state: whether to show or hide the To selector + * + * Controls the state of the To selector + */ +void +e_msg_composer_set_view_to (EMsgComposer *composer, gboolean view_to) +{ + GConfClient *gconf; + + g_return_if_fail (E_IS_MSG_COMPOSER (composer)); + + if ((composer->view_to && view_to) || + (!composer->view_to && !view_to)) + return; + + composer->view_to = view_to; + bonobo_ui_component_set_prop (composer->uic, "/commands/ViewTo", + "state", composer->view_to ? "1" : "0", NULL); + + if ((E_MSG_COMPOSER_HDRS(composer->hdrs))->visible_mask & E_MSG_COMPOSER_VISIBLE_TO) { + gconf = gconf_client_get_default (); + gconf_client_set_bool (gconf, "/apps/evolution/mail/composer/view/To", view_to, NULL); + g_object_unref (gconf); + } + + e_msg_composer_hdrs_set_visible (E_MSG_COMPOSER_HDRS (composer->hdrs), + e_msg_composer_get_visible_flags (composer)); +} + + + +/** + * e_msg_composer_get_view_postto: + * @composer: A message composer widget + * + * Get the status of the "View PostTo header" flag. + * + * Return value: The status of the "View PostTo header" flag. + **/ +gboolean +e_msg_composer_get_view_postto (EMsgComposer *composer) +{ + g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE); + + return composer->view_postto; +} + + +/** + * e_msg_composer_set_view_postto: + * @composer: A message composer widget + * @state: whether to show or hide the PostTo selector + * + * Controls the state of the PostTo selector + */ +void +e_msg_composer_set_view_postto (EMsgComposer *composer, gboolean view_postto) +{ + GConfClient *gconf; + + g_return_if_fail (E_IS_MSG_COMPOSER (composer)); + + if ((composer->view_postto && view_postto) || + (!composer->view_postto && !view_postto)) + return; + + composer->view_postto = view_postto; + bonobo_ui_component_set_prop (composer->uic, "/commands/ViewPostTo", + "state", composer->view_postto ? "1" : "0", NULL); + + if ((E_MSG_COMPOSER_HDRS(composer->hdrs))->visible_mask & E_MSG_COMPOSER_VISIBLE_POSTTO) { + gconf = gconf_client_get_default (); + gconf_client_set_bool (gconf, "/apps/evolution/mail/composer/view/PostTo", view_postto, NULL); + g_object_unref (gconf); + } + + e_msg_composer_hdrs_set_visible (E_MSG_COMPOSER_HDRS (composer->hdrs), + e_msg_composer_get_visible_flags (composer)); +} + + + +/** * e_msg_composer_get_view_cc: * @composer: A message composer widget * @@ -4788,9 +4955,11 @@ e_msg_composer_set_view_cc (EMsgComposer *composer, gboolean view_cc) bonobo_ui_component_set_prop (composer->uic, "/commands/ViewCC", "state", composer->view_cc ? "1" : "0", NULL); - gconf = gconf_client_get_default (); - gconf_client_set_bool (gconf, "/apps/evolution/mail/composer/view/Cc", view_cc, NULL); - g_object_unref (gconf); + if ((E_MSG_COMPOSER_HDRS (composer->hdrs))->visible_mask & E_MSG_COMPOSER_VISIBLE_CC) { + gconf = gconf_client_get_default (); + gconf_client_set_bool (gconf, "/apps/evolution/mail/composer/view/Cc", view_cc, NULL); + g_object_unref (gconf); + } e_msg_composer_hdrs_set_visible (E_MSG_COMPOSER_HDRS (composer->hdrs), e_msg_composer_get_visible_flags (composer)); @@ -4836,9 +5005,11 @@ e_msg_composer_set_view_bcc (EMsgComposer *composer, gboolean view_bcc) bonobo_ui_component_set_prop (composer->uic, "/commands/ViewBCC", "state", composer->view_bcc ? "1" : "0", NULL); - gconf = gconf_client_get_default (); - gconf_client_set_bool (gconf, "/apps/evolution/mail/composer/view/Bcc", view_bcc, NULL); - g_object_unref (gconf); + if ((E_MSG_COMPOSER_HDRS (composer->hdrs))->visible_mask & E_MSG_COMPOSER_VISIBLE_BCC) { + gconf = gconf_client_get_default (); + gconf_client_set_bool (gconf, "/apps/evolution/mail/composer/view/Bcc", view_bcc, NULL); + g_object_unref (gconf); + } e_msg_composer_hdrs_set_visible (E_MSG_COMPOSER_HDRS (composer->hdrs), e_msg_composer_get_visible_flags (composer)); diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h index 528067b2b5..6dd7f77305 100644 --- a/composer/e-msg-composer.h +++ b/composer/e-msg-composer.h @@ -98,6 +98,8 @@ struct _EMsgComposer { guint32 smime_encrypt : 1; guint32 view_from : 1; guint32 view_replyto : 1; + guint32 view_to : 1; + guint32 view_postto : 1; guint32 view_bcc : 1; guint32 view_cc : 1; guint32 view_subject : 1; @@ -128,7 +130,12 @@ struct _EMsgComposerClass { GtkType e_msg_composer_get_type (void); EMsgComposer *e_msg_composer_new (void); -EMsgComposer *e_msg_composer_new_post (void); + +#define E_MSG_COMPOSER_MAIL 1 +#define E_MSG_COMPOSER_POST 2 +#define E_MSG_COMPOSER_MAIL_POST E_MSG_COMPOSER_MAIL|E_MSG_COMPOSER_POST + +EMsgComposer *e_msg_composer_new_with_type (int type); EMsgComposer *e_msg_composer_new_with_message (CamelMimeMessage *msg); EMsgComposer *e_msg_composer_new_from_url (const char *url); @@ -168,9 +175,15 @@ void e_msg_composer_set_send_html (EMsgCo gboolean e_msg_composer_get_view_from (EMsgComposer *composer); void e_msg_composer_set_view_from (EMsgComposer *composer, gboolean view_from); +gboolean e_msg_composer_get_view_to (EMsgComposer *composer); +void e_msg_composer_set_view_to (EMsgComposer *composer, + gboolean view_replyto); gboolean e_msg_composer_get_view_replyto (EMsgComposer *composer); void e_msg_composer_set_view_replyto (EMsgComposer *composer, gboolean view_replyto); +gboolean e_msg_composer_get_view_postto (EMsgComposer *composer); +void e_msg_composer_set_view_postto (EMsgComposer *composer, + gboolean view_replyto); gboolean e_msg_composer_get_view_cc (EMsgComposer *composer); void e_msg_composer_set_view_cc (EMsgComposer *composer, gboolean view_cc); |