add option to avoid Face images being saved to addrbook
[claws.git] / src / prefs_message.c
index 6370ef0de0e7600088b5176b245165d04b7831dd..b8a9a2ca56ce26a2b9cbe8be28e870de887997a9 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2005-2007 Colin Leroy <colin@colino.net> & The Claws Mail Team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2005-2020 the Claws Mail Team and Colin Leroy
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * 
  */
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
+#include "claws-features.h"
 #endif
 
 #include "defs.h"
@@ -49,16 +49,20 @@ typedef struct _MessagePage
        GtkWidget *checkbtn_disphdrpane;
        GtkWidget *checkbtn_disphdr;
        GtkWidget *checkbtn_dispxface;
+       GtkWidget *checkbtn_savexface;
 
        GtkWidget *checkbtn_html;
        GtkWidget *checkbtn_html_plugin;
+       GtkWidget *checkbtn_promote_html_part;
        GtkWidget *spinbtn_linespc;
 
        GtkWidget *checkbtn_smoothscroll;
        GtkWidget *spinbtn_scrollstep;
        GtkWidget *checkbtn_halfpage;
+       GtkWidget *checkbtn_hide_quoted;
 
        GtkWidget *checkbtn_attach_desc;
+       GtkWidget *entry_quote_chars;
 } MessagePage;
 
 static void disphdr_pane_toggled(GtkToggleButton *toggle_btn, GtkWidget *widget)
@@ -81,13 +85,15 @@ static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
        GtkWidget *checkbtn_disphdrpane;
        GtkWidget *checkbtn_disphdr;
        GtkWidget *checkbtn_dispxface;
+       GtkWidget *checkbtn_savexface;
 
        GtkWidget *button_edit_disphdr;
        GtkWidget *checkbtn_html;
        GtkWidget *checkbtn_html_plugin;
+       GtkWidget *checkbtn_promote_html_part;
        GtkWidget *hbox_linespc;
        GtkWidget *label_linespc;
-       GtkObject *spinbtn_linespc_adj;
+       GtkAdjustment *spinbtn_linespc_adj;
        GtkWidget *spinbtn_linespc;
 
        GtkWidget *frame;
@@ -95,11 +101,18 @@ static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
        GtkWidget *checkbtn_smoothscroll;
        GtkWidget *hbox_scr;
        GtkWidget *label_scr;
-       GtkObject *spinbtn_scrollstep_adj;
+       GtkAdjustment *spinbtn_scrollstep_adj;
        GtkWidget *spinbtn_scrollstep;
        GtkWidget *checkbtn_halfpage;
+       GtkWidget *checkbtn_hide_quoted;
 
        GtkWidget *checkbtn_attach_desc;
+       
+       GtkWidget *frame_quote;
+       GtkWidget *hbox2;
+       GtkWidget *vbox_quote;
+       GtkWidget *entry_quote_chars;
+       GtkWidget *label_quote_chars;
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
@@ -113,9 +126,13 @@ static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
 #if HAVE_LIBCOMPFACE
        PACK_CHECK_BUTTON(vbox2, checkbtn_dispxface,
                          _("Display (X-)Face in message view"));
+       PACK_CHECK_BUTTON(vbox2, checkbtn_savexface,
+                         _("Save (X-)Face in address book if possible"));
 #else
        PACK_CHECK_BUTTON(vbox2, checkbtn_dispxface,
                          _("Display Face in message view"));
+       PACK_CHECK_BUTTON(vbox2, checkbtn_savexface,
+                         _("Save Face in address book if possible"));
 #endif
 
        gtk_widget_set_sensitive(checkbtn_dispxface, 
@@ -148,10 +165,13 @@ static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
 
        PACK_CHECK_BUTTON(vbox2, checkbtn_html_plugin,
                          _("Render HTML-only messages with plugin if possible"));
+       
+       PACK_CHECK_BUTTON(vbox2, checkbtn_promote_html_part,
+                         _("Select the HTML part of multipart/alternative messages"));
 
        hbox1 = gtk_hbox_new (FALSE, 32);
        gtk_widget_show (hbox1);
-       gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
+       gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, TRUE, 0);
 
        hbox_linespc = gtk_hbox_new (FALSE, 8);
        gtk_widget_show (hbox1);
