[evolution/wip/webkit2] Bug 513779 - Select reply style per mail account



commit abf8e44b74e484c79e80656fc01421777f2f0cb2
Author: Milan Crha <mcrha redhat com>
Date:   Thu Sep 24 15:41:33 2015 +0200

    Bug 513779 - Select reply style per mail account

 mail/e-mail-config-defaults-page.c |  128 ++++++++++++++++++++++++++++++++++++
 mail/em-composer-utils.c           |   49 ++++++++++++++
 2 files changed, 177 insertions(+), 0 deletions(-)
---
diff --git a/mail/e-mail-config-defaults-page.c b/mail/e-mail-config-defaults-page.c
index e9cfbf4..0cc3e61 100644
--- a/mail/e-mail-config-defaults-page.c
+++ b/mail/e-mail-config-defaults-page.c
@@ -371,6 +371,102 @@ mail_config_defaults_page_add_real_folder (EMailConfigDefaultsPage *page,
 }
 
 static void
+mail_config_defaults_fill_reply_style_combox (GtkComboBoxText *combo)
+{
+       struct _values {
+               ESourceMailCompositionReplyStyle reply_style;
+               const gchar *display_name;
+       } values[] = {
+               { E_SOURCE_MAIL_COMPOSITION_REPLY_STYLE_DEFAULT,
+                 NC_("ReplyForward", "Use global setting") },
+               { E_SOURCE_MAIL_COMPOSITION_REPLY_STYLE_ATTACH,
+                 NC_("ReplyForward", "Attachment") },
+               { E_SOURCE_MAIL_COMPOSITION_REPLY_STYLE_OUTLOOK,
+                 NC_("ReplyForward", "Inline (Outlook style)") },
+               { E_SOURCE_MAIL_COMPOSITION_REPLY_STYLE_QUOTED,
+                 NC_("ReplyForward", "Quoted") },
+               { E_SOURCE_MAIL_COMPOSITION_REPLY_STYLE_DO_NOT_QUOTE,
+                 NC_("ReplyForward", "Do Not Quote") }
+       };
+       GEnumClass *enum_class;
+       GEnumValue *enum_value;
+       gint ii;
+
+       g_return_if_fail (GTK_IS_COMBO_BOX_TEXT (combo));
+
+       enum_class = g_type_class_ref (E_TYPE_SOURCE_MAIL_COMPOSITION_REPLY_STYLE);
+       g_return_if_fail (enum_class != NULL);
+
+       g_warn_if_fail (enum_class->n_values == G_N_ELEMENTS (values));
+
+       for (ii = 0; ii < G_N_ELEMENTS (values); ii++) {
+               enum_value = g_enum_get_value (enum_class, values[ii].reply_style);
+               g_warn_if_fail (enum_value != NULL);
+
+               if (enum_value) {
+                       gtk_combo_box_text_append (combo,
+                               enum_value->value_name,
+                               g_dpgettext2 (GETTEXT_PACKAGE, "ReplyForward", values[ii].display_name));
+               }
+       }
+
+       g_type_class_unref (enum_class);
+}
+
+static gboolean
+mail_config_defaults_page_reply_style_to_string (GBinding *binding,
+                                                const GValue *source_value,
+                                                GValue *target_value,
+                                                gpointer data)
+{
+       GEnumClass *enum_class;
+       GEnumValue *enum_value;
+
+       enum_class = g_type_class_ref (E_TYPE_SOURCE_MAIL_COMPOSITION_REPLY_STYLE);
+       g_return_val_if_fail (enum_class != NULL, FALSE);
+
+       enum_value = g_enum_get_value (enum_class, g_value_get_enum (source_value));
+       g_return_val_if_fail (enum_value != NULL, FALSE);
+
+       g_value_set_string (target_value, enum_value->value_name);
+
+       g_type_class_unref (enum_class);
+
+       return TRUE;
+}
+
+static gboolean
+mail_config_defaults_page_string_to_reply_style (GBinding *binding,
+                                                const GValue *source_value,
+                                                GValue *target_value,
+                                                gpointer data)
+{
+       GEnumClass *enum_class;
+       GEnumValue *enum_value;
+       const gchar *value_name;
+
+       enum_class = g_type_class_ref (E_TYPE_SOURCE_MAIL_COMPOSITION_REPLY_STYLE);
+       g_return_val_if_fail (enum_class != NULL, FALSE);
+
+       value_name = g_value_get_string (source_value);
+       if (!value_name || !*value_name) {
+               enum_value = NULL;
+       } else {
+               enum_value = g_enum_get_value_by_name (enum_class, value_name);
+       }
+       if (!enum_value)
+               g_value_set_enum (target_value, E_SOURCE_MAIL_COMPOSITION_REPLY_STYLE_DEFAULT);
+       else
+               g_value_set_enum (target_value, enum_value->value);
+
+       g_warn_if_fail (enum_value != NULL);
+
+       g_type_class_unref (enum_class);
+
+       return TRUE;
+}
+
+static void
 mail_config_defaults_page_set_account_source (EMailConfigDefaultsPage *page,
                                               ESource *account_source)
 {
@@ -750,6 +846,38 @@ mail_config_defaults_page_constructed (GObject *object)
                mail_config_defaults_page_string_to_addrs,
                NULL, (GDestroyNotify) NULL);
 
