diff options
Diffstat (limited to 'composer/e-msg-composer.c')
-rw-r--r-- | composer/e-msg-composer.c | 270 |
1 files changed, 15 insertions, 255 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 3079e8ed57..9b526f63ac 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -113,37 +113,6 @@ (G_TYPE_INSTANCE_GET_PRIVATE \ ((obj), E_TYPE_MSG_COMPOSER, EMsgComposerPrivate)) -#define E_MSG_COMPOSER_VISIBLE_MASK_SENDER \ - (E_MSG_COMPOSER_VISIBLE_FROM | \ - E_MSG_COMPOSER_VISIBLE_REPLYTO) - -#define E_MSG_COMPOSER_VISIBLE_MASK_BASIC \ - (E_MSG_COMPOSER_VISIBLE_MASK_SENDER | \ - E_MSG_COMPOSER_VISIBLE_SUBJECT) - -#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_POST \ - (E_MSG_COMPOSER_VISIBLE_MASK_BASIC | \ - E_MSG_COMPOSER_VISIBLE_POSTTO) - -typedef enum { - E_MSG_COMPOSER_VISIBLE_FROM = (1 << 0), - E_MSG_COMPOSER_VISIBLE_REPLYTO = (1 << 1), - E_MSG_COMPOSER_VISIBLE_TO = (1 << 2), - E_MSG_COMPOSER_VISIBLE_CC = (1 << 3), - E_MSG_COMPOSER_VISIBLE_BCC = (1 << 4), - E_MSG_COMPOSER_VISIBLE_POSTTO = (1 << 5), - E_MSG_COMPOSER_VISIBLE_SUBJECT = (1 << 7) -} EMsgComposerHeaderVisibleFlags; - enum { SEND, SAVE_DRAFT, @@ -399,6 +368,7 @@ build_message_headers (EMsgComposer *composer, gboolean redirect) { EComposerHeaderTable *table; + EComposerHeader *header; EAccount *account; const gchar *subject; const gchar *reply_to; @@ -449,9 +419,9 @@ build_message_headers (EMsgComposer *composer, } /* To:, Cc:, Bcc: */ - if (e_composer_header_table_get_header_visible (table, E_COMPOSER_HEADER_TO) || - e_composer_header_table_get_header_visible (table, E_COMPOSER_HEADER_CC) || - e_composer_header_table_get_header_visible (table, E_COMPOSER_HEADER_BCC)) { + header = e_composer_header_table_get_header ( + table, E_COMPOSER_HEADER_TO); + if (e_composer_header_get_visible (header)) { EDestination **to, **cc, **bcc; to = e_composer_header_table_get_destinations_to (table); @@ -466,7 +436,9 @@ build_message_headers (EMsgComposer *composer, } /* X-Evolution-PostTo: */ - if (e_composer_header_table_get_header_visible (table, E_COMPOSER_HEADER_POST_TO)) { + header = e_composer_header_table_get_header ( + table, E_COMPOSER_HEADER_POST_TO); + if (e_composer_header_get_visible (header)) { CamelMedium *medium = CAMEL_MEDIUM (msg); const gchar *name = "X-Evolution-PostTo"; GList *list, *iter; @@ -1359,90 +1331,6 @@ msg_composer_subject_changed_cb (EMsgComposer *composer) gtk_window_set_title (GTK_WINDOW (composer), subject); } -enum { - UPDATE_AUTO_CC, - UPDATE_AUTO_BCC, -}; - -static void -update_auto_recipients (EComposerHeaderTable *table, - gint mode, - const gchar *auto_addrs) -{ - EDestination *dest, **destv = NULL; - CamelInternetAddress *iaddr; - GList *list = NULL; - guint length; - gint i; - - if (auto_addrs) { - iaddr = camel_internet_address_new (); - if (camel_address_decode (CAMEL_ADDRESS (iaddr), auto_addrs) != -1) { - for (i = 0; i < camel_address_length (CAMEL_ADDRESS (iaddr)); i++) { - const gchar *name, *addr; - - if (!camel_internet_address_get (iaddr, i, &name, &addr)) - continue; - - dest = e_destination_new (); - e_destination_set_auto_recipient (dest, TRUE); - - if (name) - e_destination_set_name (dest, name); - - if (addr) - e_destination_set_email (dest, addr); - - list = g_list_prepend (list, dest); - } - } - - camel_object_unref (iaddr); - } - - switch (mode) { - case UPDATE_AUTO_CC: - destv = e_composer_header_table_get_destinations_cc (table); - break; - case UPDATE_AUTO_BCC: - destv = e_composer_header_table_get_destinations_bcc (table); - break; - default: - g_return_if_reached (); - } - - if (destv) { - for (i = 0; destv[i]; i++) { - if (!e_destination_is_auto_recipient (destv[i])) { - dest = e_destination_copy (destv[i]); - list = g_list_prepend (list, dest); - } - } - - e_destination_freev (destv); - } - - list = g_list_reverse (list); - - length = g_list_length (list); - destv = destination_list_to_vector_sized (list, length); - - g_list_free (list); - - switch (mode) { - case UPDATE_AUTO_CC: - e_composer_header_table_set_destinations_cc (table, destv); - break; - case UPDATE_AUTO_BCC: - e_composer_header_table_set_destinations_bcc (table, destv); - break; - default: - g_return_if_reached (); - } - - e_destination_freev (destv); -} - static void msg_composer_account_changed_cb (EMsgComposer *composer) { @@ -1453,8 +1341,6 @@ msg_composer_account_changed_cb (EMsgComposer *composer) EAccount *account; gboolean active; gboolean sensitive; - const gchar *cc_addrs = NULL; - const gchar *bcc_addrs = NULL; const gchar *uid; table = e_msg_composer_get_header_table (composer); @@ -1477,11 +1363,6 @@ msg_composer_account_changed_cb (EMsgComposer *composer) active = account->smime_encrypt_default; gtk_toggle_action_set_active (action, active); - if (account->always_cc) - cc_addrs = account->cc_addrs; - if (account->always_bcc) - bcc_addrs = account->bcc_addrs; - uid = account->id->sig_uid; signature = uid ? mail_config_get_signature_by_uid (uid) : NULL; e_composer_header_table_set_signature (table, signature); @@ -1494,8 +1375,6 @@ msg_composer_account_changed_cb (EMsgComposer *composer) gtk_action_set_sensitive (ACTION (SEND_OPTIONS), sensitive); exit: - update_auto_recipients (table, UPDATE_AUTO_CC, cc_addrs); - update_auto_recipients (table, UPDATE_AUTO_BCC, bcc_addrs); e_msg_composer_show_sig_file (composer); } @@ -1634,36 +1513,6 @@ msg_composer_constructor (GType type, G_OBJECT (composer), "current-folder"); g_array_append_val (array, binding_id); - binding_id = gconf_bridge_bind_property ( - gconf_bridge_get (), - COMPOSER_GCONF_VIEW_BCC_KEY, - G_OBJECT (ACTION (VIEW_BCC)), "active"); - g_array_append_val (array, binding_id); - - binding_id = gconf_bridge_bind_property ( - gconf_bridge_get (), - COMPOSER_GCONF_VIEW_CC_KEY, - G_OBJECT (ACTION (VIEW_CC)), "active"); - g_array_append_val (array, binding_id); - - binding_id = gconf_bridge_bind_property ( - gconf_bridge_get (), - COMPOSER_GCONF_VIEW_FROM_KEY, - G_OBJECT (ACTION (VIEW_FROM)), "active"); - g_array_append_val (array, binding_id); - - binding_id = gconf_bridge_bind_property ( - gconf_bridge_get (), - COMPOSER_GCONF_VIEW_POST_TO_KEY, - G_OBJECT (ACTION (VIEW_POST_TO)), "active"); - g_array_append_val (array, binding_id); - - binding_id = gconf_bridge_bind_property ( - gconf_bridge_get (), - COMPOSER_GCONF_VIEW_REPLY_TO_KEY, - G_OBJECT (ACTION (VIEW_REPLY_TO)), "active"); - g_array_append_val (array, binding_id); - binding_id = gconf_bridge_bind_window ( gconf_bridge_get (), COMPOSER_GCONF_WINDOW_PREFIX, @@ -2415,87 +2264,6 @@ e_msg_composer_get_type (void) /* Callbacks. */ -static EMsgComposer * -create_composer (gint visible_mask) -{ - EMsgComposer *composer; - EComposerHeaderTable *table; - GtkToggleAction *action; - gboolean active; - - composer = g_object_new (E_TYPE_MSG_COMPOSER, NULL); - table = E_COMPOSER_HEADER_TABLE (composer->priv->header_table); - - /* Configure View Menu */ - - /* If we're mailing, you cannot disable "To". */ - action = GTK_TOGGLE_ACTION (ACTION (VIEW_TO)); - active = visible_mask & E_MSG_COMPOSER_VISIBLE_TO; - gtk_action_set_sensitive (ACTION (VIEW_TO), active); - gtk_toggle_action_set_active (action, active); - - /* Ditto for "Post-To". */ - action = GTK_TOGGLE_ACTION (ACTION (VIEW_POST_TO)); - active = visible_mask & E_MSG_COMPOSER_VISIBLE_POSTTO; - gtk_action_set_sensitive (ACTION (VIEW_POST_TO), active); - gtk_toggle_action_set_active (action, active); - - /* Disable "Cc" if we're posting. */ - if (!(visible_mask & E_MSG_COMPOSER_VISIBLE_CC)) { - action = GTK_TOGGLE_ACTION (ACTION (VIEW_CC)); - gtk_toggle_action_set_active (action, FALSE); - } - - /* Disable "Bcc" if we're posting. */ - if (!(visible_mask & E_MSG_COMPOSER_VISIBLE_BCC)) { - action = GTK_TOGGLE_ACTION (ACTION (VIEW_BCC)); - gtk_toggle_action_set_active (action, FALSE); - } - - action = GTK_TOGGLE_ACTION (ACTION (VIEW_SUBJECT)); - gtk_toggle_action_set_active (action, TRUE); - - return composer; -} - -/** - * 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. - * - * Returns: A pointer to the newly created widget - **/ - -EMsgComposer * -e_msg_composer_new_with_type (int type) -{ - EMsgComposer *composer; - gint visible_mask; - - switch (type) { - case E_MSG_COMPOSER_MAIL: - visible_mask = E_MSG_COMPOSER_VISIBLE_MASK_MAIL; - break; - - case E_MSG_COMPOSER_POST: - visible_mask = E_MSG_COMPOSER_VISIBLE_MASK_POST; - break; - - default: - visible_mask = - E_MSG_COMPOSER_VISIBLE_MASK_MAIL | - E_MSG_COMPOSER_VISIBLE_MASK_POST; - break; - } - - composer = create_composer (visible_mask); - - set_editor_text (composer, "", TRUE); - - return composer; -} - /** * e_msg_composer_new: * @@ -2506,7 +2274,7 @@ e_msg_composer_new_with_type (int type) EMsgComposer * e_msg_composer_new (void) { - return e_msg_composer_new_with_type (E_MSG_COMPOSER_MAIL); + return g_object_new (E_TYPE_MSG_COMPOSER, NULL); } static void @@ -2932,25 +2700,13 @@ e_msg_composer_new_with_message (CamelMimeMessage *message) GtkToggleAction *action; struct _camel_header_raw *xev; gint len, i; - EMsgComposerPrivate *p; for (headers = CAMEL_MIME_PART (message)->headers;headers;headers = headers->next) { if (!strcmp (headers->name, "X-Evolution-PostTo")) postto = g_list_append (postto, g_strstrip (g_strdup (headers->value))); } - if (postto != NULL) - composer = create_composer (E_MSG_COMPOSER_VISIBLE_MASK_POST); - else - composer = create_composer (E_MSG_COMPOSER_VISIBLE_MASK_MAIL); - p = composer->priv; - - if (!composer) { - g_list_foreach (postto, (GFunc)g_free, NULL); - g_list_free (postto); - return NULL; - } - + composer = e_msg_composer_new (); table = e_msg_composer_get_header_table (composer); if (postto) { @@ -3154,8 +2910,12 @@ e_msg_composer_new_with_message (CamelMimeMessage *message) while (headers) { if (g_ascii_strcasecmp (headers->name, "References") == 0 || g_ascii_strcasecmp (headers->name, "In-Reply-To") == 0) { - g_ptr_array_add (p->extra_hdr_names, g_strdup (headers->name)); - g_ptr_array_add (p->extra_hdr_values, g_strdup (headers->value)); + g_ptr_array_add ( + composer->priv->extra_hdr_names, + g_strdup (headers->name)); + g_ptr_array_add ( + composer->priv->extra_hdr_values, + g_strdup (headers->value)); } headers = headers->next; |