diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2010-01-05 08:17:26 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2010-01-05 08:17:26 +0000 |
commit | 217043f00e1b30d747a8a2e734c3a76ced282944 (patch) | |
tree | e282a3e7d9715fa29f4a78610a85d34f266a184d /src/prefs_common_dialog.c | |
parent | 7da33f3827d55c778bf39b3e3992dfe422d4798c (diff) |
implemented the UI for customizing color label text.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2410 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/prefs_common_dialog.c')
-rw-r--r-- | src/prefs_common_dialog.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/prefs_common_dialog.c b/src/prefs_common_dialog.c index 507a3fe3..031aeb96 100644 --- a/src/prefs_common_dialog.c +++ b/src/prefs_common_dialog.c @@ -49,6 +49,7 @@ #include "foldersel.h" #include "inc.h" #include "menu.h" +#include "colorlabel.h" #include "codeconv.h" #include "utils.h" #include "gtkutils.h" @@ -164,6 +165,10 @@ static struct Message { GtkWidget *chkbtn_inline_image; } message; +static struct ColorLabel { + GtkWidget *entry_color[7]; +} colorlabel; + static struct JunkMail { GtkWidget *chkbtn_enable_junk; GtkWidget *entry_junk_learncmd; @@ -588,6 +593,11 @@ static GtkWidget *prefs_spell_create (void); #endif static void prefs_display_create (void); static GtkWidget *prefs_message_create (void); + +static GtkWidget *prefs_colorlabel_create (void); +static void prefs_common_colorlabel_set_dialog (void); +static void prefs_common_colorlabel_update (void); + static void prefs_junk_create (void); #if USE_GPGME static void prefs_privacy_create (void); @@ -703,6 +713,7 @@ void prefs_common_open(void) gtk_widget_grab_focus(dialog.ok_btn); prefs_set_dialog(prefs_common_get_params()); + prefs_common_colorlabel_set_dialog(); gtk_widget_show(dialog.window); } @@ -1485,6 +1496,7 @@ static void prefs_display_create(void) GtkWidget *button_dispitem; GtkWidget *msg_wid; + GtkWidget *clabel_wid; GtkWidget *label_dispencoding; GtkWidget *optmenu_dispencoding; @@ -1628,6 +1640,10 @@ static void prefs_display_create(void) msg_wid = prefs_message_create(); gtk_box_pack_start(GTK_BOX(vbox_tab), msg_wid, FALSE, FALSE, 0); + APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Color label")); + clabel_wid = prefs_colorlabel_create(); + gtk_box_pack_start(GTK_BOX(vbox_tab), clabel_wid, FALSE, FALSE, 0); + APPEND_SUB_NOTEBOOK(notebook, vbox_tab, _("Encoding")); hbox1 = gtk_hbox_new (FALSE, 8); @@ -1881,6 +1897,71 @@ static GtkWidget *prefs_message_create(void) return vbox1; } +static GtkWidget *prefs_colorlabel_create(void) +{ + GtkWidget *vbox; + GtkWidget *table; + GtkWidget *clabel; + GtkWidget *entry; + gint i; + + vbox = gtk_vbox_new(FALSE, VSPACING); + gtk_widget_show(vbox); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 8); + + table = gtk_table_new(7, 2, FALSE); + gtk_widget_show(table); + gtk_container_add(GTK_CONTAINER(vbox), table); + gtk_table_set_row_spacings(GTK_TABLE(table), VSPACING_NARROW); + gtk_table_set_col_spacings(GTK_TABLE(table), 8); + + for (i = 0; i < 7; i++) { + clabel = colorlabel_create_color_widget + (colorlabel_get_color(i)); + gtk_widget_show(clabel); + gtk_table_attach(GTK_TABLE(table), clabel, 0, 1, i, i + 1, + GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 6); + entry = gtk_entry_new(); + gtk_widget_show(entry); + gtk_table_attach(GTK_TABLE(table), entry, 1, 2, i, i + 1, + GTK_EXPAND | GTK_FILL, 0, 0, 0); + colorlabel.entry_color[i] = entry; + } + + return vbox; +} + +static void prefs_common_colorlabel_set_dialog(void) +{ + gint i; + const gchar *text; + + for (i = 0; i < 7; i++) { + if ((text = colorlabel_get_custom_color_text(i))) { + gtk_entry_set_text(GTK_ENTRY(colorlabel.entry_color[i]), + text); + } else { + gtk_entry_set_text(GTK_ENTRY(colorlabel.entry_color[i]), + ""); + } + } +} + +static void prefs_common_colorlabel_update(void) +{ + gint i; + const gchar *text; + + for (i = 0; i < 7; i++) { + text = gtk_entry_get_text(GTK_ENTRY(colorlabel.entry_color[i])); + if (text && text[0] != '\0') + colorlabel_set_color_text(i, text); + else + colorlabel_set_color_text(i, NULL); + } + colorlabel_update_menu(); +} + static const struct { gchar *junk_cmd; gchar *nojunk_cmd; @@ -4104,6 +4185,8 @@ static void prefs_common_apply(void) gtkut_stock_button_set_set_reverse(!prefs_common.comply_gnome_hig); main_window_reflect_prefs_all(); compose_reflect_prefs_all(); + prefs_common_colorlabel_update(); + colorlabel_write_config(); sock_set_io_timeout(prefs_common.io_timeout_secs); prefs_common_write_config(); |