2011-10-07 [colin] 3.7.10cvs21
[claws.git] / src / prefs_message.c
index e85bc69f0a723435e50ccea46d234740b7d5307d..d0b8a65bc81ec8e0f6e7a18a005f01ed7b84f3c0 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2005-2007 Colin Leroy <colin@colino.net> & The Claws Mail Team
+ * Copyright (C) 2005-2011 Colin Leroy <colin@colino.net> & The Claws Mail Team
  *
  * 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
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,8 +13,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 #ifdef HAVE_CONFIG_H
@@ -52,13 +52,16 @@ typedef struct _MessagePage
 
        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)
@@ -85,9 +88,10 @@ static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
        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 +99,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);
@@ -148,10 +159,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,7 +176,7 @@ 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_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);
@@ -175,6 +189,7 @@ static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
        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,7 +209,7 @@ 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_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);
@@ -213,6 +228,33 @@ 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);
 
@@ -225,8 +267,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,6 +281,8 @@ 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;
@@ -242,11 +290,14 @@ static void prefs_message_create_widget(PrefsPage *_page, GtkWindow *window,
        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;
 }
@@ -265,10 +316,14 @@ static void prefs_message_save(PrefsPage *_page)
                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 +331,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);
 }