@@ -162,19 +182,19 @@ static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
        gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
                            FALSE, FALSE, 0);
 
-       spinbtn_linespc_adj = gtk_adjustment_new (2, 0, 16, 1, 1, 16);
+       spinbtn_linespc_adj = GTK_ADJUSTMENT(gtk_adjustment_new (2, 0, 16, 1, 1, 0));
        spinbtn_linespc = gtk_spin_button_new
                (GTK_ADJUSTMENT (spinbtn_linespc_adj), 1, 0);
        gtk_widget_show (spinbtn_linespc);
        gtk_box_pack_start (GTK_BOX (hbox_linespc), spinbtn_linespc,
                            FALSE, FALSE, 0);
-       gtk_widget_set_size_request (spinbtn_linespc, 64, -1);
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_linespc), TRUE);
 
-       label_linespc = gtk_label_new (_("pixel(s)"));
+       label_linespc = gtk_label_new (_("pixels"));
        gtk_widget_show (label_linespc);
        gtk_box_pack_start (GTK_BOX (hbox_linespc), label_linespc,
                            FALSE, FALSE, 0);
+       gtk_widget_show_all (hbox1);
 
        vbox_scr = gtkut_get_options_frame(vbox1, &frame, _("Scroll"));
 
@@ -194,17 +214,16 @@ static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
        gtk_widget_show (label_scr);
        gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
 
-       spinbtn_scrollstep_adj = gtk_adjustment_new (1, 1, 100, 1, 10, 10);
+       spinbtn_scrollstep_adj = GTK_ADJUSTMENT(gtk_adjustment_new (1, 1, 100, 1, 10, 0));
        spinbtn_scrollstep = gtk_spin_button_new
                (GTK_ADJUSTMENT (spinbtn_scrollstep_adj), 1, 0);
        gtk_widget_show (spinbtn_scrollstep);
        gtk_box_pack_start (GTK_BOX (hbox_scr), spinbtn_scrollstep,
                            FALSE, FALSE, 0);
-       gtk_widget_set_size_request (spinbtn_scrollstep, 64, -1);
        gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_scrollstep),
                                     TRUE);
 
-       label_scr = gtk_label_new (_("pixel(s)"));
+       label_scr = gtk_label_new (_("pixels"));
        gtk_widget_show (label_scr);
        gtk_box_pack_start (GTK_BOX (hbox_scr), label_scr, FALSE, FALSE, 0);
 
@@ -213,11 +232,40 @@ static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
        PACK_CHECK_BUTTON(vbox1, checkbtn_attach_desc,
                          _("Show attachment descriptions (rather than names)"));
 
+       /* quote chars */
+       PACK_FRAME (vbox1, frame_quote, _("Quotation"));
+
+       vbox_quote = gtk_vbox_new (FALSE, VSPACING_NARROW);
+       gtk_widget_show (vbox_quote);
+       gtk_container_add (GTK_CONTAINER (frame_quote), vbox_quote);
+       gtk_container_set_border_width (GTK_CONTAINER (vbox_quote), 8);
+
+       hbox1 = gtk_hbox_new (FALSE, 32);
+       gtk_widget_show (hbox1);
+       PACK_CHECK_BUTTON(vbox_quote, checkbtn_hide_quoted, _("Collapse quoted text on double click"));
+       gtk_box_pack_start (GTK_BOX (vbox_quote), hbox1, FALSE, FALSE, 0);
+
+       hbox2 = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (hbox2);
+       gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, FALSE, 0);
+
+       label_quote_chars = gtk_label_new (_("Treat these characters as quotation marks"));
+       gtk_widget_show (label_quote_chars);
+       gtk_box_pack_start (GTK_BOX (hbox2), label_quote_chars, FALSE, FALSE, 0);
+
+       entry_quote_chars = gtk_entry_new ();
+       gtk_widget_show (entry_quote_chars);
+       gtk_box_pack_start (GTK_BOX (hbox2), entry_quote_chars,
+                           FALSE, FALSE, 0);
+       gtk_widget_set_size_request (entry_quote_chars, 64, -1);
+
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_disphdrpane),
                prefs_common.display_header_pane);
 
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_dispxface),
                prefs_common.display_xface);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_savexface),
