2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2004 Hiroyuki Yamamoto
4 * This file (C) 2004 Colin Leroy
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 #include <glib/gi18n.h>
29 #include <gdk/gdkkeysyms.h>
30 #include <gtk/gtkwidget.h>
31 #include <gtk/gtkvbox.h>
32 #include <gtk/gtkbox.h>
33 #include <gtk/gtktable.h>
34 #include <gtk/gtkentry.h>
35 #include <gtk/gtklabel.h>
36 #include <gtk/gtknotebook.h>
37 #include <gtk/gtktogglebutton.h>
38 #include <gtk/gtkcheckbutton.h>
53 #include "prefs_account.h"
54 #include "mainwindow.h"
55 #include "stock_pixmap.h"
61 #include "prefs_common.h"
81 GtkWidget *organization;
83 GtkWidget *mailbox_name;
85 GtkWidget *smtp_server;
88 GtkWidget *recv_label;
89 GtkWidget *recv_server;
90 GtkWidget *recv_username;
91 GtkWidget *recv_password;
92 GtkWidget *recv_username_label;
93 GtkWidget *recv_password_label;
94 GtkWidget *recv_imap_label;
95 GtkWidget *recv_imap_subdir;
98 GtkWidget *smtp_use_ssl;
99 GtkWidget *recv_use_ssl;
102 gboolean create_mailbox;
108 static void initialize_fonts(WizardWindow *wizard)
110 GtkWidget *widget = wizard->email;
111 gint size = pango_font_description_get_size(
112 widget->style->font_desc)
116 tmp = g_strdup(prefs_common.textfont);
117 if (strrchr(tmp, ' ')) {
118 *(strrchr(tmp, ' ')) = '\0';
119 new = g_strdup_printf("%s %d", tmp, size);
120 g_free(prefs_common.textfont);
121 prefs_common.textfont = new;
125 tmp = g_strdup(prefs_common.smallfont);
126 if (strrchr(tmp, ' ')) {
127 *(strrchr(tmp, ' ')) = '\0';
128 new = g_strdup_printf("%s %d", tmp, size);
129 g_free(prefs_common.smallfont);
130 prefs_common.smallfont = new;
134 tmp = g_strdup(prefs_common.normalfont);
135 if (strrchr(tmp, ' ')) {
136 *(strrchr(tmp, ' ')) = '\0';
137 new = g_strdup_printf("%s %d", tmp, size);
138 g_free(prefs_common.normalfont);
139 prefs_common.normalfont = new;
144 #define XFACE "+}Axz@~a,-Yx?0Ysa|q}CLRH=89Y]\"')DSX^<6p\"d)'81yx5%G#u^o*7JG&[aPU0h1Ux.vb2yIjH83{5`/bVo|~nn/i83vE^E)qk-4W)_E.4Y=D*qvf/,Ci_=P<iY<M6"
146 static void write_welcome_email(WizardWindow *wizard)
153 const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name));
154 Folder *folder = folder_find_from_path(mailbox);
155 FolderItem *inbox = folder ? folder->inbox:NULL;
156 gchar *file = get_tmp_file();
158 get_rfc822_date(buf_date, sizeof(buf_date));
160 subj = g_strdup_printf(_("Welcome to Sylpheed-Claws"));
162 head = g_strdup_printf(
163 "From: %s <sylpheed-claws-users@lists.sf.net>\n"
168 "Content-Type: text/plain; charset=UTF-8\n",
169 _("Sylpheed-Claws Team"),
170 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)),
171 gtk_entry_get_text(GTK_ENTRY(wizard->email)),
172 buf_date, subj, XFACE);
173 body = g_strdup_printf(
175 "Welcome to Sylpheed-Claws\n"
176 "-------------------------\n"
178 "Now that you have set up your account you can fetch your\n"
179 "mail by clicking the 'Get Mail' button at the left of the\n"
182 "You can change your Account Preferences by using the menu\n"
183 "entry '/Configuration/Preferences for current account'\n"
184 "and change the general Preferences by using\n"
185 "'/Configuration/Preferences'.\n"
187 "You can find further information in the Sylpheed-Claws manual,\n"
188 "which can be accessed by using the menu entry '/Help/Manual'\n"
189 "or online at the URL given below.\n"
197 "Mailing Lists: <%s>\n"
201 "Sylpheed-Claws is free software, released under the terms\n"
202 "of the GNU General Public License, version 2 or later, as\n"
203 "published by the Free Software Foundation, 51 Franklin Street,\n"
204 "Fifth Floor, Boston, MA 02110-1301, USA. The license can be\n"
209 "If you wish to donate to the Sylpheed-Claws project you can do\n"
211 HOMEPAGE_URI, MANUAL_URI, FAQ_URI, THEMES_URI, MAILING_LIST_URI,
212 GPL_URI, DONATE_URI);
214 msg = g_strconcat(head, body, NULL);
216 if (inbox && inbox->total_msgs == 0
217 && str_write_to_file(msg, file) >= 0) {
218 MsgFlags flags = { MSG_UNREAD|MSG_NEW, 0};
219 folder_item_add_msg(inbox, file, &flags, FALSE);
229 static gboolean wizard_write_config(WizardWindow *wizard)
231 gboolean mailbox_ok = FALSE;
232 PrefsAccount *prefs_account = prefs_account_new();
233 GList *account_list = NULL;
234 GtkWidget *menu, *menuitem;
236 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(wizard->recv_type));
237 menuitem = gtk_menu_get_active(GTK_MENU(menu));
238 prefs_account->protocol = GPOINTER_TO_INT
239 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
241 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
242 mailbox_ok = setup_write_mailbox_path(wizard->mainwin,
243 gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
248 gtk_notebook_set_current_page (
249 GTK_NOTEBOOK(wizard->notebook),
254 if (prefs_account->protocol != A_LOCAL)
255 prefs_account->account_name = g_strdup_printf("%s@%s",
256 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)),
257 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
259 prefs_account->account_name = g_strdup_printf("%s",
260 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
262 prefs_account->name = g_strdup(
263 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)));
264 prefs_account->address = g_strdup(
265 gtk_entry_get_text(GTK_ENTRY(wizard->email)));
266 prefs_account->organization = g_strdup(
267 gtk_entry_get_text(GTK_ENTRY(wizard->organization)));
268 prefs_account->smtp_server = g_strdup(
269 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)));
271 if (prefs_account->protocol != A_LOCAL)
272 prefs_account->recv_server = g_strdup(
273 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
275 prefs_account->local_mbox = g_strdup(
276 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
278 prefs_account->userid = g_strdup(
279 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)));
280 prefs_account->passwd = g_strdup(
281 gtk_entry_get_text(GTK_ENTRY(wizard->recv_password)));
284 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl)))
285 prefs_account->ssl_smtp = SSL_TUNNEL;
286 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl))) {
287 if (prefs_account->protocol == A_IMAP4)
288 prefs_account->ssl_imap = SSL_TUNNEL;
290 prefs_account->ssl_pop = SSL_TUNNEL;
293 if (prefs_account->protocol == A_IMAP4) {
294 gchar *directory = gtk_editable_get_chars(
295 GTK_EDITABLE(wizard->recv_imap_subdir), 0, -1);
296 if (directory && strlen(directory)) {
297 prefs_account->imap_dir = g_strdup(directory);
302 account_list = g_list_append(account_list, prefs_account);
303 prefs_account_write_config_all(account_list);
304 prefs_account_free(prefs_account);
305 account_read_config_all();
307 initialize_fonts(wizard);
308 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4)
309 write_welcome_email(wizard);
314 static GtkWidget* create_page (WizardWindow *wizard, const char * title)
322 vbox = gtk_vbox_new (FALSE, 6);
323 gtk_container_set_border_width (GTK_CONTAINER(vbox), 10);
325 /* create the titlebar */
326 hbox = gtk_hbox_new (FALSE, 12);
327 image = stock_pixmap_widget(wizard->window,
328 STOCK_PIXMAP_SYLPHEED_ICON);
329 gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 0);
330 title_string = g_strconcat ("<span size=\"xx-large\" weight=\"ultrabold\">", title ? title : "", "</span>", NULL);
331 w = gtk_label_new (title_string);
332 gtk_label_set_use_markup (GTK_LABEL(w), TRUE);
333 g_free (title_string);
334 gtk_box_pack_start (GTK_BOX(hbox), w, FALSE, FALSE, 0);
336 /* pack the titlebar */
337 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
339 /* pack the separator */
340 gtk_box_pack_start (GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
343 w = gtk_alignment_new (0, 0, 0, 0);
344 gtk_widget_set_size_request (w, 0, 6);
345 gtk_box_pack_start (GTK_BOX(vbox), w, FALSE, FALSE, 0);
350 #define GTK_TABLE_ADD_ROW_AT(table,text,entry,i) { \
351 GtkWidget *label = gtk_label_new(text); \
352 gtk_table_attach(GTK_TABLE(table), label, \
353 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0); \
354 if (GTK_IS_MISC(label)) \
355 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); \
356 gtk_table_attach(GTK_TABLE(table), entry, \
357 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0); \
360 static gchar *get_default_email_addr(void)
362 gchar *domain_name = g_strdup(get_domain_name());
364 if (strchr(domain_name, '.') != strrchr(domain_name, '.')
365 && strlen(strchr(domain_name, '.')) > 6) {
366 gchar *tmp = g_strdup(strchr(domain_name, '.')+1);
370 result = g_strdup_printf("%s@%s",
377 static gchar *get_default_server(WizardWindow * wizard, const gchar *type)
379 gchar *domain_name = NULL;
380 gchar *tmp = gtk_editable_get_chars(
381 GTK_EDITABLE(wizard->email), 0, -1);
384 if (strstr(tmp, "@")) {
385 domain_name = g_strdup(strstr(tmp,"@")+1);
387 domain_name = g_strdup(get_domain_name());
392 result = g_strdup_printf("%s.%s",
398 static gchar *get_default_account(WizardWindow * wizard)
400 gchar *result = gtk_editable_get_chars(
401 GTK_EDITABLE(wizard->email), 0, -1);
403 if (strstr(result, "@")) {
404 *(strstr(result,"@")) = '\0';
410 static void wizard_email_changed(GtkWidget *widget, gpointer data)
412 WizardWindow *wizard = (WizardWindow *)data;
413 RecvProtocol protocol;
415 protocol = GPOINTER_TO_INT
416 (g_object_get_data(G_OBJECT(wizard->recv_type), MENU_VAL_ID));
418 text = get_default_server(wizard, "smtp");
419 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
422 text = get_default_account(wizard);
423 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
426 if (protocol == A_POP3) {
427 text = get_default_server(wizard, "pop");
428 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
430 } else if (protocol == A_IMAP4) {
431 text = get_default_server(wizard, "imap");
432 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
434 } else if (protocol == A_LOCAL) {
435 gchar *mbox = g_strdup_printf("/var/mail/%s", g_get_user_name());
436 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), mbox);
442 static GtkWidget* user_page (WizardWindow * wizard)
444 GtkWidget *table = gtk_table_new(3,2, FALSE);
448 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
449 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
451 wizard->full_name = gtk_entry_new();
452 gtk_entry_set_text(GTK_ENTRY(wizard->full_name), g_get_real_name());
453 GTK_TABLE_ADD_ROW_AT(table, _("Your name:"),
454 wizard->full_name, i); i++;
456 wizard->email = gtk_entry_new();
457 text = get_default_email_addr();
458 gtk_entry_set_text(GTK_ENTRY(wizard->email), text);
460 GTK_TABLE_ADD_ROW_AT(table, _("Your email address:"),
461 wizard->email, i); i++;
463 wizard->organization = gtk_entry_new();
464 GTK_TABLE_ADD_ROW_AT(table, _("Your organization:"),
465 wizard->organization, i); i++;
467 g_signal_connect(G_OBJECT(wizard->email), "changed",
468 G_CALLBACK(wizard_email_changed),
473 static GtkWidget* mailbox_page (WizardWindow * wizard)
475 GtkWidget *table = gtk_table_new(1,2, FALSE);
478 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
479 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
481 wizard->mailbox_name = gtk_entry_new();
482 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), "Mail");
483 GTK_TABLE_ADD_ROW_AT(table, _("Mailbox name:"),
484 wizard->mailbox_name, i); i++;
489 static GtkWidget* smtp_page (WizardWindow * wizard)
491 GtkWidget *table = gtk_table_new(1,2, FALSE);
495 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
496 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
498 wizard->smtp_server = gtk_entry_new();
499 text = get_default_server(wizard, "smtp");
500 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
502 GTK_TABLE_ADD_ROW_AT(table, _("SMTP server address:"),
503 wizard->smtp_server, i); i++;
507 static void wizard_protocol_changed(GtkMenuItem *menuitem, gpointer data)
509 WizardWindow *wizard = (WizardWindow *)data;
510 RecvProtocol protocol;
512 protocol = GPOINTER_TO_INT
513 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
515 if (protocol == A_POP3) {
516 text = get_default_server(wizard, "pop");
517 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
518 gtk_widget_hide(wizard->recv_imap_label);
519 gtk_widget_hide(wizard->recv_imap_subdir);
520 gtk_widget_show(wizard->recv_username);
521 gtk_widget_show(wizard->recv_password);
522 gtk_widget_show(wizard->recv_username_label);
523 gtk_widget_show(wizard->recv_password_label);
524 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("Server address:"));
526 } else if (protocol == A_IMAP4) {
527 text = get_default_server(wizard, "imap");
528 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
529 gtk_widget_show(wizard->recv_imap_label);
530 gtk_widget_show(wizard->recv_imap_subdir);
531 gtk_widget_show(wizard->recv_username);
532 gtk_widget_show(wizard->recv_password);
533 gtk_widget_show(wizard->recv_username_label);
534 gtk_widget_show(wizard->recv_password_label);
535 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("Server address:"));
537 } else if (protocol == A_LOCAL) {
538 gchar *mbox = g_strdup_printf("/var/mail/%s", g_get_user_name());
539 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), mbox);
541 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("Local mailbox:"));
542 gtk_widget_hide(wizard->recv_imap_label);
543 gtk_widget_hide(wizard->recv_imap_subdir);
544 gtk_widget_hide(wizard->recv_username);
545 gtk_widget_hide(wizard->recv_password);
546 gtk_widget_hide(wizard->recv_username_label);
547 gtk_widget_hide(wizard->recv_password_label);
551 static GtkWidget* recv_page (WizardWindow * wizard)
553 GtkWidget *table = gtk_table_new(5,2, FALSE);
554 GtkWidget *menu = gtk_menu_new();
559 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
560 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
562 wizard->recv_type = gtk_option_menu_new();
564 MENUITEM_ADD (menu, menuitem, _("POP3"), A_POP3);
565 g_signal_connect(G_OBJECT(menuitem), "activate",
566 G_CALLBACK(wizard_protocol_changed),
568 MENUITEM_ADD (menu, menuitem, _("IMAP"), A_IMAP4);
569 g_signal_connect(G_OBJECT(menuitem), "activate",
570 G_CALLBACK(wizard_protocol_changed),
572 MENUITEM_ADD (menu, menuitem, _("Local mbox file"), A_LOCAL);
573 g_signal_connect(G_OBJECT(menuitem), "activate",
574 G_CALLBACK(wizard_protocol_changed),
577 gtk_option_menu_set_menu (GTK_OPTION_MENU (wizard->recv_type), menu);
578 GTK_TABLE_ADD_ROW_AT(table, _("Server type:"),
579 wizard->recv_type, i); i++;
581 wizard->recv_server = gtk_entry_new();
582 text = get_default_server(wizard, "pop");
583 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
586 wizard->recv_label = gtk_label_new(_("Server address:"));
587 gtk_table_attach(GTK_TABLE(table), wizard->recv_label,
588 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
589 if (GTK_IS_MISC(wizard->recv_label))
590 gtk_misc_set_alignment(GTK_MISC(wizard->recv_label), 1, 0.5);
591 gtk_table_attach(GTK_TABLE(table), wizard->recv_server,
592 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
595 wizard->recv_username = gtk_entry_new();
596 wizard->recv_username_label = gtk_label_new(_("Username:"));
597 gtk_table_attach(GTK_TABLE(table), wizard->recv_username_label,
598 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
599 if (GTK_IS_MISC(wizard->recv_username_label))
600 gtk_misc_set_alignment(GTK_MISC(wizard->recv_username_label), 1, 0.5);
601 gtk_table_attach(GTK_TABLE(table), wizard->recv_username,
602 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
605 text = get_default_account(wizard);
606 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
609 wizard->recv_password = gtk_entry_new();
610 wizard->recv_password_label = gtk_label_new(_("Password:"));
611 gtk_table_attach(GTK_TABLE(table), wizard->recv_password_label,
612 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
613 if (GTK_IS_MISC(wizard->recv_password_label))
614 gtk_misc_set_alignment(GTK_MISC(wizard->recv_password_label), 1, 0.5);
615 gtk_table_attach(GTK_TABLE(table), wizard->recv_password,
616 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
617 gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_password), FALSE);
620 wizard->recv_imap_subdir = gtk_entry_new();
621 wizard->recv_imap_label = gtk_label_new(_("IMAP server directory:"));
623 gtk_table_attach(GTK_TABLE(table), wizard->recv_imap_label,
624 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
625 if (GTK_IS_MISC(wizard->recv_imap_label))
626 gtk_misc_set_alignment(GTK_MISC(wizard->recv_imap_label), 1, 0.5);
627 gtk_table_attach(GTK_TABLE(table), wizard->recv_imap_subdir,
628 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
636 static GtkWidget* ssl_page (WizardWindow * wizard)
638 GtkWidget *table = gtk_table_new(2,2, FALSE);
641 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
642 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
644 wizard->smtp_use_ssl = gtk_check_button_new_with_label(
645 _("Use SSL to connect to SMTP server"));
646 gtk_table_attach(GTK_TABLE(table), wizard->smtp_use_ssl,
647 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0); i++;
649 wizard->recv_use_ssl = gtk_check_button_new_with_label(
650 _("Use SSL to connect to receiving server"));
651 gtk_table_attach(GTK_TABLE(table), wizard->recv_use_ssl,
652 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
659 wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
661 WizardWindow * wizard = (WizardWindow *)data;
662 int current_page, num_pages;
663 GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(wizard->recv_type));
664 GtkWidget *menuitem = gtk_menu_get_active(GTK_MENU(menu));
665 gint protocol = GPOINTER_TO_INT
666 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
667 gboolean skip_mailbox_page = FALSE;
669 if (protocol == A_IMAP4) {
670 skip_mailbox_page = TRUE;
673 num_pages = g_slist_length(wizard->pages);
675 current_page = gtk_notebook_get_current_page (
676 GTK_NOTEBOOK(wizard->notebook));
677 if (response == CANCEL)
679 wizard->result = FALSE;
680 wizard->finished = TRUE;
681 gtk_widget_destroy (GTK_WIDGET(dialog));
683 else if (response == FINISHED)
685 if (!wizard_write_config(wizard)) {
686 current_page = gtk_notebook_get_current_page (
687 GTK_NOTEBOOK(wizard->notebook));
690 wizard->result = TRUE;
691 wizard->finished = TRUE;
692 gtk_widget_destroy (GTK_WIDGET(dialog));
696 if (response == GO_BACK)
698 if (current_page > 0) {
700 if (current_page == 4 && skip_mailbox_page) {
704 gtk_notebook_set_current_page (
705 GTK_NOTEBOOK(wizard->notebook),
709 else if (response == GO_FORWARD)
711 if (current_page < (num_pages-1)) {
713 if (current_page == 4 && skip_mailbox_page) {
717 gtk_notebook_set_current_page (
718 GTK_NOTEBOOK(wizard->notebook),
723 gtk_dialog_set_response_sensitive (dialog, GO_BACK,
725 gtk_dialog_set_response_sensitive (dialog, GO_FORWARD,
726 current_page < (num_pages - 1));
727 gtk_dialog_set_response_sensitive (dialog, FINISHED,
728 current_page == (num_pages - 1));
732 static gint wizard_close_cb(GtkWidget *widget, GdkEventAny *event,
735 WizardWindow *wizard = (WizardWindow *)data;
736 wizard->result = FALSE;
737 wizard->finished = TRUE;
742 gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
743 WizardWindow *wizard = g_new0(WizardWindow, 1);
750 wizard->mainwin = mainwin;
751 wizard->create_mailbox = create_mailbox;
753 gtk_widget_hide(mainwin->window);
755 wizard->window = gtk_dialog_new_with_buttons (_("Sylpheed-Claws Setup Wizard"),
757 GTK_STOCK_GO_BACK, GO_BACK,
758 GTK_STOCK_GO_FORWARD, GO_FORWARD,
759 GTK_STOCK_SAVE, FINISHED,
760 GTK_STOCK_CANCEL, CANCEL,
763 g_signal_connect(wizard->window, "response",
764 G_CALLBACK(wizard_response_cb), wizard);
765 gtk_widget_realize(wizard->window);
766 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window),
768 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
770 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
772 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
774 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
777 wizard->notebook = gtk_notebook_new();
778 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(wizard->notebook), FALSE);
779 gtk_notebook_set_show_border(GTK_NOTEBOOK(wizard->notebook), FALSE);
780 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(wizard->window)->vbox),
781 wizard->notebook, TRUE, TRUE, 0);
783 wizard->pages = NULL;
786 page = create_page(wizard, _("Welcome to Sylpheed-Claws"));
788 wizard->pages = g_slist_append(wizard->pages, page);
789 widget = stock_pixmap_widget(wizard->window,
790 STOCK_PIXMAP_SYLPHEED_LOGO);
792 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
794 text = g_strdup(_("Welcome to the Sylpheed-Claws setup wizard.\n\n"
795 "We will begin by defining some basic "
796 "information about you and your most common "
797 "mail options so that you can start to use "
798 "Sylpheed-Claws in less than five minutes."));
799 widget = gtk_label_new(text);
800 gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
801 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
805 widget = create_page (wizard, _("About You"));
806 gtk_box_pack_start (GTK_BOX(widget), user_page(wizard), FALSE, FALSE, 0);
807 wizard->pages = g_slist_append(wizard->pages, widget);
810 widget = create_page (wizard, _("Sending mail"));
811 gtk_box_pack_start (GTK_BOX(widget), smtp_page(wizard), FALSE, FALSE, 0);
812 wizard->pages = g_slist_append(wizard->pages, widget);
814 /* recv+auth page: 3 */
815 widget = create_page (wizard, _("Receiving mail"));
816 gtk_box_pack_start (GTK_BOX(widget), recv_page(wizard), FALSE, FALSE, 0);
817 wizard->pages = g_slist_append(wizard->pages, widget);
819 /* mailbox page: 4 */
820 if (create_mailbox) {
821 widget = create_page (wizard, _("Saving mail on disk"));
822 gtk_box_pack_start (GTK_BOX(widget), mailbox_page(wizard), FALSE, FALSE, 0);
823 wizard->pages = g_slist_append(wizard->pages, widget);
827 widget = create_page (wizard, _("Security"));
828 gtk_box_pack_start (GTK_BOX(widget), ssl_page(wizard), FALSE, FALSE, 0);
829 wizard->pages = g_slist_append(wizard->pages, widget);
833 page = create_page(wizard, _("Configuration finished"));
835 wizard->pages = g_slist_append(wizard->pages, page);
836 widget = stock_pixmap_widget(wizard->window,
837 STOCK_PIXMAP_SYLPHEED_LOGO);
839 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
841 text = g_strdup(_("Sylpheed-Claws is now ready.\n\n"
842 "Click Save to start."));
843 widget = gtk_label_new(text);
844 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
848 for (cur = wizard->pages; cur && cur->data; cur = cur->next) {
849 gtk_notebook_append_page (GTK_NOTEBOOK(wizard->notebook),
850 GTK_WIDGET(cur->data), NULL);
853 g_signal_connect(G_OBJECT(wizard->window), "delete_event",
854 G_CALLBACK(wizard_close_cb), wizard);
855 gtk_widget_show_all (wizard->window);
857 gtk_widget_hide(wizard->recv_imap_label);
858 gtk_widget_hide(wizard->recv_imap_subdir);
860 while (!wizard->finished)
861 gtk_main_iteration();
863 result = wizard->result;
867 gtk_widget_show(mainwin->window);