move message colouring options to '/Other Preferences/Message View/Colors'
authorPaul Mangan <paul@claws-mail.org>
Wed, 30 Jun 2004 13:45:25 +0000 (13:45 +0000)
committerPaul Mangan <paul@claws-mail.org>
Wed, 30 Jun 2004 13:45:25 +0000 (13:45 +0000)
ChangeLog.claws
configure.ac
po/POTFILES.in
src/Makefile.am
src/main.c
src/prefs_common.c
src/prefs_msg_colors.c [new file with mode: 0644]
src/prefs_msg_colors.h [new file with mode: 0644]

index 2e8dde3..5c63f9e 100644 (file)
@@ -1,3 +1,13 @@
+2004-06-30 [paul]      0.9.12cvs2
+
+       * po/POTFILES.in
+         src/Makefile.am
+         src/main.c
+         src/prefs_common.c
+         src/prefs_msg_colors.[ch]     ** NEW FILES **
+               move message colouring options to
+               '/Other Preferences/Message View/Colors'
+
 2004-06-30 [paul]      0.9.12cvs1
 
        * po/POTFILES.in
index 0274a8a..0a7e547 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=12
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=1
+EXTRA_VERSION=2
 EXTRA_RELEASE=
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
index 85974d3..3142de9 100644 (file)
@@ -90,6 +90,7 @@ src/prefs_folder_item.c
 src/prefs_fonts.c
 src/prefs_gtk.c
 src/prefs_matcher.c
+src/prefs_msg_colors.c
 src/prefs_spelling.c
 src/prefs_summary_column.c
 src/prefs_template.c
index 4381bff..bd64f56 100644 (file)
@@ -94,6 +94,7 @@ sylpheed_SOURCES = \
        prefs_fonts.c \
        prefs_gtk.c \
        prefs_matcher.c \
+       prefs_msg_colors.c \
        prefs_spelling.c \
        prefs_summary_column.c \
        prefs_template.c \
@@ -224,6 +225,7 @@ sylpheedinclude_HEADERS = \
        prefs_fonts.h \
        prefs_gtk.h \
        prefs_matcher.h \
+       prefs_msg_colors.h \
        prefs_spelling.h \
        prefs_summary_column.h \
        prefs_template.h \
index ab394c1..d15a0cb 100644 (file)
@@ -53,6 +53,7 @@
 #include "prefs_actions.h"
 #include "prefs_ext_prog.h"
 #include "prefs_fonts.h"
+#include "prefs_msg_colors.h"
 #include "prefs_spelling.h"
 #include "prefs_themes.h"
 #include "prefs_wrapping.h"
@@ -261,6 +262,7 @@ int main(int argc, char *argv[])
        prefs_fonts_init();
        prefs_ext_prog_init();
        prefs_wrapping_init();
+       prefs_msg_colors_init();
 #ifdef USE_ASPELL
        gtkaspell_checkers_init();
        prefs_spelling_init();
@@ -439,6 +441,7 @@ static void exit_sylpheed(MainWindow *mainwin)
        prefs_fonts_done();
        prefs_ext_prog_done();
        prefs_wrapping_done();
+       prefs_msg_colors_done();
 #ifdef USE_ASPELL       
        prefs_spelling_done();
        gtkaspell_checkers_quit();
index 8dd6694..6a0a2db 100644 (file)
@@ -138,8 +138,6 @@ static struct Display {
 } display;
 
 static struct Message {
-       GtkWidget *chkbtn_enablecol;
-       GtkWidget *button_edit_col;
        GtkWidget *chkbtn_mbalnum;
        GtkWidget *chkbtn_disphdrpane;
        GtkWidget *chkbtn_disphdr;
@@ -194,23 +192,11 @@ static struct Other {
        GtkObject *spinbtn_iotimeout_adj;
 } other;
 
-static struct MessageColorButtons {
-       GtkWidget *quote_level1_btn;
-       GtkWidget *quote_level2_btn;
-       GtkWidget *quote_level3_btn;
-       GtkWidget *uri_btn;
-       GtkWidget *tgt_folder_btn;
-       GtkWidget *signature_btn;
-} color_buttons;
-
 static struct KeybindDialog {
        GtkWidget *window;
        GtkWidget *combo;
 } keybind;
 
-static GtkWidget *quote_color_win;
-static GtkWidget *color_dialog;
-
 static void prefs_common_charset_set_data_from_optmenu    (PrefParam *pparam);
 static void prefs_common_charset_set_optmenu              (PrefParam *pparam);
 static void prefs_common_encoding_set_data_from_optmenu    (PrefParam *pparam);
@@ -582,8 +568,7 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        /* Message */
        {"enable_color", "TRUE", &prefs_common.enable_color, P_BOOL,
-        &message.chkbtn_enablecol,
-        prefs_set_data_from_toggle, prefs_set_toggle},
+        NULL, NULL, NULL},
 
        {"quote_level1_color", "179", &prefs_common.quote_level1_col, P_COLOR,
         NULL, NULL, NULL},