+       widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
+       gtk_grid_attach (GTK_GRID (container), widget, 0, 5, 1, 1);
+       gtk_widget_show (widget);
+
+       container = widget;
+
+       text = _("Re_ply style:");
+       widget = gtk_label_new_with_mnemonic (text);
+       gtk_widget_set_margin_left (widget, 12);
+       gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+       gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+       gtk_widget_show (widget);
+
+       label = GTK_LABEL (widget);
+
+       widget = gtk_combo_box_text_new ();
+       gtk_widget_set_hexpand (widget, FALSE);
+       gtk_label_set_mnemonic_widget (label, widget);
+       gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+       gtk_widget_show (widget);
+
+       mail_config_defaults_fill_reply_style_combox (GTK_COMBO_BOX_TEXT (widget));
+
+       e_binding_bind_property_full (
+               composition_ext, "reply-style",
+               widget, "active-id",
+               G_BINDING_BIDIRECTIONAL |
+               G_BINDING_SYNC_CREATE,
+               mail_config_defaults_page_reply_style_to_string,
+               mail_config_defaults_page_string_to_reply_style,
+               NULL, (GDestroyNotify) NULL);
+
        /*** Message Receipts ***/
 
        widget = gtk_grid_new ();
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 71289c4..e953045 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -3209,6 +3209,7 @@ em_utils_reply_to_message (EShell *shell,
        CamelInternetAddress *to, *cc;
        CamelNNTPAddress *postto = NULL;
        EMsgComposer *composer;
+       ESourceMailCompositionReplyStyle prefer_reply_style = E_SOURCE_MAIL_COMPOSITION_REPLY_STYLE_DEFAULT;
        ESource *source;
        gchar *identity_uid = NULL;
        const gchar *evo_source_header;
@@ -3229,6 +3230,13 @@ em_utils_reply_to_message (EShell *shell,
                        registry, message, folder, message_uid, sort_sources_by_ui, shell);
        if (source != NULL) {
                identity_uid = e_source_dup_uid (source);
+               if (e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_COMPOSITION)) {
+                       ESourceMailComposition *extension;
+
+                       extension = e_source_get_extension (source, E_SOURCE_EXTENSION_MAIL_COMPOSITION);
+                       prefer_reply_style = e_source_mail_composition_get_reply_style (extension);
+               }
+
                g_object_unref (source);
        }
 
@@ -3292,6 +3300,47 @@ em_utils_reply_to_message (EShell *shell,
                e_html_editor_view_set_is_message_from_selection (view, TRUE);
        }
 
+       /* If there was no send-account override */
+       if (!identity_uid) {
+               EComposerHeaderTable *header_table;
+               const gchar *used_identity_uid;
+
+               header_table = e_msg_composer_get_header_table (composer);
+               used_identity_uid = e_composer_header_table_get_identity_uid (header_table);
+
+               if (used_identity_uid) {
+                       source = e_source_registry_ref_source (e_shell_get_registry (shell), 
used_identity_uid);
+                       if (source) {
+                               if (e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_COMPOSITION)) {
+                                       ESourceMailComposition *extension;
+
+                                       extension = e_source_get_extension (source, 
E_SOURCE_EXTENSION_MAIL_COMPOSITION);
+                                       prefer_reply_style = e_source_mail_composition_get_reply_style 
(extension);
+                               }
+
+                               g_object_unref (source);
+                       }
+               }
+       }
+
+       switch (prefer_reply_style) {
+               case E_SOURCE_MAIL_COMPOSITION_REPLY_STYLE_DEFAULT:
+                       /* Do nothing, keep the passed-in reply style. */
+                       break;
+               case E_SOURCE_MAIL_COMPOSITION_REPLY_STYLE_QUOTED:
+                       style = E_MAIL_REPLY_STYLE_QUOTED;
+                       break;
+               case E_SOURCE_MAIL_COMPOSITION_REPLY_STYLE_DO_NOT_QUOTE:
+                       style = E_MAIL_REPLY_STYLE_DO_NOT_QUOTE;
+                       break;
+               case E_SOURCE_MAIL_COMPOSITION_REPLY_STYLE_ATTACH:
+                       style = E_MAIL_REPLY_STYLE_ATTACH;
+                       break;
+               case E_SOURCE_MAIL_COMPOSITION_REPLY_STYLE_OUTLOOK:
+                       style = E_MAIL_REPLY_STYLE_OUTLOOK;
+                       break;
+       }
+
        composer_set_body (composer, message, style, parts_list);
 
        if (folder != NULL) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]