[evolution/wip/tpopela/freeze-fixes] EHTMLEditorView - Add a checkbox to remember the choice when asking if lose formatting



commit 184bc5042d25345b2c2b757a509585ffb7a60838
Author: Tomas Popela <tpopela redhat com>
Date:   Thu Mar 19 10:38:23 2015 +0100

    EHTMLEditorView - Add a checkbox to remember the choice when asking if lose formatting

 data/org.gnome.evolution.mail.gschema.xml.in |    5 ++++
 e-util/e-html-editor-view.c                  |   33 ++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in
index 89373bb..9cc4c3a 100644
--- a/data/org.gnome.evolution.mail.gschema.xml.in
+++ b/data/org.gnome.evolution.mail.gschema.xml.in
@@ -456,6 +456,11 @@
       <_summary>Prompt when replying to many recipients</_summary>
       <_description>It disables/enables the repeated prompts to warn that you are sending a reply to many 
people.</_description>
     </key>
+    <key name="prompt-on-composer-mode-switch" type="b">
+      <default>true</default>
+      <_summary>Prompt when switching composer mode and the content needs to lose its formatting</_summary>
+      <_description>It disables/enables the repeated prompts to warn that you are switching composer mode 
and the content needs to lose its formatting.</_description>
+    </key>
     <key name="browser-close-on-reply-policy" enum="org.gnome.evolution.mail.AutomaticActionPolicy">
       <default>'ask'</default>
       <_summary>Policy for automatically closing the message browser window when forwarding or replying to 
the displayed message.</_summary>
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 4ff3ee9..e9e725d 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -8683,9 +8683,16 @@ process_content_for_html (EHTMLEditorView *view)
 static gboolean
 show_lose_formatting_dialog (EHTMLEditorView *view)
 {
-       gint result;
-       GtkWidget *toplevel, *dialog;
+       gint result, spacing_message_area, spacing_parent;
+       GtkWidget *toplevel, *dialog, *check, *container, *widget;
        GtkWindow *parent = NULL;
+       GSettings *settings;
+
+       settings = e_util_ref_settings ("org.gnome.evolution.mail");
+       if (!g_settings_get_boolean (settings, "prompt-on-composer-mode-switch")) {
+               g_object_unref (settings);
+               return TRUE;
+       }
 
        toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
 
@@ -8705,8 +8712,28 @@ show_lose_formatting_dialog (EHTMLEditorView *view)
                _("_Lose formatting"), GTK_RESPONSE_OK,
                NULL);
 
+       container = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+       check = gtk_check_button_new_with_mnemonic (
+               _("Do not _show this message again"));
+       widget = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog));
+       spacing_message_area = gtk_box_get_spacing (GTK_BOX (widget));
+       widget = gtk_widget_get_parent (widget);
+       spacing_parent = gtk_box_get_spacing (GTK_BOX (widget));
+
+       gtk_widget_set_margin_left (check, spacing_message_area + spacing_parent);
+       gtk_widget_set_margin_right (check, spacing_message_area + spacing_parent);
+
+       gtk_box_pack_start (GTK_BOX (container), check, FALSE, FALSE, 0);
+       gtk_widget_show (check);
+
        result = gtk_dialog_run (GTK_DIALOG (dialog));
 
+       g_settings_set_boolean (
+               settings,
+               "prompt-on-composer-mode-switch",
+               !gtk_toggle_button_get_active (
+                       GTK_TOGGLE_BUTTON (check)));
+
        if (result != GTK_RESPONSE_OK) {
                gtk_widget_destroy (dialog);
                /* Nothing has changed, but notify anyway */
@@ -8716,6 +8743,8 @@ show_lose_formatting_dialog (EHTMLEditorView *view)
 
        gtk_widget_destroy (dialog);
 
+       g_object_unref (settings);
+
        return TRUE;
 }
 


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