diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | ChangeLog.ja | 7 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/compose.c | 1 | ||||
-rw-r--r-- | src/filter.c | 1 | ||||
-rw-r--r-- | src/prefs.c | 413 | ||||
-rw-r--r-- | src/prefs.h | 118 | ||||
-rw-r--r-- | src/prefs_account.c | 145 | ||||
-rw-r--r-- | src/prefs_common.c | 171 | ||||
-rw-r--r-- | src/prefs_customheader.c | 1 | ||||
-rw-r--r-- | src/prefs_display_header.c | 1 | ||||
-rw-r--r-- | src/prefs_filter.c | 1 | ||||
-rw-r--r-- | src/prefs_filter.h | 4 | ||||
-rw-r--r-- | src/prefs_folder_item.c | 1 | ||||
-rw-r--r-- | src/prefs_summary_column.c | 1 | ||||
-rw-r--r-- | src/prefs_ui.c | 452 | ||||
-rw-r--r-- | src/prefs_ui.h | 144 | ||||
-rw-r--r-- | src/summaryview.c | 2 |
18 files changed, 791 insertions, 680 deletions
@@ -1,5 +1,12 @@ 2005-08-30 + * src/prefs.[ch] + src/prefs_ui.[ch]: separated UI code from prefs.[ch]. + * src/prefs_common.c + src/prefs_account.c: added casts for (GtkWidget **). + +2005-08-30 + * src/main.c: code cleanup. 2005-08-29 diff --git a/ChangeLog.ja b/ChangeLog.ja index ada4bb1d..01659a92 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,5 +1,12 @@ 2005-08-30 + * src/prefs.[ch] + src/prefs_ui.[ch]: prefs.[ch] から UI コードを分離。 + * src/prefs_common.c + src/prefs_account.c: (GtkWidget **) にキャストを追加。 + +2005-08-30 + * src/main.c: コードの整理。 2005-08-29 diff --git a/src/Makefile.am b/src/Makefile.am index 3fc61508..5da41db1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,6 +27,7 @@ sylpheed_SOURCES = \ menu.c menu.h \ stock_pixmap.c stock_pixmap.h \ prefs.c prefs.h \ + prefs_ui.c prefs_ui.h \ prefs_common.c prefs_common.h \ prefs_filter.c prefs_filter.h \ prefs_filter_edit.c prefs_filter_edit.h \ diff --git a/src/compose.c b/src/compose.c index ef98bbff..a2e8e2ff 100644 --- a/src/compose.c +++ b/src/compose.c @@ -52,6 +52,7 @@ #include <gtk/gtktable.h> #include <gtk/gtkhbox.h> #include <gtk/gtklabel.h> +#include <gtk/gtkcheckbutton.h> #include <gtk/gtkscrolledwindow.h> #include <gtk/gtktreeview.h> #include <gtk/gtkdnd.h> diff --git a/src/filter.c b/src/filter.c index 26c77c91..b4a26ee0 100644 --- a/src/filter.c +++ b/src/filter.c @@ -41,6 +41,7 @@ #include "xml.h" #include "prefs.h" #include "prefs_account.h" +#include "account.h" typedef enum { diff --git a/src/prefs.c b/src/prefs.c index 444d3ae8..4579df4f 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -23,18 +23,15 @@ #include <glib.h> #include <glib/gi18n.h> -#include <gtk/gtk.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> -#include "main.h" #include "prefs.h" #include "codeconv.h" #include "utils.h" -#include "gtkutils.h" typedef enum { @@ -466,413 +463,3 @@ void prefs_free(PrefParam *param) } } } - -void prefs_dialog_create(PrefsDialog *dialog) -{ - GtkWidget *window; - GtkWidget *vbox; - GtkWidget *notebook; - - GtkWidget *confirm_area; - GtkWidget *ok_btn; - GtkWidget *cancel_btn; - GtkWidget *apply_btn; - - g_return_if_fail(dialog != NULL); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_container_set_border_width (GTK_CONTAINER (window), 8); - 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, TRUE, FALSE); - - vbox = gtk_vbox_new (FALSE, 6); - gtk_widget_show(vbox); - gtk_container_add (GTK_CONTAINER (window), vbox); - - notebook = gtk_notebook_new (); - gtk_widget_show(notebook); - gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (notebook), 2); - /* GTK_WIDGET_UNSET_FLAGS (notebook, GTK_CAN_FOCUS); */ - gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE); - - gtkut_stock_button_set_create(&confirm_area, - &ok_btn, GTK_STOCK_OK, - &cancel_btn, GTK_STOCK_CANCEL, - &apply_btn, GTK_STOCK_APPLY); - gtk_widget_show(confirm_area); - gtk_box_pack_end (GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0); - gtk_widget_grab_default(ok_btn); - - dialog->window = window; - dialog->notebook = notebook; - dialog->confirm_area = confirm_area; - dialog->ok_btn = ok_btn; - dialog->cancel_btn = cancel_btn; - dialog->apply_btn = apply_btn; -} - -void prefs_dialog_destroy(PrefsDialog *dialog) -{ - gtk_widget_destroy(dialog->window); - dialog->window = NULL; - dialog->notebook = NULL; - dialog->ok_btn = NULL; - dialog->cancel_btn = NULL; - dialog->apply_btn = NULL; -} - -void prefs_button_toggled(GtkToggleButton *toggle_btn, GtkWidget *widget) -{ - gboolean is_active; - - is_active = gtk_toggle_button_get_active(toggle_btn); - gtk_widget_set_sensitive(widget, is_active); -} - -void prefs_set_dialog(PrefParam *param) -{ - gint i; - - for (i = 0; param[i].name != NULL; i++) { - if (param[i].widget_set_func) - param[i].widget_set_func(¶m[i]); - } -} - -void prefs_set_data_from_dialog(PrefParam *param) -{ - gint i; - - for (i = 0; param[i].name != NULL; i++) { - if (param[i].data_set_func) - param[i].data_set_func(¶m[i]); - } -} - -void prefs_set_dialog_to_default(PrefParam *param) -{ - gint i; - PrefParam tmpparam; - gchar *str_data = NULL; - gint int_data; - gushort ushort_data; - gboolean bool_data; - DummyEnum enum_data; - - for (i = 0; param[i].name != NULL; i++) { - if (!param[i].widget_set_func) continue; - - tmpparam = param[i]; - - switch (tmpparam.type) { - case P_STRING: - if (tmpparam.defval) { - if (!g_ascii_strncasecmp - (tmpparam.defval, "ENV_", 4)) { - str_data = g_strdup - (g_getenv(param[i].defval + 4)); - tmpparam.data = &str_data; - break; - } else if (tmpparam.defval[0] == '~') { - str_data = - g_strconcat(get_home_dir(), - param[i].defval + 1, - NULL); - tmpparam.data = &str_data; - break; - } - } - tmpparam.data = &tmpparam.defval; - break; - case P_INT: - if (tmpparam.defval) - int_data = atoi(tmpparam.defval); - else - int_data = 0; - tmpparam.data = &int_data; - break; - case P_USHORT: - if (tmpparam.defval) - ushort_data = atoi(tmpparam.defval); - else - ushort_data = 0; - tmpparam.data = &ushort_data; - break; - case P_BOOL: - if (tmpparam.defval) { - if (!g_ascii_strcasecmp(tmpparam.defval, "TRUE")) - bool_data = TRUE; - else - bool_data = atoi(tmpparam.defval) - ? TRUE : FALSE; - } else - bool_data = FALSE; - tmpparam.data = &bool_data; - break; - case P_ENUM: - if (tmpparam.defval) - enum_data = (DummyEnum)atoi(tmpparam.defval); - else - enum_data = 0; - tmpparam.data = &enum_data; - break; - case P_OTHER: - break; - } - tmpparam.widget_set_func(&tmpparam); - g_free(str_data); - str_data = NULL; - } -} - -void prefs_set_data_from_entry(PrefParam *pparam) -{ - gchar **str; - const gchar *entry_str; - - g_return_if_fail(*pparam->widget != NULL); - - entry_str = gtk_entry_get_text(GTK_ENTRY(*pparam->widget)); - - switch (pparam->type) { - case P_STRING: - str = (gchar **)pparam->data; - g_free(*str); - *str = entry_str[0] ? g_strdup(entry_str) : NULL; - break; - case P_USHORT: - *((gushort *)pparam->data) = atoi(entry_str); - break; - case P_INT: - *((gint *)pparam->data) = atoi(entry_str); - break; - default: - g_warning("Invalid PrefType for GtkEntry widget: %d\n", - pparam->type); - } -} - -void prefs_set_entry(PrefParam *pparam) -{ - gchar **str; - - g_return_if_fail(*pparam->widget != NULL); - - switch (pparam->type) { - case P_STRING: - str = (gchar **)pparam->data; - gtk_entry_set_text(GTK_ENTRY(*pparam->widget), - *str ? *str : ""); - break; - case P_INT: - gtk_entry_set_text(GTK_ENTRY(*pparam->widget), - itos(*((gint *)pparam->data))); - break; - case P_USHORT: - gtk_entry_set_text(GTK_ENTRY(*pparam->widget), - itos(*((gushort *)pparam->data))); - break; - default: - g_warning("Invalid PrefType for GtkEntry widget: %d\n", - pparam->type); - } -} - -void prefs_set_data_from_text(PrefParam *pparam) -{ - gchar **str; - gchar *text = NULL, *tp = NULL; - gchar *tmp, *tmpp; - - g_return_if_fail(*pparam->widget != NULL); - g_return_if_fail(GTK_IS_EDITABLE(*pparam->widget) || - GTK_IS_TEXT_VIEW(*pparam->widget)); - - switch (pparam->type) { - case P_STRING: - str = (gchar **)pparam->data; - g_free(*str); - if (GTK_IS_EDITABLE(*pparam->widget)) { - tp = text = gtk_editable_get_chars - (GTK_EDITABLE(*pparam->widget), 0, -1); - } else if (GTK_IS_TEXT_VIEW(*pparam->widget)) { - GtkTextView *textview = GTK_TEXT_VIEW(*pparam->widget); - GtkTextBuffer *buffer; - GtkTextIter start, end; - - buffer = gtk_text_view_get_buffer(textview); - gtk_text_buffer_get_start_iter(buffer, &start); - gtk_text_buffer_get_iter_at_offset(buffer, &end, -1); - tp = text = gtk_text_buffer_get_text - (buffer, &start, &end, FALSE); - } - - g_return_if_fail(tp != NULL && text != NULL); - - if (text[0] == '\0') { - *str = NULL; - g_free(text); - break; - } - - Xalloca(tmpp = tmp, strlen(text) * 2 + 1, - { *str = NULL; break; }); - while (*tp) { - if (*tp == '\n') { - *tmpp++ = '\\'; - *tmpp++ = 'n'; - tp++; - } else - *tmpp++ = *tp++; - } - *tmpp = '\0'; - *str = g_strdup(tmp); - g_free(text); - break; - default: - g_warning("Invalid PrefType for GtkTextView widget: %d\n", - pparam->type); - } -} - -void prefs_set_text(PrefParam *pparam) -{ - gchar *buf, *sp, *bufp; - gchar **str; - GtkTextView *text; - GtkTextBuffer *buffer; - GtkTextIter iter; - - g_return_if_fail(*pparam->widget != NULL); - - switch (pparam->type) { - case P_STRING: - str = (gchar **)pparam->data; - if (*str) { - bufp = buf = alloca(strlen(*str) + 1); - if (!buf) buf = ""; - else { - sp = *str; - while (*sp) { - if (*sp == '\\' && *(sp + 1) == 'n') { - *bufp++ = '\n'; - sp += 2; - } else - *bufp++ = *sp++; - } - *bufp = '\0'; - } - } else - buf = ""; - - text = GTK_TEXT_VIEW(*pparam->widget); - buffer = gtk_text_view_get_buffer(text); - gtk_text_buffer_set_text(buffer, "", 0); - gtk_text_buffer_get_start_iter(buffer, &iter); - gtk_text_buffer_insert(buffer, &iter, buf, -1); - break; - default: - g_warning("Invalid PrefType for GtkTextView widget: %d\n", - pparam->type); - } -} - -void prefs_set_data_from_toggle(PrefParam *pparam) -{ - g_return_if_fail(pparam->type == P_BOOL); - g_return_if_fail(*pparam->widget != NULL); - - *((gboolean *)pparam->data) = - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(*pparam->widget)); -} - -void prefs_set_toggle(PrefParam *pparam) -{ - g_return_if_fail(pparam->type == P_BOOL); - g_return_if_fail(*pparam->widget != NULL); - - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(*pparam->widget), - *((gboolean *)pparam->data)); -} - -void prefs_set_data_from_spinbtn(PrefParam *pparam) -{ - g_return_if_fail(*pparam->widget != NULL); - - switch (pparam->type) { - case P_INT: - *((gint *)pparam->data) = - gtk_spin_button_get_value_as_int - (GTK_SPIN_BUTTON(*pparam->widget)); - break; - case P_USHORT: - *((gushort *)pparam->data) = - (gushort)gtk_spin_button_get_value_as_int - (GTK_SPIN_BUTTON(*pparam->widget)); - break; - default: - g_warning("Invalid PrefType for GtkSpinButton widget: %d\n", - pparam->type); - } -} - -void prefs_set_spinbtn(PrefParam *pparam) -{ - g_return_if_fail(*pparam->widget != NULL); - - switch (pparam->type) { - case P_INT: - gtk_spin_button_set_value(GTK_SPIN_BUTTON(*pparam->widget), - (gfloat)*((gint *)pparam->data)); - break; - case P_USHORT: - gtk_spin_button_set_value(GTK_SPIN_BUTTON(*pparam->widget), - (gfloat)*((gushort *)pparam->data)); - break; - default: - g_warning("Invalid PrefType for GtkSpinButton widget: %d\n", - pparam->type); - } -} - -void prefs_set_data_from_fontbtn(PrefParam *pparam) -{ - gchar **str; - const gchar *font_str; - - g_return_if_fail(*pparam->widget != NULL); - - font_str = gtk_font_button_get_font_name - (GTK_FONT_BUTTON(*pparam->widget)); - - switch (pparam->type) { - case P_STRING: - str = (gchar **)pparam->data; - g_free(*str); - *str = font_str[0] ? g_strdup(font_str) : NULL; - break; - default: - g_warning("Invalid PrefType for GtkFontButton widget: %d\n", - pparam->type); - } -} - -void prefs_set_fontbtn(PrefParam *pparam) -{ - gchar **str; - - g_return_if_fail(*pparam->widget != NULL); - - switch (pparam->type) { - case P_STRING: - str = (gchar **)pparam->data; - gtk_font_button_set_font_name(GTK_FONT_BUTTON(*pparam->widget), - *str ? *str : ""); - break; - default: - g_warning("Invalid PrefType for GtkFontButton widget: %d\n", - pparam->type); - } -} diff --git a/src/prefs.h b/src/prefs.h index b81bea68..f062d1eb 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -21,27 +21,15 @@ #define __PREFS_H__ #include <glib.h> -#include <gtk/gtkwidget.h> -#include <gtk/gtksignal.h> -#include <gtk/gtklabel.h> -#include <gtk/gtknotebook.h> -#include <gtk/gtkcheckbutton.h> -#include <gtk/gtkbox.h> #include <stdio.h> typedef struct _PrefParam PrefParam; typedef struct _PrefFile PrefFile; -typedef struct _PrefsDialog PrefsDialog; -#include "account.h" - -#define VSPACING 10 -#define VSPACING_NARROW 4 -#define VSPACING_NARROW_2 2 -#define VBOX_BORDER 16 -#define DEFAULT_ENTRY_WIDTH 80 #define PREFSBUFSIZE 1024 +#define P_WID(wid) ((gpointer *)(wid)) + typedef enum { P_STRING, @@ -60,7 +48,7 @@ struct _PrefParam { gchar *defval; gpointer data; PrefType type; - GtkWidget **widget; + gpointer *widget; DataSetFunc data_set_func; WidgetSetFunc widget_set_func; }; @@ -70,85 +58,6 @@ struct _PrefFile { gchar *path; }; -struct _PrefsDialog -{ - GtkWidget *window; - GtkWidget *notebook; - - GtkWidget *confirm_area; - GtkWidget *ok_btn; - GtkWidget *cancel_btn; - GtkWidget *apply_btn; -}; - -#define SET_NOTEBOOK_LABEL(notebook, str, page_num) \ -{ \ - GtkWidget *label; \ - \ - label = gtk_label_new (str); \ - gtk_widget_show (label); \ - gtk_notebook_set_tab_label \ - (GTK_NOTEBOOK (notebook), \ - gtk_notebook_get_nth_page \ - (GTK_NOTEBOOK (notebook), page_num), \ - label); \ -} - -#define PACK_CHECK_BUTTON(box, chkbtn, label) \ -{ \ - chkbtn = gtk_check_button_new_with_label(label); \ - gtk_widget_show(chkbtn); \ - gtk_box_pack_start(GTK_BOX(box), chkbtn, FALSE, TRUE, 0); \ -} - -#define PACK_END_CHECK_BUTTON(box, chkbtn, label) \ -{ \ - chkbtn = gtk_check_button_new_with_label(label); \ - gtk_widget_show(chkbtn); \ - gtk_box_pack_end(GTK_BOX(box), chkbtn, FALSE, TRUE, 0); \ -} - -#define PACK_FRAME(box, frame, label) \ -{ \ - frame = gtk_frame_new(label); \ - gtk_widget_show(frame); \ - gtk_box_pack_start(GTK_BOX(box), frame, FALSE, TRUE, 0); \ - gtk_frame_set_label_align(GTK_FRAME(frame), 0.01, 0.5); \ -} - -#define PACK_FRAME_WITH_CHECK_BUTTON(box, frame, chkbtn, label) \ -{ \ - chkbtn = gtk_check_button_new_with_label(label); \ - gtk_widget_show(chkbtn); \ - PACK_FRAME(box, frame, NULL); \ - gtk_frame_set_label_widget(GTK_FRAME(frame), chkbtn); \ -} - -#define PACK_SMALL_LABEL(box, label, str) \ -{ \ - label = gtk_label_new(str); \ - gtk_widget_show(label); \ - gtk_box_pack_start(GTK_BOX(box), label, FALSE, TRUE, 0); \ - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); \ - gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); \ - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); \ - gtkut_widget_set_small_font_size(label); \ -} - -#define PACK_VSPACER(box, vbox, spacing) \ -{ \ - vbox = gtk_vbox_new(FALSE, 0); \ - gtk_widget_show(vbox); \ - gtk_box_pack_start(GTK_BOX(box), vbox, FALSE, TRUE, spacing); \ -} - -#define SET_TOGGLE_SENSITIVITY(togglewid, targetwid) \ -{ \ - gtk_widget_set_sensitive(targetwid, FALSE); \ - g_signal_connect(G_OBJECT(togglewid), "toggled", \ - G_CALLBACK(prefs_button_toggled), targetwid); \ -} - void prefs_read_config (PrefParam *param, const gchar *label, const gchar *rcfile, @@ -168,25 +77,4 @@ gint prefs_file_close_revert (PrefFile *pfile); void prefs_set_default (PrefParam *param); void prefs_free (PrefParam *param); -void prefs_dialog_create (PrefsDialog *dialog); -void prefs_dialog_destroy (PrefsDialog *dialog); - -void prefs_button_toggled (GtkToggleButton *toggle_btn, - GtkWidget *widget); - -void prefs_set_dialog (PrefParam *param); -void prefs_set_data_from_dialog (PrefParam *param); -void prefs_set_dialog_to_default(PrefParam *param); - -void prefs_set_data_from_entry (PrefParam *pparam); -void prefs_set_entry (PrefParam *pparam); -void prefs_set_data_from_text (PrefParam *pparam); -void prefs_set_text (PrefParam *pparam); -void prefs_set_data_from_toggle (PrefParam *pparam); -void prefs_set_toggle (PrefParam *pparam); -void prefs_set_data_from_spinbtn(PrefParam *pparam); -void prefs_set_spinbtn (PrefParam *pparam); -void prefs_set_data_from_fontbtn(PrefParam *pparam); -void prefs_set_fontbtn (PrefParam *pparam); - #endif /* __PREFS_H__ */ diff --git a/src/prefs_account.c b/src/prefs_account.c index c7d51473..8cd55299 100644 --- a/src/prefs_account.c +++ b/src/prefs_account.c @@ -36,6 +36,7 @@ #include "main.h" #include "prefs.h" +#include "prefs_ui.h" #include "prefs_account.h" #include "prefs_customheader.h" #include "prefs_common.h" @@ -215,270 +216,278 @@ static void prefs_account_ascii_armored_warning (GtkWidget *widget); static PrefParam param[] = { /* Basic */ {"account_name", NULL, &tmp_ac_prefs.account_name, P_STRING, - &basic.acname_entry, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&basic.acname_entry), + prefs_set_data_from_entry, prefs_set_entry}, {"is_default", "FALSE", &tmp_ac_prefs.is_default, P_BOOL, - &basic.default_chkbtn, + P_WID(&basic.default_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"name", NULL, &tmp_ac_prefs.name, P_STRING, - &basic.name_entry, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&basic.name_entry), prefs_set_data_from_entry, prefs_set_entry}, {"address", NULL, &tmp_ac_prefs.address, P_STRING, - &basic.addr_entry, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&basic.addr_entry), prefs_set_data_from_entry, prefs_set_entry}, {"organization", NULL, &tmp_ac_prefs.organization, P_STRING, - &basic.org_entry, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&basic.org_entry), prefs_set_data_from_entry, prefs_set_entry}, {"protocol", NULL, &tmp_ac_prefs.protocol, P_ENUM, - &basic.protocol_optmenu, + P_WID(&basic.protocol_optmenu), prefs_account_protocol_set_data_from_optmenu, prefs_account_protocol_set_optmenu}, {"receive_server", NULL, &tmp_ac_prefs.recv_server, P_STRING, - &basic.recvserv_entry, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&basic.recvserv_entry), + prefs_set_data_from_entry, prefs_set_entry}, {"smtp_server", NULL, &tmp_ac_prefs.smtp_server, P_STRING, - &basic.smtpserv_entry, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&basic.smtpserv_entry), + prefs_set_data_from_entry, prefs_set_entry}, {"nntp_server", NULL, &tmp_ac_prefs.nntp_server, P_STRING, - &basic.nntpserv_entry, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&basic.nntpserv_entry), + prefs_set_data_from_entry, prefs_set_entry}, {"use_nntp_auth", "FALSE", &tmp_ac_prefs.use_nntp_auth, P_BOOL, - &basic.nntpauth_chkbtn, + P_WID(&basic.nntpauth_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"user_id", "ENV_USER", &tmp_ac_prefs.userid, P_STRING, - &basic.uid_entry, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&basic.uid_entry), prefs_set_data_from_entry, prefs_set_entry}, {"password", NULL, &tmp_ac_prefs.passwd, P_STRING, - &basic.pass_entry, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&basic.pass_entry), prefs_set_data_from_entry, prefs_set_entry}, {"inbox", "inbox", &tmp_ac_prefs.inbox, P_STRING, - &receive.inbox_entry, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&receive.inbox_entry), + prefs_set_data_from_entry, prefs_set_entry}, /* Receive */ {"use_apop_auth", "FALSE", &tmp_ac_prefs.use_apop_auth, P_BOOL, - &receive.use_apop_chkbtn, + P_WID(&receive.use_apop_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"remove_mail", "TRUE", &tmp_ac_prefs.rmmail, P_BOOL, - &receive.rmmail_chkbtn, + P_WID(&receive.rmmail_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"message_leave_time", "0", &tmp_ac_prefs.msg_leave_time, P_INT, - &receive.leave_time_entry, + P_WID(&receive.leave_time_entry), prefs_set_data_from_entry, prefs_set_entry}, {"get_all_mail", "FALSE", &tmp_ac_prefs.getall, P_BOOL, - &receive.getall_chkbtn, + P_WID(&receive.getall_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"enable_size_limit", "FALSE", &tmp_ac_prefs.enable_size_limit, P_BOOL, - &receive.size_limit_chkbtn, + P_WID(&receive.size_limit_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"size_limit", "1024", &tmp_ac_prefs.size_limit, P_INT, - &receive.size_limit_entry, + P_WID(&receive.size_limit_entry), prefs_set_data_from_entry, prefs_set_entry}, {"filter_on_receive", "TRUE", &tmp_ac_prefs.filter_on_recv, P_BOOL, - &receive.filter_on_recv_chkbtn, + P_WID(&receive.filter_on_recv_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"imap_auth_method", "0", &tmp_ac_prefs.imap_auth_type, P_ENUM, - &receive.imap_auth_type_optmenu, + P_WID(&receive.imap_auth_type_optmenu), prefs_account_imap_auth_type_set_data_from_optmenu, prefs_account_imap_auth_type_set_optmenu}, {"max_nntp_articles", "300", &tmp_ac_prefs.max_nntp_articles, P_INT, - &receive.maxarticle_spinbtn, + P_WID(&receive.maxarticle_spinbtn), prefs_set_data_from_spinbtn, prefs_set_spinbtn}, {"receive_at_get_all", "TRUE", &tmp_ac_prefs.recv_at_getall, P_BOOL, - &receive.recvatgetall_chkbtn, + P_WID(&receive.recvatgetall_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, /* Send */ {"add_date", "TRUE", &tmp_ac_prefs.add_date, P_BOOL, - &p_send.date_chkbtn, + P_WID(&p_send.date_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"generate_msgid", "TRUE", &tmp_ac_prefs.gen_msgid, P_BOOL, - &p_send.msgid_chkbtn, + P_WID(&p_send.msgid_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"add_custom_header", "FALSE", &tmp_ac_prefs.add_customhdr, P_BOOL, - &p_send.customhdr_chkbtn, + P_WID(&p_send.customhdr_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"use_smtp_auth", "FALSE", &tmp_ac_prefs.use_smtp_auth, P_BOOL, - &p_send.smtp_auth_chkbtn, + P_WID(&p_send.smtp_auth_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"smtp_auth_method", "0", &tmp_ac_prefs.smtp_auth_type, P_ENUM, - &p_send.smtp_auth_type_optmenu, + P_WID(&p_send.smtp_auth_type_optmenu), prefs_account_smtp_auth_type_set_data_from_optmenu, prefs_account_smtp_auth_type_set_optmenu}, {"smtp_user_id", NULL, &tmp_ac_prefs.smtp_userid, P_STRING, - &p_send.smtp_uid_entry, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&p_send.smtp_uid_entry), + prefs_set_data_from_entry, prefs_set_entry}, {"smtp_password", NULL, &tmp_ac_prefs.smtp_passwd, P_STRING, - &p_send.smtp_pass_entry, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&p_send.smtp_pass_entry), + prefs_set_data_from_entry, prefs_set_entry}, {"pop_before_smtp", "FALSE", &tmp_ac_prefs.pop_before_smtp, P_BOOL, NULL, NULL, NULL}, #if 0 - &p_send.pop_bfr_smtp_chkbtn, + P_WID(&p_send.pop_bfr_smtp_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, #endif /* Compose */ {"signature_type", "0", &tmp_ac_prefs.sig_type, P_ENUM, - &compose.sigfile_radiobtn, + P_WID(&compose.sigfile_radiobtn), prefs_account_enum_set_data_from_radiobtn, prefs_account_enum_set_radiobtn}, {"signature_path", "~" G_DIR_SEPARATOR_S DEFAULT_SIGNATURE, &tmp_ac_prefs.sig_path, P_STRING, - &compose.sigpath_entry, + P_WID(&compose.sigpath_entry), prefs_set_data_from_entry, prefs_set_entry}, {"set_autocc", "FALSE", &tmp_ac_prefs.set_autocc, P_BOOL, - &compose.autocc_chkbtn, + P_WID(&compose.autocc_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"auto_cc", NULL, &tmp_ac_prefs.auto_cc, P_STRING, - &compose.autocc_entry, + P_WID(&compose.autocc_entry), prefs_set_data_from_entry, prefs_set_entry}, {"set_autobcc", "FALSE", &tmp_ac_prefs.set_autobcc, P_BOOL, - &compose.autobcc_chkbtn, + P_WID(&compose.autobcc_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"auto_bcc", NULL, &tmp_ac_prefs.auto_bcc, P_STRING, - &compose.autobcc_entry, + P_WID(&compose.autobcc_entry), prefs_set_data_from_entry, prefs_set_entry}, {"set_autoreplyto", "FALSE", &tmp_ac_prefs.set_autoreplyto, P_BOOL, - &compose.autoreplyto_chkbtn, + P_WID(&compose.autoreplyto_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"auto_replyto", NULL, &tmp_ac_prefs.auto_replyto, P_STRING, - &compose.autoreplyto_entry, + P_WID(&compose.autoreplyto_entry), prefs_set_data_from_entry, prefs_set_entry}, #if USE_GPGME /* Privacy */ {"default_sign", "FALSE", &tmp_ac_prefs.default_sign, P_BOOL, - &privacy.default_sign_chkbtn, + P_WID(&privacy.default_sign_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"default_encrypt", "FALSE", &tmp_ac_prefs.default_encrypt, P_BOOL, - &privacy.default_encrypt_chkbtn, + P_WID(&privacy.default_encrypt_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"encrypt_reply", "TRUE", &tmp_ac_prefs.encrypt_reply, P_BOOL, - &privacy.encrypt_reply_chkbtn, + P_WID(&privacy.encrypt_reply_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"ascii_armored", "FALSE", &tmp_ac_prefs.ascii_armored, P_BOOL, - &privacy.ascii_armored_chkbtn, + P_WID(&privacy.ascii_armored_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"clearsign", "FALSE", &tmp_ac_prefs.clearsign, P_BOOL, - &privacy.clearsign_chkbtn, + P_WID(&privacy.clearsign_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"sign_key", NULL, &tmp_ac_prefs.sign_key, P_ENUM, - &privacy.defaultkey_radiobtn, + P_WID(&privacy.defaultkey_radiobtn), prefs_account_enum_set_data_from_radiobtn, prefs_account_enum_set_radiobtn}, {"sign_key_id", NULL, &tmp_ac_prefs.sign_key_id, P_STRING, - &privacy.customkey_entry, + P_WID(&privacy.customkey_entry), prefs_set_data_from_entry, prefs_set_entry}, #endif /* USE_GPGME */ #if USE_SSL /* SSL */ {"ssl_pop", "0", &tmp_ac_prefs.ssl_pop, P_ENUM, - &ssl.pop_nossl_radiobtn, + P_WID(&ssl.pop_nossl_radiobtn), prefs_account_enum_set_data_from_radiobtn, prefs_account_enum_set_radiobtn}, {"ssl_imap", "0", &tmp_ac_prefs.ssl_imap, P_ENUM, - &ssl.imap_nossl_radiobtn, + P_WID(&ssl.imap_nossl_radiobtn), prefs_account_enum_set_data_from_radiobtn, prefs_account_enum_set_radiobtn}, {"ssl_nntp", "0", &tmp_ac_prefs.ssl_nntp, P_ENUM, - &ssl.nntp_nossl_radiobtn, + P_WID(&ssl.nntp_nossl_radiobtn), prefs_account_enum_set_data_from_radiobtn, prefs_account_enum_set_radiobtn}, {"ssl_smtp", "0", &tmp_ac_prefs.ssl_smtp, P_ENUM, - &ssl.smtp_nossl_radiobtn, + P_WID(&ssl.smtp_nossl_radiobtn), prefs_account_enum_set_data_from_radiobtn, prefs_account_enum_set_radiobtn}, {"use_nonblocking_ssl", "1", &tmp_ac_prefs.use_nonblocking_ssl, P_BOOL, - &ssl.use_nonblocking_ssl_chkbtn, + P_WID(&ssl.use_nonblocking_ssl_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, #endif /* USE_SSL */ /* Advanced */ {"set_smtpport", "FALSE", &tmp_ac_prefs.set_smtpport, P_BOOL, - &advanced.smtpport_chkbtn, + P_WID(&advanced.smtpport_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"smtp_port", "25", &tmp_ac_prefs.smtpport, P_USHORT, - &advanced.smtpport_entry, + P_WID(&advanced.smtpport_entry), prefs_set_data_from_entry, prefs_set_entry}, {"set_popport", "FALSE", &tmp_ac_prefs.set_popport, P_BOOL, - &advanced.popport_chkbtn, + P_WID(&advanced.popport_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"pop_port", "110", &tmp_ac_prefs.popport, P_USHORT, - &advanced.popport_entry, + P_WID(&advanced.popport_entry), prefs_set_data_from_entry, prefs_set_entry}, {"set_imapport", "FALSE", &tmp_ac_prefs.set_imapport, P_BOOL, - &advanced.imapport_chkbtn, + P_WID(&advanced.imapport_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"imap_port", "143", &tmp_ac_prefs.imapport, P_USHORT, - &advanced.imapport_entry, + P_WID(&advanced.imapport_entry), prefs_set_data_from_entry, prefs_set_entry}, {"set_nntpport", "FALSE", &tmp_ac_prefs.set_nntpport, P_BOOL, - &advanced.nntpport_chkbtn, + P_WID(&advanced.nntpport_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"nntp_port", "119", &tmp_ac_prefs.nntpport, P_USHORT, - &advanced.nntpport_entry, + P_WID(&advanced.nntpport_entry), prefs_set_data_from_entry, prefs_set_entry}, {"set_domain", "FALSE", &tmp_ac_prefs.set_domain, P_BOOL, - &advanced.domain_chkbtn, + P_WID(&advanced.domain_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"domain", NULL, &tmp_ac_prefs.domain, P_STRING, - &advanced.domain_entry, + P_WID(&advanced.domain_entry), prefs_set_data_from_entry, prefs_set_entry}, {"imap_directory", NULL, &tmp_ac_prefs.imap_dir, P_STRING, - &advanced.imapdir_entry, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&advanced.imapdir_entry), + prefs_set_data_from_entry, prefs_set_entry}, {"set_sent_folder", "FALSE", &tmp_ac_prefs.set_sent_folder, P_BOOL, - &advanced.sent_folder_chkbtn, + P_WID(&advanced.sent_folder_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"sent_folder", NULL, &tmp_ac_prefs.sent_folder, P_STRING, - &advanced.sent_folder_entry, + P_WID(&advanced.sent_folder_entry), prefs_set_data_from_entry, prefs_set_entry}, {"set_draft_folder", "FALSE", &tmp_ac_prefs.set_draft_folder, P_BOOL, - &advanced.draft_folder_chkbtn, + P_WID(&advanced.draft_folder_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"draft_folder", NULL, &tmp_ac_prefs.draft_folder, P_STRING, - &advanced.draft_folder_entry, + P_WID(&advanced.draft_folder_entry), prefs_set_data_from_entry, prefs_set_entry}, {"set_trash_folder", "FALSE", &tmp_ac_prefs.set_trash_folder, P_BOOL, - &advanced.trash_folder_chkbtn, + P_WID(&advanced.trash_folder_chkbtn), prefs_set_data_from_toggle, prefs_set_toggle}, {"trash_folder", NULL, &tmp_ac_prefs.trash_folder, P_STRING, - &advanced.trash_folder_entry, + P_WID(&advanced.trash_folder_entry), prefs_set_data_from_entry, prefs_set_entry}, {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL} diff --git a/src/prefs_common.c b/src/prefs_common.c index 305d1892..86e67906 100644 --- a/src/prefs_common.c +++ b/src/prefs_common.c @@ -37,6 +37,7 @@ #include "main.h" #include "prefs.h" +#include "prefs_ui.h" #include "prefs_common.h" #include "prefs_display_header.h" #include "prefs_summary_column.h" @@ -236,61 +237,62 @@ static void prefs_common_recv_dialog_set_optmenu (PrefParam *pparam); static PrefParam param[] = { /* Receive */ {"use_ext_inc", "FALSE", &prefs_common.use_extinc, P_BOOL, - &receive.checkbtn_incext, + P_WID(&receive.checkbtn_incext), prefs_set_data_from_toggle, prefs_set_toggle}, {"ext_inc_path", DEFAULT_INC_PATH, &prefs_common.extinc_cmd, P_STRING, - &receive.entry_incext, + P_WID(&receive.entry_incext), prefs_set_data_from_entry, prefs_set_entry}, {"inc_local", "FALSE", &prefs_common.inc_local, P_BOOL, - &receive.checkbtn_local, + P_WID(&receive.checkbtn_local), prefs_set_data_from_toggle, prefs_set_toggle}, {"filter_on_inc_local", "TRUE", &prefs_common.filter_on_inc, P_BOOL, - &receive.checkbtn_filter_on_inc, + P_WID(&receive.checkbtn_filter_on_inc), prefs_set_data_from_toggle, prefs_set_toggle}, {"spool_path", DEFAULT_SPOOL_PATH, &prefs_common.spool_path, P_STRING, - &receive.entry_spool, + P_WID(&receive.entry_spool), prefs_set_data_from_entry, prefs_set_entry}, {"autochk_newmail", "FALSE", &prefs_common.autochk_newmail, P_BOOL, - &receive.checkbtn_autochk, + P_WID(&receive.checkbtn_autochk), prefs_set_data_from_toggle, prefs_set_toggle}, {"autochk_interval", "10", &prefs_common.autochk_itv, P_INT, - &receive.spinbtn_autochk, + P_WID(&receive.spinbtn_autochk), prefs_set_data_from_spinbtn, prefs_set_spinbtn}, {"check_on_startup", "FALSE", &prefs_common.chk_on_startup, P_BOOL, - &receive.checkbtn_chkonstartup, + P_WID(&receive.checkbtn_chkonstartup), prefs_set_data_from_toggle, prefs_set_toggle}, {"scan_all_after_inc", "FALSE", &prefs_common.scan_all_after_inc, - P_BOOL, &receive.checkbtn_scan_after_inc, + P_BOOL, P_WID(&receive.checkbtn_scan_after_inc), prefs_set_data_from_toggle, prefs_set_toggle}, {"enable_newmsg_notify", "FALSE", &prefs_common.enable_newmsg_notify, - P_BOOL, &receive.checkbtn_newmsg_notify, + P_BOOL, P_WID(&receive.checkbtn_newmsg_notify), prefs_set_data_from_toggle, prefs_set_toggle}, {"newmsg_notify_command", NULL, &prefs_common.newmsg_notify_cmd, - P_STRING, &receive.entry_newmsg_notify, + P_STRING, P_WID(&receive.entry_newmsg_notify), prefs_set_data_from_entry, prefs_set_entry}, /* Send */ {"use_ext_sendmail", "FALSE", &prefs_common.use_extsend, P_BOOL, - &p_send.checkbtn_extsend, + P_WID(&p_send.checkbtn_extsend), prefs_set_data_from_toggle, prefs_set_toggle}, {"ext_sendmail_cmd", DEFAULT_SENDMAIL_CMD, &prefs_common.extsend_cmd, P_STRING, - &p_send.entry_extsend, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&p_send.entry_extsend), + prefs_set_data_from_entry, prefs_set_entry}, {"save_message", "TRUE", &prefs_common.savemsg, P_BOOL, - &p_send.checkbtn_savemsg, + P_WID(&p_send.checkbtn_savemsg), prefs_set_data_from_toggle, prefs_set_toggle}, {"filter_sent_message", "FALSE", &prefs_common.filter_sent, P_BOOL, - &p_send.checkbtn_filter_sent, + P_WID(&p_send.checkbtn_filter_sent), prefs_set_data_from_toggle, prefs_set_toggle}, {"outgoing_charset", CS_AUTO, &prefs_common.outgoing_charset, P_STRING, - &p_send.optmenu_charset, + P_WID(&p_send.optmenu_charset), prefs_common_charset_set_data_from_optmenu, prefs_common_charset_set_optmenu}, {"encoding_method", "0", &prefs_common.encoding_method, P_ENUM, - &p_send.optmenu_encoding_method, + P_WID(&p_send.optmenu_encoding_method), prefs_common_encoding_set_data_from_optmenu, prefs_common_encoding_set_optmenu}, @@ -299,42 +301,43 @@ static PrefParam param[] = { /* Compose */ {"auto_signature", "TRUE", &prefs_common.auto_sig, P_BOOL, - &compose.checkbtn_autosig, + P_WID(&compose.checkbtn_autosig), prefs_set_data_from_toggle, prefs_set_toggle}, {"signature_separator", "-- ", &prefs_common.sig_sep, P_STRING, - &compose.entry_sigsep, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&compose.entry_sigsep), + prefs_set_data_from_entry, prefs_set_entry}, {"auto_ext_editor", "FALSE", &prefs_common.auto_exteditor, P_BOOL, - &compose.checkbtn_autoextedit, + P_WID(&compose.checkbtn_autoextedit), prefs_set_data_from_toggle, prefs_set_toggle}, {"undo_level", "50", &prefs_common.undolevels, P_INT, - &compose.spinbtn_undolevel, + P_WID(&compose.spinbtn_undolevel), prefs_set_data_from_spinbtn, prefs_set_spinbtn}, {"linewrap_length", "72", &prefs_common.linewrap_len, P_INT, - &compose.spinbtn_linewrap, + P_WID(&compose.spinbtn_linewrap), prefs_set_data_from_spinbtn, prefs_set_spinbtn}, {"linewrap_quotation", "FALSE", &prefs_common.linewrap_quote, P_BOOL, - &compose.checkbtn_wrapquote, + P_WID(&compose.checkbtn_wrapquote), prefs_set_data_from_toggle, prefs_set_toggle}, {"linewrap_auto", "FALSE", &prefs_common.autowrap, P_BOOL, - &compose.checkbtn_autowrap, + P_WID(&compose.checkbtn_autowrap), prefs_set_data_from_toggle, prefs_set_toggle}, {"linewrap_before_sending", "FALSE", &prefs_common.linewrap_at_send, P_BOOL, - &compose.checkbtn_wrapatsend, + P_WID(&compose.checkbtn_wrapatsend), prefs_set_data_from_toggle, prefs_set_toggle}, {"reply_with_quote", "TRUE", &prefs_common.reply_with_quote, P_BOOL, - &compose.checkbtn_quote, + P_WID(&compose.checkbtn_quote), prefs_set_data_from_toggle, prefs_set_toggle}, {"reply_account_autoselect", "TRUE", &prefs_common.reply_account_autosel, P_BOOL, - &compose.checkbtn_reply_account_autosel, + P_WID(&compose.checkbtn_reply_account_autosel), prefs_set_data_from_toggle, prefs_set_toggle}, {"default_reply_list", "TRUE", &prefs_common.default_reply_list, P_BOOL, - &compose.checkbtn_default_reply_list, + P_WID(&compose.checkbtn_default_reply_list), prefs_set_data_from_toggle, prefs_set_toggle}, {"show_ruler", "TRUE", &prefs_common.show_ruler, P_BOOL, @@ -342,49 +345,50 @@ static PrefParam param[] = { /* Quote */ {"reply_quote_mark", "> ", &prefs_common.quotemark, P_STRING, - "e.entry_quotemark, prefs_set_data_from_entry, prefs_set_entry}, + P_WID("e.entry_quotemark), + prefs_set_data_from_entry, prefs_set_entry}, {"reply_quote_format", "On %d\\n%f wrote:\\n\\n%Q", - &prefs_common.quotefmt, P_STRING, "e.text_quotefmt, + &prefs_common.quotefmt, P_STRING, P_WID("e.text_quotefmt), prefs_set_data_from_text, prefs_set_text}, {"forward_quote_mark", "> ", &prefs_common.fw_quotemark, P_STRING, - "e.entry_fw_quotemark, + P_WID("e.entry_fw_quotemark), prefs_set_data_from_entry, prefs_set_entry}, {"forward_quote_format", "\\n\\nBegin forwarded message:\\n\\n" "?d{Date: %d\\n}?f{From: %f\\n}?t{To: %t\\n}?c{Cc: %c\\n}" "?n{Newsgroups: %n\\n}?s{Subject: %s\\n}\\n\\n%M", - &prefs_common.fw_quotefmt, P_STRING, "e.text_fw_quotefmt, + &prefs_common.fw_quotefmt, P_STRING, P_WID("e.text_fw_quotefmt), prefs_set_data_from_text, prefs_set_text}, /* Display */ {"message_font_name", DEFAULT_MESSAGE_FONT, &prefs_common.textfont, P_STRING, - &display.fontbtn_textfont, + P_WID(&display.fontbtn_textfont), prefs_set_data_from_fontbtn, prefs_set_fontbtn}, {"display_folder_unread_num", "TRUE", &prefs_common.display_folder_unread, P_BOOL, - &display.chkbtn_folder_unread, + P_WID(&display.chkbtn_folder_unread), prefs_set_data_from_toggle, prefs_set_toggle}, {"newsgroup_abbrev_len", "16", &prefs_common.ng_abbrev_len, P_INT, - &display.spinbtn_ng_abbrev_len, + P_WID(&display.spinbtn_ng_abbrev_len), prefs_set_data_from_spinbtn, prefs_set_spinbtn}, {"translate_header", "TRUE", &prefs_common.trans_hdr, P_BOOL, - &display.chkbtn_transhdr, + P_WID(&display.chkbtn_transhdr), prefs_set_data_from_toggle, prefs_set_toggle}, /* Display: Summary View */ {"enable_swap_from", "FALSE", &prefs_common.swap_from, P_BOOL, - &display.chkbtn_swapfrom, + P_WID(&display.chkbtn_swapfrom), prefs_set_data_from_toggle, prefs_set_toggle}, {"date_format", "%y/%m/%d(%a) %H:%M", &prefs_common.date_format, - P_STRING, &display.entry_datefmt, + P_STRING, P_WID(&display.entry_datefmt), prefs_set_data_from_entry, prefs_set_entry}, {"expand_thread", "TRUE", &prefs_common.expand_thread, P_BOOL, - &display.chkbtn_expand_thread, + P_WID(&display.chkbtn_expand_thread), prefs_set_data_from_toggle, prefs_set_toggle}, {"enable_rules_hint", "TRUE", &prefs_common.enable_rules_hint, P_BOOL, @@ -520,7 +524,7 @@ static PrefParam param[] = { /* Message */ {"enable_color", "TRUE", &prefs_common.enable_color, P_BOOL, - &message.chkbtn_enablecol, + P_WID(&message.chkbtn_enablecol), prefs_set_data_from_toggle, prefs_set_toggle}, {"quote_level1_color", "179", &prefs_common.quote_level1_col, P_INT, @@ -537,19 +541,19 @@ static PrefParam param[] = { P_BOOL, NULL, NULL, NULL}, {"convert_mb_alnum", "FALSE", &prefs_common.conv_mb_alnum, P_BOOL, - &message.chkbtn_mbalnum, + P_WID(&message.chkbtn_mbalnum), prefs_set_data_from_toggle, prefs_set_toggle}, {"display_header_pane", "TRUE", &prefs_common.display_header_pane, - P_BOOL, &message.chkbtn_disphdrpane, + P_BOOL, P_WID(&message.chkbtn_disphdrpane), prefs_set_data_from_toggle, prefs_set_toggle}, {"display_header", "TRUE", &prefs_common.display_header, P_BOOL, - &message.chkbtn_disphdr, + P_WID(&message.chkbtn_disphdr), prefs_set_data_from_toggle, prefs_set_toggle}, {"render_html", "TRUE", &prefs_common.render_html, P_BOOL, - &message.chkbtn_html, + P_WID(&message.chkbtn_html), prefs_set_data_from_toggle, prefs_set_toggle}, {"line_space", "2", &prefs_common.line_space, P_INT, - &message.spinbtn_linespc, + P_WID(&message.spinbtn_linespc), prefs_set_data_from_spinbtn, prefs_set_spinbtn}, {"textview_cursor_visible", "FALSE", @@ -558,20 +562,20 @@ static PrefParam param[] = { {"enable_smooth_scroll", "FALSE", &prefs_common.enable_smooth_scroll, P_BOOL, - &message.chkbtn_smoothscroll, + P_WID(&message.chkbtn_smoothscroll), prefs_set_data_from_toggle, prefs_set_toggle}, {"scroll_step", "1", &prefs_common.scroll_step, P_INT, - &message.spinbtn_scrollstep, + P_WID(&message.spinbtn_scrollstep), prefs_set_data_from_spinbtn, prefs_set_spinbtn}, {"scroll_half_page", "FALSE", &prefs_common.scroll_halfpage, P_BOOL, - &message.chkbtn_halfpage, + P_WID(&message.chkbtn_halfpage), prefs_set_data_from_toggle, prefs_set_toggle}, {"resize_image", "TRUE", &prefs_common.resize_image, P_BOOL, - &message.chkbtn_resize_image, + P_WID(&message.chkbtn_resize_image), prefs_set_data_from_toggle, prefs_set_toggle}, {"inline_image", "TRUE", &prefs_common.inline_image, P_BOOL, - &message.chkbtn_inline_image, + P_WID(&message.chkbtn_inline_image), prefs_set_data_from_toggle, prefs_set_toggle}, {"show_other_header", "FALSE", &prefs_common.show_other_header, P_BOOL, @@ -587,48 +591,51 @@ static PrefParam param[] = { /* Junk mail */ {"enable_junk", "FALSE", &prefs_common.enable_junk, P_BOOL, - &junk.chkbtn_enable_junk, + P_WID(&junk.chkbtn_enable_junk), prefs_set_data_from_toggle, prefs_set_toggle}, {"junk_learn_command", "bogofilter -s -I", &prefs_common.junk_learncmd, P_STRING, - &junk.entry_junk_learncmd, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&junk.entry_junk_learncmd), + prefs_set_data_from_entry, prefs_set_entry}, {"nojunk_learn_command", "bogofilter -n -I", &prefs_common.nojunk_learncmd, P_STRING, - &junk.entry_nojunk_learncmd, + P_WID(&junk.entry_nojunk_learncmd), prefs_set_data_from_entry, prefs_set_entry}, {"junk_classify_command", "bogofilter -I", &prefs_common.junk_classify_cmd, P_STRING, - &junk.entry_classify_cmd, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&junk.entry_classify_cmd), + prefs_set_data_from_entry, prefs_set_entry}, {"junk_folder", NULL, &prefs_common.junk_folder, P_STRING, - &junk.entry_junkfolder, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&junk.entry_junkfolder), + prefs_set_data_from_entry, prefs_set_entry}, {"filter_junk_on_receive", "FALSE", &prefs_common.filter_junk_on_recv, - P_BOOL, &junk.chkbtn_filter_on_recv, + P_BOOL, P_WID(&junk.chkbtn_filter_on_recv), prefs_set_data_from_toggle, prefs_set_toggle}, #if USE_GPGME /* Privacy */ {"auto_check_signatures", "TRUE", &prefs_common.auto_check_signatures, P_BOOL, - &privacy.checkbtn_auto_check_signatures, + P_WID(&privacy.checkbtn_auto_check_signatures), prefs_set_data_from_toggle, prefs_set_toggle}, {"gpg_signature_popup", "FALSE", &prefs_common.gpg_signature_popup, P_BOOL, - &privacy.checkbtn_gpg_signature_popup, + P_WID(&privacy.checkbtn_gpg_signature_popup), prefs_set_data_from_toggle, prefs_set_toggle}, {"store_passphrase", "FALSE", &prefs_common.store_passphrase, P_BOOL, - &privacy.checkbtn_store_passphrase, + P_WID(&privacy.checkbtn_store_passphrase), prefs_set_data_from_toggle, prefs_set_toggle}, {"store_passphrase_timeout", "0", &prefs_common.store_passphrase_timeout, P_INT, - &privacy.spinbtn_store_passphrase, + P_WID(&privacy.spinbtn_store_passphrase), prefs_set_data_from_spinbtn, prefs_set_spinbtn}, #ifndef G_OS_WIN32 {"passphrase_grab", "FALSE", &prefs_common.passphrase_grab, P_BOOL, - &privacy.checkbtn_passphrase_grab, + P_WID(&privacy.checkbtn_passphrase_grab), prefs_set_data_from_toggle, prefs_set_toggle}, #endif /* G_OS_WIN32 */ {"gpg_warning", "TRUE", &prefs_common.gpg_warning, P_BOOL, - &privacy.checkbtn_gpg_warning, + P_WID(&privacy.checkbtn_gpg_warning), prefs_set_data_from_toggle, prefs_set_toggle}, #endif /* USE_GPGME */ @@ -640,30 +647,30 @@ static PrefParam param[] = { {"always_show_message_when_selected", "FALSE", &prefs_common.always_show_msg, - P_BOOL, &interface.checkbtn_always_show_msg, + P_BOOL, P_WID(&interface.checkbtn_always_show_msg), prefs_set_data_from_toggle, prefs_set_toggle}, {"open_unread_on_enter", "FALSE", &prefs_common.open_unread_on_enter, - P_BOOL, &interface.checkbtn_openunread, + P_BOOL, P_WID(&interface.checkbtn_openunread), prefs_set_data_from_toggle, prefs_set_toggle}, {"mark_as_read_on_new_window", "FALSE", &prefs_common.mark_as_read_on_new_window, - P_BOOL, &interface.checkbtn_mark_as_read_on_newwin, + P_BOOL, P_WID(&interface.checkbtn_mark_as_read_on_newwin), prefs_set_data_from_toggle, prefs_set_toggle}, {"open_inbox_on_inc", "FALSE", &prefs_common.open_inbox_on_inc, - P_BOOL, &interface.checkbtn_openinbox, + P_BOOL, P_WID(&interface.checkbtn_openinbox), prefs_set_data_from_toggle, prefs_set_toggle}, {"immediate_execution", "TRUE", &prefs_common.immediate_exec, P_BOOL, - &interface.checkbtn_immedexec, + P_WID(&interface.checkbtn_immedexec), prefs_set_data_from_toggle, prefs_set_toggle}, {"receive_dialog_mode", "1", &prefs_common.recv_dialog_mode, P_ENUM, - &interface.optmenu_recvdialog, + P_WID(&interface.optmenu_recvdialog), prefs_common_recv_dialog_set_data_from_optmenu, prefs_common_recv_dialog_set_optmenu}, {"no_receive_error_panel", "FALSE", &prefs_common.no_recv_err_panel, - P_BOOL, &interface.checkbtn_no_recv_err_panel, + P_BOOL, P_WID(&interface.checkbtn_no_recv_err_panel), prefs_set_data_from_toggle, prefs_set_toggle}, {"close_receive_dialog", "TRUE", &prefs_common.close_recv_dialog, - P_BOOL, &interface.checkbtn_close_recv_dialog, + P_BOOL, P_WID(&interface.checkbtn_close_recv_dialog), prefs_set_data_from_toggle, prefs_set_toggle}, #ifdef G_OS_WIN32 @@ -671,34 +678,36 @@ static PrefParam param[] = { #else {"comply_gnome_hig", "TRUE", &prefs_common.comply_gnome_hig, P_BOOL, #endif - &interface.checkbtn_comply_gnome_hig, + P_WID(&interface.checkbtn_comply_gnome_hig), prefs_set_data_from_toggle, prefs_set_toggle}, /* Other */ {"uri_open_command", DEFAULT_BROWSER_CMD, &prefs_common.uri_cmd, P_STRING, - &other.uri_entry, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&other.uri_entry), prefs_set_data_from_entry, prefs_set_entry}, {"print_command", "lpr %s", &prefs_common.print_cmd, P_STRING, - &other.printcmd_entry, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&other.printcmd_entry), + prefs_set_data_from_entry, prefs_set_entry}, {"ext_editor_command", "gedit %s", &prefs_common.ext_editor_cmd, P_STRING, - &other.exteditor_entry, prefs_set_data_from_entry, prefs_set_entry}, + P_WID(&other.exteditor_entry), + prefs_set_data_from_entry, prefs_set_entry}, {"add_address_by_click", "FALSE", &prefs_common.add_address_by_click, - P_BOOL, &other.checkbtn_addaddrbyclick, + P_BOOL, P_WID(&other.checkbtn_addaddrbyclick), prefs_set_data_from_toggle, prefs_set_toggle}, {"confirm_on_exit", "FALSE", &prefs_common.confirm_on_exit, P_BOOL, - &other.checkbtn_confonexit, + P_WID(&other.checkbtn_confonexit), prefs_set_data_from_toggle, prefs_set_toggle}, {"clean_trash_on_exit", "FALSE", &prefs_common.clean_on_exit, P_BOOL, - &other.checkbtn_cleanonexit, + P_WID(&other.checkbtn_cleanonexit), prefs_set_data_from_toggle, prefs_set_toggle}, {"ask_on_cleaning", "TRUE", &prefs_common.ask_on_clean, P_BOOL, - &other.checkbtn_askonclean, + P_WID(&other.checkbtn_askonclean), prefs_set_data_from_toggle, prefs_set_toggle}, {"warn_queued_on_exit", "TRUE", &prefs_common.warn_queued_on_exit, - P_BOOL, &other.checkbtn_warnqueued, + P_BOOL, P_WID(&other.checkbtn_warnqueued), prefs_set_data_from_toggle, prefs_set_toggle}, {"logwindow_line_limit", "1000", &prefs_common.logwin_line_limit, @@ -706,10 +715,10 @@ static PrefParam param[] = { /* Advanced */ {"strict_cache_check", "FALSE", &prefs_common.strict_cache_check, - P_BOOL, &advanced.checkbtn_strict_cache_check, + P_BOOL, P_WID(&advanced.checkbtn_strict_cache_check), prefs_set_data_from_toggle, prefs_set_toggle}, {"io_timeout_secs", "60", &prefs_common.io_timeout_secs, - P_INT, &advanced.spinbtn_iotimeout, + P_INT, P_WID(&advanced.spinbtn_iotimeout), prefs_set_data_from_spinbtn, prefs_set_spinbtn}, {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL} diff --git a/src/prefs_customheader.c b/src/prefs_customheader.c index 97df2bbf..eee8696b 100644 --- a/src/prefs_customheader.c +++ b/src/prefs_customheader.c @@ -34,6 +34,7 @@ #include "main.h" #include "prefs.h" +#include "prefs_ui.h" #include "prefs_customheader.h" #include "prefs_common.h" #include "prefs_account.h" diff --git a/src/prefs_display_header.c b/src/prefs_display_header.c index 6d21aef8..7d5953d0 100644 --- a/src/prefs_display_header.c +++ b/src/prefs_display_header.c @@ -33,6 +33,7 @@ #include <errno.h> #include "prefs.h" +#include "prefs_ui.h" #include "prefs_display_header.h" #include "prefs_common.h" #include "manage_window.h" diff --git a/src/prefs_filter.c b/src/prefs_filter.c index 8af08f4b..9ef63daa 100644 --- a/src/prefs_filter.c +++ b/src/prefs_filter.c @@ -34,6 +34,7 @@ #include "main.h" #include "prefs.h" +#include "prefs_ui.h" #include "prefs_filter.h" #include "prefs_filter_edit.h" #include "prefs_common.h" diff --git a/src/prefs_filter.h b/src/prefs_filter.h index ca9ca6cb..e99c4f7f 100644 --- a/src/prefs_filter.h +++ b/src/prefs_filter.h @@ -26,8 +26,6 @@ #include <glib.h> -#include "procmsg.h" - typedef enum { FILTER_BY_NONE, @@ -37,6 +35,8 @@ typedef enum FILTER_BY_SUBJECT } PrefsFilterType; +#include "procmsg.h" + void prefs_filter_read_config (void); void prefs_filter_write_config (void); diff --git a/src/prefs_folder_item.c b/src/prefs_folder_item.c index cd6514f5..374110ef 100644 --- a/src/prefs_folder_item.c +++ b/src/prefs_folder_item.c @@ -30,6 +30,7 @@ #include "folder.h" #include "prefs.h" +#include "prefs_ui.h" #include "prefs_folder_item.h" #include "prefs_account.h" #include "account.h" diff --git a/src/prefs_summary_column.c b/src/prefs_summary_column.c index 7197f8e6..334db41f 100644 --- a/src/prefs_summary_column.c +++ b/src/prefs_summary_column.c @@ -35,6 +35,7 @@ #include <gtk/gtkstock.h> #include "prefs.h" +#include "prefs_ui.h" #include "prefs_common.h" #include "prefs_summary_column.h" #include "manage_window.h" diff --git a/src/prefs_ui.c b/src/prefs_ui.c new file mode 100644 index 00000000..5f516c79 --- /dev/null +++ b/src/prefs_ui.c @@ -0,0 +1,452 @@ +/* + * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client + * Copyright (C) 1999-2005 Hiroyuki Yamamoto + * + * 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 <glib.h> +#include <glib/gi18n.h> +#include <gtk/gtk.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> + +#include "prefs.h" +#include "prefs_ui.h" +#include "codeconv.h" +#include "utils.h" +#include "gtkutils.h" + +typedef enum +{ + DUMMY_PARAM +} DummyEnum; + +void prefs_dialog_create(PrefsDialog *dialog) +{ + GtkWidget *window; + GtkWidget *vbox; + GtkWidget *notebook; + + GtkWidget *confirm_area; + GtkWidget *ok_btn; + GtkWidget *cancel_btn; + GtkWidget *apply_btn; + + g_return_if_fail(dialog != NULL); + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_container_set_border_width (GTK_CONTAINER (window), 8); + 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, TRUE, FALSE); + + vbox = gtk_vbox_new (FALSE, 6); + gtk_widget_show(vbox); + gtk_container_add (GTK_CONTAINER (window), vbox); + + notebook = gtk_notebook_new (); + gtk_widget_show(notebook); + gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0); + gtk_container_set_border_width (GTK_CONTAINER (notebook), 2); + /* GTK_WIDGET_UNSET_FLAGS (notebook, GTK_CAN_FOCUS); */ + gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE); + + gtkut_stock_button_set_create(&confirm_area, + &ok_btn, GTK_STOCK_OK, + &cancel_btn, GTK_STOCK_CANCEL, + &apply_btn, GTK_STOCK_APPLY); + gtk_widget_show(confirm_area); + gtk_box_pack_end (GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0); + gtk_widget_grab_default(ok_btn); + + dialog->window = window; + dialog->notebook = notebook; + dialog->confirm_area = confirm_area; + dialog->ok_btn = ok_btn; + dialog->cancel_btn = cancel_btn; + dialog->apply_btn = apply_btn; +} + +void prefs_dialog_destroy(PrefsDialog *dialog) +{ + gtk_widget_destroy(dialog->window); + dialog->window = NULL; + dialog->notebook = NULL; + dialog->ok_btn = NULL; + dialog->cancel_btn = NULL; + dialog->apply_btn = NULL; +} + +void prefs_button_toggled(GtkToggleButton *toggle_btn, GtkWidget *widget) +{ + gboolean is_active; + + is_active = gtk_toggle_button_get_active(toggle_btn); + gtk_widget_set_sensitive(widget, is_active); +} + +void prefs_set_dialog(PrefParam *param) +{ + gint i; + + for (i = 0; param[i].name != NULL; i++) { + if (param[i].widget_set_func) + param[i].widget_set_func(¶m[i]); + } +} + +void prefs_set_data_from_dialog(PrefParam *param) +{ + gint i; + + for (i = 0; param[i].name != NULL; i++) { + if (param[i].data_set_func) + param[i].data_set_func(¶m[i]); + } +} + +void prefs_set_dialog_to_default(PrefParam *param) +{ + gint i; + PrefParam tmpparam; + gchar *str_data = NULL; + gint int_data; + gushort ushort_data; + gboolean bool_data; + DummyEnum enum_data; + + for (i = 0; param[i].name != NULL; i++) { + if (!param[i].widget_set_func) continue; + + tmpparam = param[i]; + + switch (tmpparam.type) { + case P_STRING: + if (tmpparam.defval) { + if (!g_ascii_strncasecmp + (tmpparam.defval, "ENV_", 4)) { + str_data = g_strdup + (g_getenv(param[i].defval + 4)); + tmpparam.data = &str_data; + break; + } else if (tmpparam.defval[0] == '~') { + str_data = + g_strconcat(get_home_dir(), + param[i].defval + 1, + NULL); + tmpparam.data = &str_data; + break; + } + } + tmpparam.data = &tmpparam.defval; + break; + case P_INT: + if (tmpparam.defval) + int_data = atoi(tmpparam.defval); + else + int_data = 0; + tmpparam.data = &int_data; + break; + case P_USHORT: + if (tmpparam.defval) + ushort_data = atoi(tmpparam.defval); + else + ushort_data = 0; + tmpparam.data = &ushort_data; + break; + case P_BOOL: + if (tmpparam.defval) { + if (!g_ascii_strcasecmp(tmpparam.defval, "TRUE")) + bool_data = TRUE; + else + bool_data = atoi(tmpparam.defval) + ? TRUE : FALSE; + } else + bool_data = FALSE; + tmpparam.data = &bool_data; + break; + case P_ENUM: + if (tmpparam.defval) + enum_data = (DummyEnum)atoi(tmpparam.defval); + else + enum_data = 0; + tmpparam.data = &enum_data; + break; + case P_OTHER: + break; + } + tmpparam.widget_set_func(&tmpparam); + g_free(str_data); + str_data = NULL; + } +} + +void prefs_set_data_from_entry(PrefParam *pparam) +{ + gchar **str; + const gchar *entry_str; + + g_return_if_fail(*pparam->widget != NULL); + + entry_str = gtk_entry_get_text(GTK_ENTRY(*pparam->widget)); + + switch (pparam->type) { + case P_STRING: + str = (gchar **)pparam->data; + g_free(*str); + *str = entry_str[0] ? g_strdup(entry_str) : NULL; + break; + case P_USHORT: + *((gushort *)pparam->data) = atoi(entry_str); + break; + case P_INT: + *((gint *)pparam->data) = atoi(entry_str); + break; + default: + g_warning("Invalid PrefType for GtkEntry widget: %d\n", + pparam->type); + } +} + +void prefs_set_entry(PrefParam *pparam) +{ + gchar **str; + + g_return_if_fail(*pparam->widget != NULL); + + switch (pparam->type) { + case P_STRING: + str = (gchar **)pparam->data; + gtk_entry_set_text(GTK_ENTRY(*pparam->widget), + *str ? *str : ""); + break; + case P_INT: + gtk_entry_set_text(GTK_ENTRY(*pparam->widget), + itos(*((gint *)pparam->data))); + break; + case P_USHORT: + gtk_entry_set_text(GTK_ENTRY(*pparam->widget), + itos(*((gushort *)pparam->data))); + break; + default: + g_warning("Invalid PrefType for GtkEntry widget: %d\n", + pparam->type); + } +} + +void prefs_set_data_from_text(PrefParam *pparam) +{ + gchar **str; + gchar *text = NULL, *tp = NULL; + gchar *tmp, *tmpp; + + g_return_if_fail(*pparam->widget != NULL); + g_return_if_fail(GTK_IS_EDITABLE(*pparam->widget) || + GTK_IS_TEXT_VIEW(*pparam->widget)); + + switch (pparam->type) { + case P_STRING: + str = (gchar **)pparam->data; + g_free(*str); + if (GTK_IS_EDITABLE(*pparam->widget)) { + tp = text = gtk_editable_get_chars + (GTK_EDITABLE(*pparam->widget), 0, -1); + } else if (GTK_IS_TEXT_VIEW(*pparam->widget)) { + GtkTextView *textview = GTK_TEXT_VIEW(*pparam->widget); + GtkTextBuffer *buffer; + GtkTextIter start, end; + + buffer = gtk_text_view_get_buffer(textview); + gtk_text_buffer_get_start_iter(buffer, &start); + gtk_text_buffer_get_iter_at_offset(buffer, &end, -1); + tp = text = gtk_text_buffer_get_text + (buffer, &start, &end, FALSE); + } + + g_return_if_fail(tp != NULL && text != NULL); + + if (text[0] == '\0') { + *str = NULL; + g_free(text); + break; + } + + Xalloca(tmpp = tmp, strlen(text) * 2 + 1, + { *str = NULL; break; }); + while (*tp) { + if (*tp == '\n') { + *tmpp++ = '\\'; + *tmpp++ = 'n'; + tp++; + } else + *tmpp++ = *tp++; + } + *tmpp = '\0'; + *str = g_strdup(tmp); + g_free(text); + break; + default: + g_warning("Invalid PrefType for GtkTextView widget: %d\n", + pparam->type); + } +} + +void prefs_set_text(PrefParam *pparam) +{ + gchar *buf, *sp, *bufp; + gchar **str; + GtkTextView *text; + GtkTextBuffer *buffer; + GtkTextIter iter; + + g_return_if_fail(*pparam->widget != NULL); + + switch (pparam->type) { + case P_STRING: + str = (gchar **)pparam->data; + if (*str) { + bufp = buf = alloca(strlen(*str) + 1); + if (!buf) buf = ""; + else { + sp = *str; + while (*sp) { + if (*sp == '\\' && *(sp + 1) == 'n') { + *bufp++ = '\n'; + sp += 2; + } else + *bufp++ = *sp++; + } + *bufp = '\0'; + } + } else + buf = ""; + + text = GTK_TEXT_VIEW(*pparam->widget); + buffer = gtk_text_view_get_buffer(text); + gtk_text_buffer_set_text(buffer, "", 0); + gtk_text_buffer_get_start_iter(buffer, &iter); + gtk_text_buffer_insert(buffer, &iter, buf, -1); + break; + default: + g_warning("Invalid PrefType for GtkTextView widget: %d\n", + pparam->type); + } +} + +void prefs_set_data_from_toggle(PrefParam *pparam) +{ + g_return_if_fail(pparam->type == P_BOOL); + g_return_if_fail(*pparam->widget != NULL); + + *((gboolean *)pparam->data) = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(*pparam->widget)); +} + +void prefs_set_toggle(PrefParam *pparam) +{ + g_return_if_fail(pparam->type == P_BOOL); + g_return_if_fail(*pparam->widget != NULL); + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(*pparam->widget), + *((gboolean *)pparam->data)); +} + +void prefs_set_data_from_spinbtn(PrefParam *pparam) +{ + g_return_if_fail(*pparam->widget != NULL); + + switch (pparam->type) { + case P_INT: + *((gint *)pparam->data) = + gtk_spin_button_get_value_as_int + (GTK_SPIN_BUTTON(*pparam->widget)); + break; + case P_USHORT: + *((gushort *)pparam->data) = + (gushort)gtk_spin_button_get_value_as_int + (GTK_SPIN_BUTTON(*pparam->widget)); + break; + default: + g_warning("Invalid PrefType for GtkSpinButton widget: %d\n", + pparam->type); + } +} + +void prefs_set_spinbtn(PrefParam *pparam) +{ + g_return_if_fail(*pparam->widget != NULL); + + switch (pparam->type) { + case P_INT: + gtk_spin_button_set_value(GTK_SPIN_BUTTON(*pparam->widget), + (gfloat)*((gint *)pparam->data)); + break; + case P_USHORT: + gtk_spin_button_set_value(GTK_SPIN_BUTTON(*pparam->widget), + (gfloat)*((gushort *)pparam->data)); + break; + default: + g_warning("Invalid PrefType for GtkSpinButton widget: %d\n", + pparam->type); + } +} + +void prefs_set_data_from_fontbtn(PrefParam *pparam) +{ + gchar **str; + const gchar *font_str; + + g_return_if_fail(*pparam->widget != NULL); + + font_str = gtk_font_button_get_font_name + (GTK_FONT_BUTTON(*pparam->widget)); + + switch (pparam->type) { + case P_STRING: + str = (gchar **)pparam->data; + g_free(*str); + *str = font_str[0] ? g_strdup(font_str) : NULL; + break; + default: + g_warning("Invalid PrefType for GtkFontButton widget: %d\n", + pparam->type); + } +} + +void prefs_set_fontbtn(PrefParam *pparam) +{ + gchar **str; + + g_return_if_fail(*pparam->widget != NULL); + + switch (pparam->type) { + case P_STRING: + str = (gchar **)pparam->data; + gtk_font_button_set_font_name(GTK_FONT_BUTTON(*pparam->widget), + *str ? *str : ""); + break; + default: + g_warning("Invalid PrefType for GtkFontButton widget: %d\n", + pparam->type); + } +} diff --git a/src/prefs_ui.h b/src/prefs_ui.h new file mode 100644 index 00000000..9d921aae --- /dev/null +++ b/src/prefs_ui.h @@ -0,0 +1,144 @@ +/* + * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client + * Copyright (C) 1999-2005 Hiroyuki Yamamoto + * + * 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_UI_H__ +#define __PREFS_UI_H__ + +#include <glib.h> +#include <gtk/gtkwidget.h> +#include <gtk/gtksignal.h> +#include <gtk/gtklabel.h> +#include <gtk/gtknotebook.h> +#include <gtk/gtkcheckbutton.h> +#include <gtk/gtkframe.h> +#include <gtk/gtkvbox.h> +#include <stdio.h> + +typedef struct _PrefsDialog PrefsDialog; + +#include "prefs.h" +#include "gtkutils.h" + +#define VSPACING 10 +#define VSPACING_NARROW 4 +#define VSPACING_NARROW_2 2 +#define VBOX_BORDER 16 +#define DEFAULT_ENTRY_WIDTH 80 + +struct _PrefsDialog +{ + GtkWidget *window; + GtkWidget *notebook; + + GtkWidget *confirm_area; + GtkWidget *ok_btn; + GtkWidget *cancel_btn; + GtkWidget *apply_btn; +}; + +#define SET_NOTEBOOK_LABEL(notebook, str, page_num) \ +{ \ + GtkWidget *label; \ + \ + label = gtk_label_new (str); \ + gtk_widget_show (label); \ + gtk_notebook_set_tab_label \ + (GTK_NOTEBOOK (notebook), \ + gtk_notebook_get_nth_page \ + (GTK_NOTEBOOK (notebook), page_num), \ + label); \ +} + +#define PACK_CHECK_BUTTON(box, chkbtn, label) \ +{ \ + chkbtn = gtk_check_button_new_with_label(label); \ + gtk_widget_show(chkbtn); \ + gtk_box_pack_start(GTK_BOX(box), chkbtn, FALSE, TRUE, 0); \ +} + +#define PACK_END_CHECK_BUTTON(box, chkbtn, label) \ +{ \ + chkbtn = gtk_check_button_new_with_label(label); \ + gtk_widget_show(chkbtn); \ + gtk_box_pack_end(GTK_BOX(box), chkbtn, FALSE, TRUE, 0); \ +} + +#define PACK_FRAME(box, frame, label) \ +{ \ + frame = gtk_frame_new(label); \ + gtk_widget_show(frame); \ + gtk_box_pack_start(GTK_BOX(box), frame, FALSE, TRUE, 0); \ + gtk_frame_set_label_align(GTK_FRAME(frame), 0.01, 0.5); \ +} + +#define PACK_FRAME_WITH_CHECK_BUTTON(box, frame, chkbtn, label) \ +{ \ + chkbtn = gtk_check_button_new_with_label(label); \ + gtk_widget_show(chkbtn); \ + PACK_FRAME(box, frame, NULL); \ + gtk_frame_set_label_widget(GTK_FRAME(frame), chkbtn); \ +} + +#define PACK_SMALL_LABEL(box, label, str) \ +{ \ + label = gtk_label_new(str); \ + gtk_widget_show(label); \ + gtk_box_pack_start(GTK_BOX(box), label, FALSE, TRUE, 0); \ + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); \ + gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); \ + gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); \ + gtkut_widget_set_small_font_size(label); \ +} + +#define PACK_VSPACER(box, vbox, spacing) \ +{ \ + vbox = gtk_vbox_new(FALSE, 0); \ + gtk_widget_show(vbox); \ + gtk_box_pack_start(GTK_BOX(box), vbox, FALSE, TRUE, spacing); \ +} + +#define SET_TOGGLE_SENSITIVITY(togglewid, targetwid) \ +{ \ + gtk_widget_set_sensitive(targetwid, FALSE); \ + g_signal_connect(G_OBJECT(togglewid), "toggled", \ + G_CALLBACK(prefs_button_toggled), targetwid); \ +} + +void prefs_dialog_create (PrefsDialog *dialog); +void prefs_dialog_destroy (PrefsDialog *dialog); + +void prefs_button_toggled (GtkToggleButton *toggle_btn, + GtkWidget *widget); + +void prefs_set_dialog (PrefParam *param); +void prefs_set_data_from_dialog (PrefParam *param); +void prefs_set_dialog_to_default(PrefParam *param); + +void prefs_set_data_from_entry (PrefParam *pparam); +void prefs_set_entry (PrefParam *pparam); +void prefs_set_data_from_text (PrefParam *pparam); +void prefs_set_text (PrefParam *pparam); +void prefs_set_data_from_toggle (PrefParam *pparam); +void prefs_set_toggle (PrefParam *pparam); +void prefs_set_data_from_spinbtn(PrefParam *pparam); +void prefs_set_spinbtn (PrefParam *pparam); +void prefs_set_data_from_fontbtn(PrefParam *pparam); +void prefs_set_fontbtn (PrefParam *pparam); + +#endif /* __PREFS_UI_H__ */ diff --git a/src/summaryview.c b/src/summaryview.c index dfd58ede..6e83b6fe 100644 --- a/src/summaryview.c +++ b/src/summaryview.c @@ -30,7 +30,6 @@ #include <gtk/gtkcellrendererpixbuf.h> #include <gtk/gtkcellrenderertext.h> #include <gtk/gtksignal.h> -#include <gtk/gtktext.h> #include <gtk/gtkmenu.h> #include <gtk/gtkmenuitem.h> #include <gtk/gtkcheckmenuitem.h> @@ -42,6 +41,7 @@ #include <gtk/gtkeventbox.h> #include <gtk/gtkstatusbar.h> #include <gtk/gtkstock.h> +#include <gtk/gtknotebook.h> #include <stdio.h> #include <stdlib.h> |