- g_return_if_fail(date_format_list != NULL);
-
- /* only on double click */
- if (event->type != GDK_2BUTTON_PRESS)
- return;
-
- /* get format from clist */
- gtk_clist_get_text(GTK_CLIST(date_format_list), row, 0, &format);
-
- curs_pos = gtk_editable_get_position(GTK_EDITABLE(datefmt_sample));
- old_format = gtk_entry_get_text(GTK_ENTRY(datefmt_sample));
-
- /* insert the format into the text entry */
- new_format = g_malloc(strlen(old_format) + 3);
-
- strncpy(new_format, old_format, curs_pos);
- new_format[curs_pos] = '\0';
- strcat(new_format, format);
- strcat(new_format, &old_format[curs_pos]);
-
- gtk_entry_set_text(GTK_ENTRY(datefmt_sample), new_format);
- gtk_editable_set_position(GTK_EDITABLE(datefmt_sample), curs_pos + 2);
-
- g_free(new_format);
-}
-
-static GtkWidget *create_date_format(GtkButton *button, void *data)
-{
- static GtkWidget *date_format = NULL;
- GtkWidget *vbox1;
- GtkWidget *scrolledwindow1;
- GtkWidget *date_format_list;
- GtkWidget *label3;
- GtkWidget *label4;
- GtkWidget *table2;
- GtkWidget *vbox2;
- GtkWidget *vbox3;
- GtkWidget *hbox2;
- GtkWidget *label5;
- GtkWidget *hbox1;
- GtkWidget *label6;
- GtkWidget *label7;
- GtkWidget *confirm_area;
- GtkWidget *ok_btn;
- GtkWidget *cancel_btn;
-
- const struct {
- gchar *fmt;
- gchar *txt;
- } time_format[] = {
- { "%a", _("the full abbreviated weekday name") },
- { "%A", _("the full weekday name") },
- { "%b", _("the abbreviated month name") },
- { "%B", _("the full month name") },
- { "%c", _("the preferred date and time for the current locale") },
- { "%C", _("the century number (year/100)") },
- { "%d", _("the day of the month as a decimal number") },
- { "%H", _("the hour as a decimal number using a 24-hour clock") },
- { "%I", _("the hour as a decimal number using a 12-hour clock") },
- { "%j", _("the day of the year as a decimal number") },
- { "%m", _("the month as a decimal number") },
- { "%M", _("the minute as a decimal number") },
- { "%p", _("either AM or PM") },
- { "%S", _("the second as a decimal number") },
- { "%w", _("the day of the week as a decimal number") },
- { "%x", _("the preferred date for the current locale") },
- { "%y", _("the last two digits of a year") },
- { "%Y", _("the year as a decimal number") },
- { "%Z", _("the time zone or name or abbreviation") }
- };
- int tmp;
- const int TIME_FORMAT_ELEMS = sizeof time_format / sizeof time_format[0];
-
- if (date_format) return date_format;
-
- date_format = gtk_window_new(GTK_WINDOW_DIALOG);
- gtk_window_set_title(GTK_WINDOW(date_format), _("Date format"));
- gtk_window_set_position(GTK_WINDOW(date_format), GTK_WIN_POS_CENTER);
- gtk_window_set_default_size(GTK_WINDOW(date_format), 440, 280);
-
- vbox1 = gtk_vbox_new(FALSE, 10);
- gtk_widget_show(vbox1);
- gtk_container_add(GTK_CONTAINER(date_format), vbox1);
-
- scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
- gtk_widget_show(scrolledwindow1);
- gtk_box_pack_start(GTK_BOX(vbox1), scrolledwindow1, TRUE, TRUE, 0);
-
- date_format_list = gtk_clist_new(2);
- gtk_widget_show(date_format_list);
- gtk_container_add(GTK_CONTAINER(scrolledwindow1), date_format_list);
- gtk_clist_set_column_width(GTK_CLIST(date_format_list), 0, 80);
- gtk_clist_set_column_width(GTK_CLIST(date_format_list), 1, 80);
- gtk_clist_column_titles_show(GTK_CLIST(date_format_list));
-
- label3 = gtk_label_new(_("Date Format"));
- gtk_widget_show(label3);
- gtk_clist_set_column_widget(GTK_CLIST(date_format_list), 0, label3);
-
- label4 = gtk_label_new(_("Date Format Description"));
- gtk_widget_show(label4);
- gtk_clist_set_column_widget(GTK_CLIST(date_format_list), 1, label4);
-
- for (tmp = 0; tmp < TIME_FORMAT_ELEMS; tmp++) {
- gchar *text[3];
- /* phoney casting necessary because of gtk... */
- text[0] = (gchar *) time_format[tmp].fmt;
- text[1] = (gchar *) time_format[tmp].txt;
- text[2] = NULL;
- gtk_clist_append(GTK_CLIST(date_format_list), text);
- }
-
- table2 = gtk_table_new(1, 1, TRUE);
- gtk_widget_show(table2);
- gtk_box_pack_start(GTK_BOX(vbox1), table2, FALSE, TRUE, 0);
-
- vbox2 = gtk_vbox_new(FALSE, 0);
- gtk_widget_show(vbox2);
- gtk_table_attach(GTK_TABLE(table2), vbox2, 0, 1, 0, 1,
- (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0);
-
- vbox3 = gtk_vbox_new(TRUE, 4);
- gtk_widget_show(vbox3);
- gtk_box_pack_end(GTK_BOX(vbox2), vbox3, FALSE, FALSE, 10);
-
- hbox2 = gtk_hbox_new(FALSE, 0);
- gtk_widget_show(hbox2);
- gtk_box_pack_start(GTK_BOX(vbox3), hbox2, TRUE, TRUE, 0);
-
- label5 = gtk_label_new(_("Date format"));
- gtk_widget_show(label5);
- gtk_box_pack_start(GTK_BOX(hbox2), label5, FALSE, FALSE, 0);
- gtk_misc_set_padding(GTK_MISC(label5), 8, 0);
-
- datefmt_sample = gtk_entry_new_with_max_length(300);
- gtk_widget_show(datefmt_sample);
- gtk_box_pack_start(GTK_BOX(hbox2), datefmt_sample, TRUE, TRUE, 40);
-
- hbox1 = gtk_hbox_new(FALSE, 0);
- gtk_widget_show(hbox1);
- gtk_box_pack_start(GTK_BOX(vbox3), hbox1, TRUE, TRUE, 0);
-
- label6 = gtk_label_new(_("Example"));
- gtk_widget_show(label6);
- gtk_box_pack_start(GTK_BOX(hbox1), label6, FALSE, TRUE, 0);
- gtk_misc_set_padding(GTK_MISC(label6), 8, 0);
-
- label7 = gtk_label_new(_("label7"));
- gtk_widget_show(label7);
- gtk_box_pack_start(GTK_BOX(hbox1), label7, TRUE, TRUE, 60);
- gtk_label_set_justify(GTK_LABEL(label7), GTK_JUSTIFY_LEFT);
-
- gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
- &cancel_btn, _("Cancel"), NULL, NULL);
- gtk_widget_grab_default(ok_btn);
-
- gtk_widget_show(confirm_area);
-
- gtk_box_pack_start(GTK_BOX(vbox1), confirm_area, FALSE, FALSE, 0);
-
- /* set the current format */
- gtk_entry_set_text(GTK_ENTRY(datefmt_sample), prefs_common.date_format);
- date_format_entry_on_change(GTK_EDITABLE(datefmt_sample),
- GTK_LABEL(label7));
-
- gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked",
- GTK_SIGNAL_FUNC(date_format_ok_btn_clicked),
- &date_format);
-
- gtk_signal_connect(GTK_OBJECT(cancel_btn), "clicked",
- GTK_SIGNAL_FUNC(date_format_cancel_btn_clicked),
- &date_format);
-
- gtk_signal_connect(GTK_OBJECT(date_format), "delete_event",
- GTK_SIGNAL_FUNC(date_format_on_delete),
- &date_format);
-
- gtk_signal_connect(GTK_OBJECT(datefmt_sample), "changed",
- GTK_SIGNAL_FUNC(date_format_entry_on_change),
- label7);
-
- gtk_window_set_position(GTK_WINDOW(date_format), GTK_WIN_POS_CENTER);
- gtk_window_set_modal(GTK_WINDOW(date_format), TRUE);
-
- gtk_widget_show(date_format);
-
- gtk_signal_connect(GTK_OBJECT(date_format_list), "select_row",
- GTK_SIGNAL_FUNC(date_format_select_row),
- &datefmt_sample);
-
- return date_format;
-}
-
-static void prefs_display_create(void)
-{
- GtkWidget *vbox1;
- GtkWidget *frame_font;
- GtkWidget *table1;
- GtkWidget *label_textfont;
- GtkWidget *entry_textfont;
- GtkWidget *button_textfont;
- GtkWidget *chkbtn_folder_unread;
- GtkWidget *chkbtn_transhdr;
- GtkWidget *frame_summary;
- GtkWidget *vbox2;
- GtkWidget *chkbtn_swapfrom;
- GtkWidget *chkbtn_hscrollbar;
- GtkWidget *chkbtn_useaddrbook;
- GtkWidget *hbox1;
- GtkWidget *label_datefmt;
- GtkWidget *label_datefmt_btn;
- GtkWidget *button_dispitem;
- GtkWidget *tmplabel, *tmpentry, *tmpbutton;
-
- vbox1 = gtk_vbox_new (FALSE, VSPACING);
- gtk_widget_show (vbox1);
- gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
- gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
-
- PACK_FRAME(vbox1, frame_font, _("Font"));
-
- table1 = gtk_table_new (4, 3, FALSE);
- gtk_widget_show (table1);
- gtk_container_add (GTK_CONTAINER (frame_font), table1);
- gtk_container_set_border_width (GTK_CONTAINER (table1), 8);
- gtk_table_set_row_spacings (GTK_TABLE (table1), 8);
- gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
-
- label_textfont = gtk_label_new (_("Text"));
- gtk_widget_show (label_textfont);
- gtk_table_attach (GTK_TABLE (table1), label_textfont, 0, 1, 0, 1,
- GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);
-
- entry_textfont = gtk_entry_new ();
- gtk_widget_show (entry_textfont);
- gtk_table_attach (GTK_TABLE (table1), entry_textfont, 1, 2, 0, 1,
- (GTK_EXPAND | GTK_FILL), 0, 0, 0);
-
- button_textfont = gtk_button_new_with_label ("... ");
- gtk_widget_show (button_textfont);
- gtk_table_attach (GTK_TABLE (table1), button_textfont, 2, 3, 0, 1,
- 0, 0, 0, 0);
- gtk_signal_connect (GTK_OBJECT (button_textfont), "clicked",
- GTK_SIGNAL_FUNC (prefs_font_select), entry_textfont);
-
- tmplabel = gtk_label_new (_("Small"));
- gtk_widget_show (tmplabel);
- gtk_table_attach (GTK_TABLE (table1), tmplabel, 0, 1, 1, 2,
- GTK_FILL, (GTK_EXPAND | GTK_FILL), 0, 0);