+               prefs_common.save_xface);
 
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_disphdr),
                prefs_common.display_header);
@@ -225,8 +273,12 @@ static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
                prefs_common.render_html);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_html_plugin),
                prefs_common.invoke_plugin_on_html);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_promote_html_part),
+               prefs_common.promote_html_part);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_smoothscroll),
                prefs_common.enable_smooth_scroll);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_hide_quoted),
+               prefs_common.hide_quoted);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_halfpage),
                prefs_common.scroll_halfpage);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_attach_desc),
@@ -235,18 +287,24 @@ static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
                prefs_common.line_space);
        gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_scrollstep),
                prefs_common.scroll_step);
+       gtk_entry_set_text(GTK_ENTRY(entry_quote_chars), 
+                       prefs_common.quote_chars?prefs_common.quote_chars:"");
                
        prefs_message->window = GTK_WIDGET(window);
        prefs_message->checkbtn_disphdrpane = checkbtn_disphdrpane;
        prefs_message->checkbtn_dispxface = checkbtn_dispxface;
+       prefs_message->checkbtn_savexface = checkbtn_savexface;
        prefs_message->checkbtn_disphdr = checkbtn_disphdr;
        prefs_message->checkbtn_html = checkbtn_html;
        prefs_message->checkbtn_html_plugin = checkbtn_html_plugin;
+       prefs_message->checkbtn_promote_html_part = checkbtn_promote_html_part;
        prefs_message->spinbtn_linespc = spinbtn_linespc;
        prefs_message->checkbtn_smoothscroll = checkbtn_smoothscroll;
+       prefs_message->checkbtn_hide_quoted = checkbtn_hide_quoted;
        prefs_message->spinbtn_scrollstep = spinbtn_scrollstep;
        prefs_message->checkbtn_halfpage = checkbtn_halfpage;
        prefs_message->checkbtn_attach_desc = checkbtn_attach_desc;
+       prefs_message->entry_quote_chars = entry_quote_chars;
        
        prefs_message->page.widget = vbox1;
 }
@@ -259,16 +317,22 @@ static void prefs_message_save(PrefsPage *_page)
                GTK_TOGGLE_BUTTON(page->checkbtn_disphdrpane));
        prefs_common.display_xface = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->checkbtn_dispxface));
+       prefs_common.save_xface = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(page->checkbtn_savexface));
        prefs_common.display_header = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->checkbtn_disphdr));
        prefs_common.render_html = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->checkbtn_html));
        prefs_common.invoke_plugin_on_html = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->checkbtn_html_plugin));
+       prefs_common.promote_html_part = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(page->checkbtn_promote_html_part));
        prefs_common.enable_smooth_scroll = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->checkbtn_smoothscroll));
        prefs_common.scroll_halfpage = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->checkbtn_halfpage));
+       prefs_common.hide_quoted = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(page->checkbtn_hide_quoted));
        prefs_common.attach_desc = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->checkbtn_attach_desc));
        prefs_common.line_space = gtk_spin_button_get_value_as_int(
@@ -276,6 +340,11 @@ static void prefs_message_save(PrefsPage *_page)
        prefs_common.scroll_step = gtk_spin_button_get_value_as_int(
                GTK_SPIN_BUTTON(page->spinbtn_scrollstep));
 
+       g_free(prefs_common.quote_chars); 
+       prefs_common.quote_chars = gtk_editable_get_chars(
+                       GTK_EDITABLE(page->entry_quote_chars), 0, -1);
+       remove_space(prefs_common.quote_chars);
+
        main_window_reflect_prefs_all_real(FALSE);
 }