@@ -799,25 +784,6 @@ static void date_format_select_row         (GtkWidget      *date_format_list,
 static GtkWidget *date_format_create            (GtkButton      *button,
                                                  void           *data);
 
-static void prefs_quote_colors_dialog          (void);
-static void prefs_quote_colors_dialog_create   (void);
-static void prefs_quote_colors_key_pressed     (GtkWidget      *widget,
-                                                GdkEventKey    *event,
-                                                gpointer        data);
-static void quote_color_set_dialog             (GtkWidget      *widget,
-                                                gpointer        data);
-static void quote_colors_set_dialog_ok         (GtkWidget      *widget,
-                                                gpointer        data);
-static void quote_colors_set_dialog_cancel     (GtkWidget      *widget,
-                                                gpointer        data);
-static void quote_colors_set_dialog_key_pressed        (GtkWidget      *widget,
-                                                GdkEventKey    *event,
-                                                gpointer        data);
-static void set_button_bg_color                        (GtkWidget      *widget,
-                                                gint            color);
-static void prefs_enable_message_color_toggled (void);
-static void prefs_recycle_colors_toggled       (GtkWidget      *widget);
-
 static void prefs_keybind_select               (void);
 static gint prefs_keybind_deleted              (GtkWidget      *widget,
                                                 GdkEventAny    *event,
@@ -1782,8 +1748,6 @@ static void prefs_message_create(void)
        GtkWidget *vbox2;
        GtkWidget *vbox3;
        GtkWidget *hbox1;
-       GtkWidget *chkbtn_enablecol;
-       GtkWidget *button_edit_col;
        GtkWidget *chkbtn_mbalnum;
        GtkWidget *chkbtn_disphdrpane;
        GtkWidget *chkbtn_disphdr;
@@ -1814,24 +1778,6 @@ static void prefs_message_create(void)
        gtk_widget_show (vbox2);
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
 
-       hbox1 = gtk_hbox_new (FALSE, 8);
-       gtk_widget_show (hbox1);
-       gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, TRUE, 0);
-
-       PACK_CHECK_BUTTON (hbox1, chkbtn_enablecol,
-                          _("Enable coloration of message"));
-       gtk_signal_connect(GTK_OBJECT(chkbtn_enablecol), "toggled",
-                          GTK_SIGNAL_FUNC(prefs_enable_message_color_toggled),
-                          NULL);
-
-       button_edit_col = gtk_button_new_with_label (_(" Edit... "));
-       gtk_widget_show (button_edit_col);
-       gtk_box_pack_end (GTK_BOX (hbox1), button_edit_col, FALSE, TRUE, 0);
-       gtk_signal_connect (GTK_OBJECT (button_edit_col), "clicked",
-                           GTK_SIGNAL_FUNC (prefs_quote_colors_dialog), NULL);
-
-       SET_TOGGLE_SENSITIVITY(chkbtn_enablecol, button_edit_col);
-
        PACK_CHECK_BUTTON
                (vbox2, chkbtn_mbalnum,
                 _("Display multi-byte alphanumeric as\n"
@@ -1936,9 +1882,6 @@ static void prefs_message_create(void)
        PACK_CHECK_BUTTON(vbox3, chkbtn_attach_desc,
                          _("Show attachment descriptions (rather than names)"));
 
-
-       message.chkbtn_enablecol   = chkbtn_enablecol;
-       message.button_edit_col    = button_edit_col;
        message.chkbtn_mbalnum     = chkbtn_mbalnum;
        message.chkbtn_disphdrpane = chkbtn_disphdrpane;
        message.chkbtn_disphdr     = chkbtn_disphdr;
@@ -2623,334 +2566,6 @@ static GtkWidget *date_format_create(GtkButton *button, void *data)
        return datefmt_win;
 }
 
-void prefs_quote_colors_dialog(void)
-{
-       if (!quote_color_win)
-               prefs_quote_colors_dialog_create();
-       gtk_widget_show(quote_color_win);
-       manage_window_set_transient(GTK_WINDOW(quote_color_win));
-
-       gtk_main();
-       gtk_widget_hide(quote_color_win);
-
-       textview_update_message_colors();
-       main_window_reflect_prefs_all();
-}
-
-static void prefs_quote_colors_dialog_create(void)
-{
-       GtkWidget *window;
-       GtkWidget *vbox;
-       GtkWidget *table;
-       GtkWidget *quotelevel1_label;
-       GtkWidget *quotelevel2_label;
-       GtkWidget *quotelevel3_label;
-       GtkWidget *uri_label;
-       GtkWidget *signature_label;
-       GtkWidget *tgt_folder_label;
-       GtkWidget *hbbox;
-       GtkWidget *ok_btn;
-       GtkWidget *recycle_colors_btn;
-       GtkWidget *frame_colors;
-
-       window = gtk_window_new(GTK_WINDOW_DIALOG);
-       gtk_container_set_border_width(GTK_CONTAINER(window), 2);
-       gtk_window_set_title(GTK_WINDOW(window), _("Set message colors"));
-       gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
-       gtk_window_set_modal(GTK_WINDOW(window), TRUE);
-       gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
-
-       vbox = gtk_vbox_new (FALSE, VSPACING);
-       gtk_container_add (GTK_CONTAINER (window), vbox);
-       gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
-       PACK_FRAME(vbox, frame_colors, _("Colors"));
-
-       table = gtk_table_new (5, 2, FALSE);
-       gtk_container_add (GTK_CONTAINER (frame_colors), table);
-       gtk_container_set_border_width (GTK_CONTAINER (table), 8);
-       gtk_table_set_row_spacings (GTK_TABLE (table), 2);
-       gtk_table_set_col_spacings (GTK_TABLE (table), 5);
-
-
-       color_buttons.quote_level1_btn = gtk_button_new();
-       gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level1_btn,
-                         0, 1, 0, 1, 0, 0, 0, 0);
-       gtk_widget_set_usize (color_buttons.quote_level1_btn, 40, 30);
-       gtk_container_set_border_width
-               (GTK_CONTAINER (color_buttons.quote_level1_btn), 5);
-
-       color_buttons.quote_level2_btn = gtk_button_new();
-       gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level2_btn,
-                         0, 1, 1, 2, 0, 0, 0, 0);
-       gtk_widget_set_usize (color_buttons.quote_level2_btn, 40, 30);
-       gtk_container_set_border_width (GTK_CONTAINER (color_buttons.quote_level2_btn), 5);
-
-       color_buttons.quote_level3_btn = gtk_button_new_with_label ("");
-       gtk_table_attach (GTK_TABLE (table), color_buttons.quote_level3_btn,
-                         0, 1, 2, 3, 0, 0, 0, 0);
-       gtk_widget_set_usize (color_buttons.quote_level3_btn, 40, 30);
-       gtk_container_set_border_width
-               (GTK_CONTAINER (color_buttons.quote_level3_btn), 5);
-
-       color_buttons.uri_btn = gtk_button_new_with_label ("");
-       gtk_table_attach (GTK_TABLE (table), color_buttons.uri_btn,
-                         0, 1, 3, 4, 0, 0, 0, 0);
-       gtk_widget_set_usize (color_buttons.uri_btn, 40, 30);
-       gtk_container_set_border_width (GTK_CONTAINER (color_buttons.uri_btn), 5);
-
-       color_buttons.tgt_folder_btn = gtk_button_new_with_label ("");
-       gtk_table_attach (GTK_TABLE (table), color_buttons.tgt_folder_btn,
-                         0, 1, 4, 5, 0, 0, 0, 0);
-       gtk_widget_set_usize (color_buttons.tgt_folder_btn, 40, 30);
-       gtk_container_set_border_width (GTK_CONTAINER (color_buttons.tgt_folder_btn), 5);
-
-       color_buttons.signature_btn = gtk_button_new_with_label ("");
-       gtk_table_attach (GTK_TABLE (table), color_buttons.signature_btn,
-                         0, 1, 5, 6, 0, 0, 0, 0);
-       gtk_widget_set_usize (color_buttons.signature_btn, 40, 30);
-       gtk_container_set_border_width (GTK_CONTAINER (color_buttons.signature_btn), 5);
-
-       quotelevel1_label = gtk_label_new (_("Quoted Text - First Level"));
-       gtk_table_attach (GTK_TABLE (table), quotelevel1_label, 1, 2, 0, 1,
-                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
-       gtk_label_set_justify (GTK_LABEL (quotelevel1_label), GTK_JUSTIFY_LEFT);
-       gtk_misc_set_alignment (GTK_MISC (quotelevel1_label), 0, 0.5);
-
-       quotelevel2_label = gtk_label_new (_("Quoted Text - Second Level"));
-       gtk_table_attach (GTK_TABLE (table), quotelevel2_label, 1, 2, 1, 2,
-                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
-       gtk_label_set_justify (GTK_LABEL (quotelevel2_label), GTK_JUSTIFY_LEFT);
-       gtk_misc_set_alignment (GTK_MISC (quotelevel2_label), 0, 0.5);
-
-       quotelevel3_label = gtk_label_new (_("Quoted Text - Third Level"));
-       gtk_table_attach (GTK_TABLE (table), quotelevel3_label, 1, 2, 2, 3,
-                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
-       gtk_label_set_justify (GTK_LABEL (quotelevel3_label), GTK_JUSTIFY_LEFT);
-       gtk_misc_set_alignment (GTK_MISC (quotelevel3_label), 0, 0.5);
-
-       uri_label = gtk_label_new (_("URI link"));
-       gtk_table_attach (GTK_TABLE (table), uri_label, 1, 2, 3, 4,
-                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
-       gtk_label_set_justify (GTK_LABEL (uri_label), GTK_JUSTIFY_LEFT);
-       gtk_misc_set_alignment (GTK_MISC (uri_label), 0, 0.5);
-
-       tgt_folder_label = gtk_label_new (_("Target folder"));
-       gtk_table_attach (GTK_TABLE (table), tgt_folder_label, 1, 2, 4, 5,
-                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
-       gtk_label_set_justify (GTK_LABEL (tgt_folder_label), GTK_JUSTIFY_LEFT);
-       gtk_misc_set_alignment (GTK_MISC (tgt_folder_label), 0, 0.5);
-
-       signature_label = gtk_label_new (_("Signatures"));
-       gtk_table_attach (GTK_TABLE (table), signature_label, 1, 2, 5, 6,
-                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
-       gtk_label_set_justify (GTK_LABEL (signature_label), GTK_JUSTIFY_LEFT);
-       gtk_misc_set_alignment (GTK_MISC (signature_label), 0, 0.5);
-
-       PACK_CHECK_BUTTON (vbox, recycle_colors_btn,
-                          _("Recycle quote colors"));
-
-       gtkut_button_set_create(&hbbox, &ok_btn, _("OK"),
-                               NULL, NULL, NULL, NULL);
-       gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
-
-       gtk_widget_grab_default(ok_btn);
-       MANAGE_WINDOW_SIGNALS_CONNECT(window);
-       gtk_signal_connect(GTK_OBJECT(window), "delete_event",
-                          GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
-       gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
-                          GTK_SIGNAL_FUNC(prefs_quote_colors_key_pressed),
-                          NULL);
-
-       gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level1_btn), "clicked",
-                          GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL1");
-       gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level2_btn), "clicked",
-                          GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL2");
-       gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level3_btn), "clicked",
-                          GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL3");
-       gtk_signal_connect(GTK_OBJECT(color_buttons.uri_btn), "clicked",
-                          GTK_SIGNAL_FUNC(quote_color_set_dialog), "URI");
-       gtk_signal_connect(GTK_OBJECT(color_buttons.tgt_folder_btn), "clicked",
-                          GTK_SIGNAL_FUNC(quote_color_set_dialog), "TGTFLD");
-       gtk_signal_connect(GTK_OBJECT(color_buttons.signature_btn), "clicked",
-                          GTK_SIGNAL_FUNC(quote_color_set_dialog), "SIGNATURE");
-       gtk_signal_connect(GTK_OBJECT(recycle_colors_btn), "toggled",
-                          GTK_SIGNAL_FUNC(prefs_recycle_colors_toggled), NULL);
-       gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked",
-                          GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
-
-       /* show message button colors and recycle options */
-       set_button_bg_color(color_buttons.quote_level1_btn,
-                           prefs_common.quote_level1_col);
-       set_button_bg_color(color_buttons.quote_level2_btn,
-                           prefs_common.quote_level2_col);
-       set_button_bg_color(color_buttons.quote_level3_btn,
-                           prefs_common.quote_level3_col);
-       set_button_bg_color(color_buttons.uri_btn,
-                           prefs_common.uri_col);
-       set_button_bg_color(color_buttons.tgt_folder_btn,
-                           prefs_common.tgt_folder_col);
-       set_button_bg_color(color_buttons.signature_btn,
-                           prefs_common.signature_col);
-       gtk_toggle_button_set_active((GtkToggleButton *)recycle_colors_btn,
-                                    prefs_common.recycle_quote_colors);
-
-       gtk_widget_show_all(vbox);
-       quote_color_win = window;
-}
-
-static void prefs_quote_colors_key_pressed(GtkWidget *widget,
-                                          GdkEventKey *event, gpointer data)
-{
-       if (event && event->keyval == GDK_Escape)
-               gtk_main_quit();
-}
-
-static void quote_color_set_dialog(GtkWidget *widget, gpointer data)
-{
-       gchar *type = (gchar *)data;
-       gchar *title = NULL;
-       gdouble color[4] = {0.0, 0.0, 0.0, 0.0};
-       gint rgbvalue = 0;
-       GtkColorSelectionDialog *dialog;
-
-       if(g_strcasecmp(type, "LEVEL1") == 0) {
-               title = _("Pick color for quotation level 1");
-               rgbvalue = prefs_common.quote_level1_col;
-       } else if(g_strcasecmp(type, "LEVEL2") == 0) {
-               title = _("Pick color for quotation level 2");
-               rgbvalue = prefs_common.quote_level2_col;
-       } else if(g_strcasecmp(type, "LEVEL3") == 0) {
-               title = _("Pick color for quotation level 3");
-               rgbvalue = prefs_common.quote_level3_col;
-       } else if(g_strcasecmp(type, "URI") == 0) {
-               title = _("Pick color for URI");
-               rgbvalue = prefs_common.uri_col;
-       } else if(g_strcasecmp(type, "TGTFLD") == 0) {
-               title = _("Pick color for target folder");
-               rgbvalue = prefs_common.tgt_folder_col;
-       } else if(g_strcasecmp(type, "SIGNATURE") == 0) {
-               title = _("Pick color for signatures");
-               rgbvalue = prefs_common.signature_col;
-       } else {   /* Should never be called */
-               g_warning("Unrecognized datatype '%s' in quote_color_set_dialog\n", type);
-               return;
-       }
-
-       color_dialog = gtk_color_selection_dialog_new(title);
-       gtk_window_set_position(GTK_WINDOW(color_dialog), GTK_WIN_POS_CENTER);
-       gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
-       gtk_window_set_policy(GTK_WINDOW(color_dialog), FALSE, FALSE, FALSE);
-       manage_window_set_transient(GTK_WINDOW(color_dialog));
-
-       gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->ok_button),
-                          "clicked", GTK_SIGNAL_FUNC(quote_colors_set_dialog_ok), data);
-       gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->cancel_button),
-                          "clicked", GTK_SIGNAL_FUNC(quote_colors_set_dialog_cancel), data);
-       gtk_signal_connect(GTK_OBJECT(color_dialog), "key_press_event",
-                          GTK_SIGNAL_FUNC(quote_colors_set_dialog_key_pressed),
-                          data);
-
-       /* preselect the previous color in the color selection dialog */
-       color[0] = (gdouble) ((rgbvalue & 0xff0000) >> 16) / 255.0;
-       color[1] = (gdouble) ((rgbvalue & 0x00ff00) >>  8) / 255.0;
-       color[2] = (gdouble)  (rgbvalue & 0x0000ff)        / 255.0;
-       dialog = GTK_COLOR_SELECTION_DIALOG(color_dialog);
-       gtk_color_selection_set_color
-               (GTK_COLOR_SELECTION(dialog->colorsel), color);
-
-       gtk_widget_show(color_dialog);
-}
-
-static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
-{
-       GtkColorSelection *colorsel = (GtkColorSelection *)
-                                               ((GtkColorSelectionDialog *)color_dialog)->colorsel;
-       gdouble color[4];
-       gint red, green, blue, rgbvalue;
-       gchar *type = (gchar *)data;
-
-       gtk_color_selection_get_color(colorsel, color);
-
-       red      = (gint) (color[0] * 255.0);
-       green    = (gint) (color[1] * 255.0);
-       blue     = (gint) (color[2] * 255.0);
-       rgbvalue = (gint) ((red * 0x10000) | (green * 0x100) | blue);
-
-#if 0
-       fprintf(stderr, "redc = %f, greenc = %f, bluec = %f\n", color[0], color[1], color[2]);
-       fprintf(stderr, "red = %d, green = %d, blue = %d\n", red, green, blue);
-       fprintf(stderr, "Color is %x\n", rgbvalue);
-#endif
-
-       if (g_strcasecmp(type, "LEVEL1") == 0) {
-               prefs_common.quote_level1_col = rgbvalue;
-               set_button_bg_color(color_buttons.quote_level1_btn, rgbvalue);
-       } else if (g_strcasecmp(type, "LEVEL2") == 0) {
-               prefs_common.quote_level2_col = rgbvalue;
-               set_button_bg_color(color_buttons.quote_level2_btn, rgbvalue);
-       } else if (g_strcasecmp(type, "LEVEL3") == 0) {
-               prefs_common.quote_level3_col = rgbvalue;
-               set_button_bg_color(color_buttons.quote_level3_btn, rgbvalue);
-       } else if (g_strcasecmp(type, "URI") == 0) {
-               prefs_common.uri_col = rgbvalue;
-               set_button_bg_color(color_buttons.uri_btn, rgbvalue);
-       } else if (g_strcasecmp(type, "TGTFLD") == 0) {
-               prefs_common.tgt_folder_col = rgbvalue;
-               set_button_bg_color(color_buttons.tgt_folder_btn, rgbvalue);
-               folderview_set_target_folder_color(prefs_common.tgt_folder_col);
-       } else if (g_strcasecmp(type, "SIGNATURE") == 0) {
-               prefs_common.signature_col = rgbvalue;
-               set_button_bg_color(color_buttons.signature_btn, rgbvalue);
-       } else
-               fprintf( stderr, "Unrecognized datatype '%s' in quote_color_set_dialog_ok\n", type );
-
-       gtk_widget_destroy(color_dialog);
-}
-
-static void quote_colors_set_dialog_cancel(GtkWidget *widget, gpointer data)
-{
-       gtk_widget_destroy(color_dialog);
-}
-
-static void quote_colors_set_dialog_key_pressed(GtkWidget *widget,
-                                               GdkEventKey *event,
-                                               gpointer data)
-{
-       gtk_widget_destroy(color_dialog);
-}
-
-static void set_button_bg_color(GtkWidget *widget, gint rgbvalue)
-{
-       GtkStyle *newstyle;
-       GdkColor color;
-
-       gtkut_convert_int_to_gdk_color(rgbvalue, &color);
-       newstyle = gtk_style_copy(gtk_widget_get_default_style());
-       newstyle->bg[GTK_STATE_NORMAL]   = color;
-       newstyle->bg[GTK_STATE_PRELIGHT] = color;
-       newstyle->bg[GTK_STATE_ACTIVE]   = color;
-
-       gtk_widget_set_style(GTK_WIDGET(widget), newstyle);
-}
-
-static void prefs_enable_message_color_toggled(void)
-{
-       gboolean is_active;
-
-       is_active = gtk_toggle_button_get_active
-               (GTK_TOGGLE_BUTTON(message.chkbtn_enablecol));
-       gtk_widget_set_sensitive(message.button_edit_col, is_active);
-       prefs_common.enable_color = is_active;
-}
-
-static void prefs_recycle_colors_toggled(GtkWidget *widget)
-{
-       gboolean is_active;
-
-       is_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
-       prefs_common.recycle_quote_colors = is_active;
-}
-
 static void prefs_keybind_select(void)
 {
        GtkWidget *window;
diff --git a/src/prefs_msg_colors.c b/src/prefs_msg_colors.c
new file mode 100644 (file)
index 0000000..24fa999
--- /dev/null
@@ -0,0 +1,397 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2004 Hiroyuki Yamamoto & The Sylpheed-Claws 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
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "defs.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "intl.h"
+#include "prefs_common.h"
+#include "prefs_gtk.h"
+
+#include "gtk/gtkutils.h"
+#include "gtk/prefswindow.h"
+
+#include "manage_window.h"
+
+static struct MessageColorButtons {
+       GtkWidget *quote_level1_btn;
+       GtkWidget *quote_level2_btn;
+       GtkWidget *quote_level3_btn;
+       GtkWidget *uri_btn;
+       GtkWidget *tgt_folder_btn;
+       GtkWidget *signature_btn;
+} color_buttons;
+
+typedef struct _MsgColorsPage
+{
+       PrefsPage page;
+
+       GtkWidget *window;
+       
+       GtkWidget *chkbtn_enablecol;
+       GtkWidget *chkbtn_recycle_colors;
+} MsgColorsPage;
+
+static GtkWidget *color_dialog;
+
+static void prefs_quote_colors_key_pressed     (GtkWidget      *widget,
+                                                GdkEventKey    *event,
+                                                gpointer        data);
+static void quote_color_set_dialog             (GtkWidget      *widget,
+                                                gpointer        data);
+static void quote_colors_set_dialog_ok         (GtkWidget      *widget,
+                                                gpointer        data);
+static void quote_colors_set_dialog_cancel     (GtkWidget      *widget,
+                                                gpointer        data);
+static void quote_colors_set_dialog_key_pressed        (GtkWidget      *widget,
+                                                GdkEventKey    *event,
+                                                gpointer        data);
+static void set_button_bg_color                        (GtkWidget      *widget,
+                                                gint            color);
+
+void prefs_msg_colors_create_widget(PrefsPage *_page, GtkWindow *window, 
+                                   gpointer data)
+{
+       MsgColorsPage *prefs_msg_colors = (MsgColorsPage *) _page;
+       
+       GtkWidget *table;
+       GtkWidget *chkbtn_enablecol;
+       GtkWidget *quotelevel1_label;
+       GtkWidget *quotelevel2_label;
+       GtkWidget *quotelevel3_label;
+       GtkWidget *uri_label;
+       GtkWidget *signature_label;
+       GtkWidget *tgt_folder_label;
+       GtkWidget *chkbtn_recycle_colors;
+       GtkWidget *hbox;
+
+       table = gtk_table_new(8, 3, FALSE);
+       gtk_widget_show(table);
+       gtk_container_set_border_width(GTK_CONTAINER(table), 8);
+       gtk_table_set_row_spacings(GTK_TABLE(table), 4);
+       gtk_table_set_col_spacings(GTK_TABLE(table), 8);
+
+       chkbtn_enablecol = 
+               gtk_check_button_new_with_label(_("Enable coloration of message"));
+       gtk_table_attach (GTK_TABLE (table), chkbtn_enablecol, 0, 1, 1, 2,
+                         (GtkAttachOptions) (GTK_FILL),
+                         (GtkAttachOptions) (0), 0, 0);
+
+       hbox = gtk_hbox_new(FALSE, 8);
+       gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 2, 3,
+                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
+
+       color_buttons.quote_level1_btn = gtk_button_new();
+       gtk_widget_set_usize (color_buttons.quote_level1_btn, 30, 20);
+       gtk_box_pack_start (GTK_BOX(hbox), color_buttons.quote_level1_btn, 
+                           FALSE, FALSE, 0);
+
+       quotelevel1_label = gtk_label_new (_("Quoted Text - First Level"));
+       gtk_box_pack_start (GTK_BOX(hbox), quotelevel1_label, 
+                           FALSE, FALSE, 0);
+               
+       hbox = gtk_hbox_new(FALSE, 8);
+       gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 3, 4,
+                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
+
+       color_buttons.quote_level2_btn = gtk_button_new();
+       gtk_widget_set_usize (color_buttons.quote_level2_btn, 30, 20);
+       gtk_box_pack_start (GTK_BOX(hbox), color_buttons.quote_level2_btn, 
+                           FALSE, FALSE, 0);
+
+       quotelevel2_label = gtk_label_new (_("Quoted Text - Second Level"));
+       gtk_box_pack_start (GTK_BOX(hbox), quotelevel2_label, 
+                           FALSE, FALSE, 0);
+
+       hbox = gtk_hbox_new(FALSE, 8);
+       gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 4, 5,
+                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
+
+       color_buttons.quote_level3_btn = gtk_button_new_with_label ("");
+       gtk_widget_set_usize (color_buttons.quote_level3_btn, 30, 20);
+       gtk_box_pack_start (GTK_BOX(hbox), color_buttons.quote_level3_btn, 
+                           FALSE, FALSE, 0);
+
+       quotelevel3_label = gtk_label_new (_("Quoted Text - Third Level"));
+       gtk_box_pack_start (GTK_BOX(hbox), quotelevel3_label, 
+                           FALSE, FALSE, 0);
+
+       hbox = gtk_hbox_new(FALSE, 8);
+       gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 5, 6,
+                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
+
+       color_buttons.uri_btn = gtk_button_new_with_label ("");
+       gtk_widget_set_usize (color_buttons.uri_btn, 30, 20);
+       gtk_box_pack_start (GTK_BOX(hbox), color_buttons.uri_btn, 
+                           FALSE, FALSE, 0);
+
+       uri_label = gtk_label_new (_("URI link"));
+       gtk_box_pack_start (GTK_BOX(hbox), uri_label, FALSE, FALSE, 0);
+
+       hbox = gtk_hbox_new(FALSE, 8);
+       gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 6, 7,
+                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
+
+       color_buttons.tgt_folder_btn = gtk_button_new_with_label ("");
+       gtk_widget_set_usize (color_buttons.tgt_folder_btn, 30, 20);
+       gtk_box_pack_start (GTK_BOX(hbox), color_buttons.tgt_folder_btn, 
+                           FALSE, FALSE, 0);
+
+       tgt_folder_label = gtk_label_new (_("Target folder"));
+       gtk_box_pack_start (GTK_BOX(hbox), tgt_folder_label, FALSE, FALSE, 0);
+
+       hbox = gtk_hbox_new(FALSE, 8);
+       gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 7, 8,
+                         (GTK_EXPAND | GTK_FILL), 0, 0, 0);
+
+       color_buttons.signature_btn = gtk_button_new_with_label ("");
+       gtk_widget_set_usize (color_buttons.signature_btn, 30, 20);
+       gtk_box_pack_start (GTK_BOX(hbox), color_buttons.signature_btn, 
+                           FALSE, FALSE, 0);
+
+       signature_label = gtk_label_new (_("Signatures"));
+       gtk_box_pack_start (GTK_BOX(hbox), signature_label, FALSE, FALSE, 0);
+
+       chkbtn_recycle_colors = 
+               gtk_check_button_new_with_label(_("Recycle quote colors"));
+       gtk_table_attach (GTK_TABLE (table), chkbtn_recycle_colors, 0, 1, 8, 9,
+                         (GtkAttachOptions) (GTK_FILL),
+                         (GtkAttachOptions) (0), 0, 0);
+                         
+       gtk_widget_show_all(table);
+
+       gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level1_btn), "clicked",
+                          GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL1");
+       gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level2_btn), "clicked",
+                          GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL2");
+       gtk_signal_connect(GTK_OBJECT(color_buttons.quote_level3_btn), "clicked",
+                          GTK_SIGNAL_FUNC(quote_color_set_dialog), "LEVEL3");
+       gtk_signal_connect(GTK_OBJECT(color_buttons.uri_btn), "clicked",
+                          GTK_SIGNAL_FUNC(quote_color_set_dialog), "URI");
+       gtk_signal_connect(GTK_OBJECT(color_buttons.tgt_folder_btn), "clicked",
+                          GTK_SIGNAL_FUNC(quote_color_set_dialog), "TGTFLD");
+       gtk_signal_connect(GTK_OBJECT(color_buttons.signature_btn), "clicked",
+                          GTK_SIGNAL_FUNC(quote_color_set_dialog), "SIGNATURE");
+
+       set_button_bg_color(color_buttons.quote_level1_btn,
+                           prefs_common.quote_level1_col);
+       set_button_bg_color(color_buttons.quote_level2_btn,
+                           prefs_common.quote_level2_col);
+       set_button_bg_color(color_buttons.quote_level3_btn,
+                           prefs_common.quote_level3_col);
+       set_button_bg_color(color_buttons.uri_btn,
+                           prefs_common.uri_col);
+       set_button_bg_color(color_buttons.tgt_folder_btn,
+                           prefs_common.tgt_folder_col);
+       set_button_bg_color(color_buttons.signature_btn,
+                           prefs_common.signature_col);
+
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_enablecol),
+                                    prefs_common.enable_color);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbtn_recycle_colors),
+                                    prefs_common.recycle_quote_colors);
+
+       prefs_msg_colors->window                = GTK_WIDGET(window);
+       prefs_msg_colors->chkbtn_enablecol      = chkbtn_enablecol;
+       prefs_msg_colors->chkbtn_recycle_colors = chkbtn_recycle_colors;
+
+       prefs_msg_colors->page.widget = table;
+}
+
+static void prefs_quote_colors_key_pressed(GtkWidget *widget,
+                                          GdkEventKey *event, gpointer data)
+{
+       if (event && event->keyval == GDK_Escape)
+               gtk_main_quit();
+}
+
+static void quote_color_set_dialog(GtkWidget *widget, gpointer data)
+{
+       gchar *type = (gchar *)data;
+       gchar *title = NULL;
+       gdouble color[4] = {0.0, 0.0, 0.0, 0.0};
+       gint rgbvalue = 0;
+       GtkColorSelectionDialog *dialog;
+
+       if(g_strcasecmp(type, "LEVEL1") == 0) {
+               title = _("Pick color for quotation level 1");
+               rgbvalue = prefs_common.quote_level1_col;
+       } else if(g_strcasecmp(type, "LEVEL2") == 0) {
+               title = _("Pick color for quotation level 2");
+               rgbvalue = prefs_common.quote_level2_col;
+       } else if(g_strcasecmp(type, "LEVEL3") == 0) {
+               title = _("Pick color for quotation level 3");
+               rgbvalue = prefs_common.quote_level3_col;
+       } else if(g_strcasecmp(type, "URI") == 0) {
+               title = _("Pick color for URI");
+               rgbvalue = prefs_common.uri_col;
+       } else if(g_strcasecmp(type, "TGTFLD") == 0) {
+               title = _("Pick color for target folder");
+               rgbvalue = prefs_common.tgt_folder_col;
+       } else if(g_strcasecmp(type, "SIGNATURE") == 0) {
+               title = _("Pick color for signatures");
+               rgbvalue = prefs_common.signature_col;
+       } else {   /* Should never be called */
+               g_warning("Unrecognized datatype '%s' in quote_color_set_dialog\n", type);
+               return;
+       }
+
+       color_dialog = gtk_color_selection_dialog_new(title);
+       gtk_window_set_position(GTK_WINDOW(color_dialog), GTK_WIN_POS_CENTER);
+       gtk_window_set_modal(GTK_WINDOW(color_dialog), TRUE);
+       gtk_window_set_policy(GTK_WINDOW(color_dialog), FALSE, FALSE, FALSE);
+       manage_window_set_transient(GTK_WINDOW(color_dialog));
+
+       gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->ok_button),
+                          "clicked", GTK_SIGNAL_FUNC(quote_colors_set_dialog_ok), data);
+       gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(color_dialog)->cancel_button),
+                          "clicked", GTK_SIGNAL_FUNC(quote_colors_set_dialog_cancel), data);
+       gtk_signal_connect(GTK_OBJECT(color_dialog), "key_press_event",
+                          GTK_SIGNAL_FUNC(quote_colors_set_dialog_key_pressed),
+                          data);
+
+       /* preselect the previous color in the color selection dialog */
+       color[0] = (gdouble) ((rgbvalue & 0xff0000) >> 16) / 255.0;
+       color[1] = (gdouble) ((rgbvalue & 0x00ff00) >>  8) / 255.0;
+       color[2] = (gdouble)  (rgbvalue & 0x0000ff)        / 255.0;
+       dialog = GTK_COLOR_SELECTION_DIALOG(color_dialog);
+       gtk_color_selection_set_color
+               (GTK_COLOR_SELECTION(dialog->colorsel), color);
+
+       gtk_widget_show(color_dialog);
+}
+
+static void quote_colors_set_dialog_ok(GtkWidget *widget, gpointer data)
+{
+       GtkColorSelection *colorsel = (GtkColorSelection *)
+                                               ((GtkColorSelectionDialog *)color_dialog)->colorsel;
+       gdouble color[4];
+       gint red, green, blue, rgbvalue;
+       gchar *type = (gchar *)data;
+
+       gtk_color_selection_get_color(colorsel, color);
+
+       red      = (gint) (color[0] * 255.0);
+       green    = (gint) (color[1] * 255.0);
+       blue     = (gint) (color[2] * 255.0);
+       rgbvalue = (gint) ((red * 0x10000) | (green * 0x100) | blue);
+
+#if 0
+       fprintf(stderr, "redc = %f, greenc = %f, bluec = %f\n", color[0], color[1], color[2]);
+       fprintf(stderr, "red = %d, green = %d, blue = %d\n", red, green, blue);
+       fprintf(stderr, "Color is %x\n", rgbvalue);
+#endif
+
+       if (g_strcasecmp(type, "LEVEL1") == 0) {
+               prefs_common.quote_level1_col = rgbvalue;
+               set_button_bg_color(color_buttons.quote_level1_btn, rgbvalue);
+       } else if (g_strcasecmp(type, "LEVEL2") == 0) {
+               prefs_common.quote_level2_col = rgbvalue;
+               set_button_bg_color(color_buttons.quote_level2_btn, rgbvalue);
+       } else if (g_strcasecmp(type, "LEVEL3") == 0) {
+               prefs_common.quote_level3_col = rgbvalue;
+               set_button_bg_color(color_buttons.quote_level3_btn, rgbvalue);
+       } else if (g_strcasecmp(type, "URI") == 0) {
+               prefs_common.uri_col = rgbvalue;
+               set_button_bg_color(color_buttons.uri_btn, rgbvalue);
+       } else if (g_strcasecmp(type, "TGTFLD") == 0) {
+               prefs_common.tgt_folder_col = rgbvalue;
+               set_button_bg_color(color_buttons.tgt_folder_btn, rgbvalue);
+               folderview_set_target_folder_color(prefs_common.tgt_folder_col);
+       } else if (g_strcasecmp(type, "SIGNATURE") == 0) {
+               prefs_common.signature_col = rgbvalue;
+               set_button_bg_color(color_buttons.signature_btn, rgbvalue);
+       } else
+               fprintf( stderr, "Unrecognized datatype '%s' in quote_color_set_dialog_ok\n", type );
+
+       gtk_widget_destroy(color_dialog);
+}
+
+static void quote_colors_set_dialog_cancel(GtkWidget *widget, gpointer data)
+{
+       gtk_widget_destroy(color_dialog);
+}
+
+static void quote_colors_set_dialog_key_pressed(GtkWidget *widget,
+                                               GdkEventKey *event,
+                                               gpointer data)
+{
+       gtk_widget_destroy(color_dialog);
+}
+
+static void set_button_bg_color(GtkWidget *widget, gint rgbvalue)
+{
+       GtkStyle *newstyle;
+       GdkColor color;
+
+       gtkut_convert_int_to_gdk_color(rgbvalue, &color);
+       newstyle = gtk_style_copy(gtk_widget_get_default_style());
+       newstyle->bg[GTK_STATE_NORMAL]   = color;
+       newstyle->bg[GTK_STATE_PRELIGHT] = color;
+       newstyle->bg[GTK_STATE_ACTIVE]   = color;
+
+       gtk_widget_set_style(GTK_WIDGET(widget), newstyle);
+}
+
+void prefs_msg_colors_save(PrefsPage *_page)
+{
+       MsgColorsPage *page = (MsgColorsPage *) _page;
+
+       prefs_common.enable_color = 
+               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->chkbtn_enablecol));
+       prefs_common.recycle_quote_colors =
+               gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->chkbtn_recycle_colors));
+}
+
+static void prefs_msg_colors_destroy_widget(PrefsPage *_page)
+{
+}
+
+MsgColorsPage *prefs_msg_colors;
+
+void prefs_msg_colors_init(void)
+{
+       MsgColorsPage *page;
+
+       page = g_new0(MsgColorsPage, 1);
+       page->page.path = _("Message View/Colors");
+       page->page.create_widget = prefs_msg_colors_create_widget;
+       page->page.destroy_widget = prefs_msg_colors_destroy_widget;
+       page->page.save_page = prefs_msg_colors_save;
+       page->page.weight = 60.0;
+       prefs_gtk_register_page((PrefsPage *) page);
+       prefs_msg_colors = page;
+}
+
+void prefs_msg_colors_done(void)
+{
+       prefs_gtk_unregister_page((PrefsPage *) prefs_msg_colors);
+       g_free(prefs_msg_colors);
+}
+
diff --git a/src/prefs_msg_colors.h b/src/prefs_msg_colors.h
new file mode 100644 (file)
index 0000000..7658bb9
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2004 Hiroyuki Yamamoto & the Sylpheed-Claws 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
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef PREFS_MSG_COLORS_H
+#define PREFS_MSG_COLORS_H
+
+void prefs_msg_colors_init     (void);
+void prefs_msg_colors_done     (void);
+
+#endif /* PREFS_MSG_COLORS_H */