[evolution] I#248 - Option to open Plain Text composer in Preformatted



commit 7786985494f5a611e1ac630e79381410048427a9
Author: Milan Crha <mcrha redhat com>
Date:   Tue Dec 4 14:05:05 2018 +0100

    I#248 - Option to open Plain Text composer in Preformatted
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/248

 data/org.gnome.evolution.mail.gschema.xml.in |  5 +++++
 src/mail/e-mail-notes.c                      | 20 ++++++++++++++++++--
 src/modules/mail/e-mail-shell-backend.c      | 25 +++++++++++++++++++++----
 3 files changed, 44 insertions(+), 6 deletions(-)
---
diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in
index 9eed9abb72..fec1ba520d 100644
--- a/data/org.gnome.evolution.mail.gschema.xml.in
+++ b/data/org.gnome.evolution.mail.gschema.xml.in
@@ -254,6 +254,11 @@
       <_summary>Mark replied to messages as read</_summary>
       <_description>When replying to a message and marking it as being replied to, then whether also mark it 
as read.</_description>
     </key>
+    <key name="composer-plain-text-starts-preformatted" type="b">
+      <default>false</default>
+      <_summary>Whether start Plain Text composer with Preformatted paragraph mode</_summary>
+      <_description>When set to true, new Plain Text messages will have preselected Preformatted paragraph 
mode. The Normal paragraph mode will be used when set to false.</_description>
+    </key>
     <key name="display-content-disposition-inline" type="b">
       <default>true</default>
       <_summary>Whether to obey Content-Disposition:inline message header hint</_summary>
diff --git a/src/mail/e-mail-notes.c b/src/mail/e-mail-notes.c
index b9224bbedb..db50e57bfd 100644
--- a/src/mail/e-mail-notes.c
+++ b/src/mail/e-mail-notes.c
@@ -921,6 +921,18 @@ e_mail_notes_editor_init (EMailNotesEditor *notes_editor)
 {
 }
 
+static gboolean
+set_preformatted_block_format_on_idle_cb (gpointer user_data)
+{
+       EContentEditor *cnt_editor = user_data;
+
+       g_return_val_if_fail (E_IS_CONTENT_EDITOR (cnt_editor), FALSE);
+
+       e_content_editor_set_block_format (cnt_editor, E_CONTENT_EDITOR_BLOCK_FORMAT_PRE);
+
+       return FALSE;
+}
+
 static EMailNotesEditor *
 e_mail_notes_editor_new_with_editor (EHTMLEditor *html_editor,
                                     GtkWindow *parent,
@@ -1075,8 +1087,12 @@ e_mail_notes_editor_new_with_editor (EHTMLEditor *html_editor,
        gtk_widget_grab_focus (GTK_WIDGET (cnt_editor));
 
        settings = e_util_ref_settings ("org.gnome.evolution.mail");
-       e_content_editor_set_html_mode (
-               cnt_editor, g_settings_get_boolean (settings, "composer-send-html"));
+       e_content_editor_set_html_mode (cnt_editor, g_settings_get_boolean (settings, "composer-send-html"));
+       if (!g_settings_get_boolean (settings, "composer-send-html") &&
+           g_settings_get_boolean (settings, "composer-plain-text-starts-preformatted")) {
+               g_idle_add_full (G_PRIORITY_LOW, set_preformatted_block_format_on_idle_cb,
+                       g_object_ref (cnt_editor), g_object_unref);
+       }
        g_object_unref (settings);
 
        g_signal_connect (
diff --git a/src/modules/mail/e-mail-shell-backend.c b/src/modules/mail/e-mail-shell-backend.c
index 7faf9643b0..c1ab62edbc 100644
--- a/src/modules/mail/e-mail-shell-backend.c
+++ b/src/modules/mail/e-mail-shell-backend.c
@@ -518,6 +518,18 @@ mail_shell_backend_window_weak_notify_cb (EShell *shell,
                where_the_object_was);
 }
 
+static gboolean
+set_preformatted_block_format_on_idle_cb (gpointer user_data)
+{
+       EContentEditor *cnt_editor = user_data;
+
+       g_return_val_if_fail (E_IS_CONTENT_EDITOR (cnt_editor), FALSE);
+
+       e_content_editor_set_block_format (cnt_editor, E_CONTENT_EDITOR_BLOCK_FORMAT_PRE);
+
+       return FALSE;
+}
+
 static void
 mail_shell_backend_window_added_cb (GtkApplication *application,
                                     GtkWindow *window,
@@ -543,18 +555,23 @@ mail_shell_backend_window_added_cb (GtkApplication *application,
        if (editor != NULL) {
                EContentEditor *cnt_editor;
                GSettings *settings;
-               gboolean active = TRUE;
+               gboolean use_html, use_preformatted;
 
                cnt_editor = e_html_editor_get_content_editor (editor);
 
                settings = e_util_ref_settings ("org.gnome.evolution.mail");
 
-               active = g_settings_get_boolean (
-                       settings, "composer-send-html");
+               use_html = g_settings_get_boolean (settings, "composer-send-html");
+               use_preformatted = g_settings_get_boolean (settings, 
"composer-plain-text-starts-preformatted");
 
                g_object_unref (settings);
 
-               e_content_editor_set_html_mode (cnt_editor, active);
+               e_content_editor_set_html_mode (cnt_editor, use_html);
+
+               if (!use_html && use_preformatted) {
+                       g_idle_add_full (G_PRIORITY_LOW, set_preformatted_block_format_on_idle_cb,
+                               g_object_ref (cnt_editor), g_object_unref);
+               }
        }
 
        if (E_IS_MSG_COMPOSER (window)) {


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