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 static void write_welcome_email(WizardWindow *wizard)
148 const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name));
149 Folder *folder = folder_find_from_path(mailbox);
150 FolderItem *inbox = folder ? folder->inbox:NULL;
151 gchar *file = get_tmp_file();
153 get_rfc822_date(buf_date, sizeof(buf_date));
155 body = g_strdup_printf(
156 "From: Sylpheed-Claws Team <sylpheed-claws-users@lists.sf.net>\n"
159 "Subject: Welcome to Sylpheed-Claws.\n"
161 "Welcome to Sylpheed-Claws\n"
162 "-------------------------\n"
164 "Now that you have set up your account you can fetch your\n"
165 "mail by clicking the 'Get All' button at the left of the\n"
168 "You can change your Account Preferences by using the menu\n"
169 "entry '/Configuration/Preferences for current account'\n"
170 "and change the general Preferences by using\n"
171 "'/Configuration/Preferences'.\n"
173 "You can find futher information in the Sylpheed-Claws manual,\n"
174 "which can be accessed by using the menu entry '/Help/Manual'\n"
175 "or online at the URL given below.\n"
179 "Homepage: <http://claws.sylpheed.org>\n"
180 "Manual: <http://claws.sylpheed.org/manual/>\n"
181 "FAQ: <http://claws.sylpheed.org/faq.php>\n"
182 "Themes: <http://claws.sylpheed.org/themes.php>\n"
183 "Mailing Lists: <http://claws.sylpheed.org/MLs.php>\n"
187 "Sylpheed-Claws is free software, released under the terms\n"
188 "of the GNU General Public License, version 2 or later, as\n"
189 "published by the Free Software Foundation, 51 Franklin Street,\n"
190 "Fifth Floor, Boston, MA 02110-1301, USA. The license can be\n"
191 "found at <http://www.gnu.org/licenses/gpl.html>.\n"
195 "If you wish to donate to the Sylpheed-Claws project you can do\n"
196 "so at <https://sourceforge.net/donate/index.php?group_id=25528>.",
197 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)),
198 gtk_entry_get_text(GTK_ENTRY(wizard->email)),
201 if (inbox && inbox->total_msgs == 0
202 && str_write_to_file(body, file) >= 0) {
203 MsgFlags flags = { MSG_UNREAD|MSG_NEW, 0};
204 folder_item_add_msg(inbox, file, &flags, FALSE);
209 static gboolean wizard_write_config(WizardWindow *wizard)
211 gboolean mailbox_ok = FALSE;
212 PrefsAccount *prefs_account = prefs_account_new();
213 GList *account_list = NULL;
214 GtkWidget *menu, *menuitem;
216 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(wizard->recv_type));
217 menuitem = gtk_menu_get_active(GTK_MENU(menu));
218 prefs_account->protocol = GPOINTER_TO_INT
219 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
221 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
222 mailbox_ok = setup_write_mailbox_path(wizard->mainwin,
223 gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
228 gtk_notebook_set_current_page (
229 GTK_NOTEBOOK(wizard->notebook),
234 if (prefs_account->protocol != A_LOCAL)
235 prefs_account->account_name = g_strdup_printf("%s@%s",
236 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)),
237 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
239 prefs_account->account_name = g_strdup_printf("%s",
240 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
242 prefs_account->name = g_strdup(
243 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)));
244 prefs_account->address = g_strdup(
245 gtk_entry_get_text(GTK_ENTRY(wizard->email)));
246 prefs_account->organization = g_strdup(
247 gtk_entry_get_text(GTK_ENTRY(wizard->organization)));
248 prefs_account->smtp_server = g_strdup(
249 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)));
251 if (prefs_account->protocol != A_LOCAL)
252 prefs_account->recv_server = g_strdup(
253 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
255 prefs_account->local_mbox = g_strdup(
256 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
258 prefs_account->userid = g_strdup(
259 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)));
260 prefs_account->passwd = g_strdup(
261 gtk_entry_get_text(GTK_ENTRY(wizard->recv_password)));
264 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl)))
265 prefs_account->ssl_smtp = SSL_TUNNEL;
266 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl))) {
267 if (prefs_account->protocol == A_IMAP4)
268 prefs_account->ssl_imap = SSL_TUNNEL;
270 prefs_account->ssl_pop = SSL_TUNNEL;
273 if (prefs_account->protocol == A_IMAP4) {
274 gchar *directory = gtk_editable_get_chars(
275 GTK_EDITABLE(wizard->recv_imap_subdir), 0, -1);
276 if (directory && strlen(directory)) {
277 prefs_account->imap_dir = g_strdup(directory);
282 account_list = g_list_append(account_list, prefs_account);
283 prefs_account_write_config_all(account_list);
284 prefs_account_free(prefs_account);
285 account_read_config_all();
287 initialize_fonts(wizard);
288 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4)
289 write_welcome_email(wizard);
294 static GtkWidget* create_page (WizardWindow *wizard, const char * title)
302 vbox = gtk_vbox_new (FALSE, 6);
303 gtk_container_set_border_width (GTK_CONTAINER(vbox), 10);
305 /* create the titlebar */
306 hbox = gtk_hbox_new (FALSE, 12);
307 image = stock_pixmap_widget(wizard->window,
308 STOCK_PIXMAP_SYLPHEED_ICON);
309 gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 0);
310 title_string = g_strconcat ("<span size=\"xx-large\" weight=\"ultrabold\">", title ? title : "", "</span>", NULL);
311 w = gtk_label_new (title_string);
312 gtk_label_set_use_markup (GTK_LABEL(w), TRUE);
313 g_free (title_string);
314 gtk_box_pack_start (GTK_BOX(hbox), w, FALSE, FALSE, 0);
316 /* pack the titlebar */
317 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
319 /* pack the separator */
320 gtk_box_pack_start (GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
323 w = gtk_alignment_new (0, 0, 0, 0);
324 gtk_widget_set_size_request (w, 0, 6);
325 gtk_box_pack_start (GTK_BOX(vbox), w, FALSE, FALSE, 0);
330 #define GTK_TABLE_ADD_ROW_AT(table,text,entry,i) { \
331 GtkWidget *label = gtk_label_new(text); \
332 gtk_table_attach(GTK_TABLE(table), label, \
333 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0); \
334 if (GTK_IS_MISC(label)) \
335 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); \
336 gtk_table_attach(GTK_TABLE(table), entry, \
337 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0); \
340 static gchar *get_default_email_addr(void)
342 gchar *domain_name = g_strdup(get_domain_name());
344 if (strchr(domain_name, '.') != strrchr(domain_name, '.')
345 && strlen(strchr(domain_name, '.')) > 6) {
346 gchar *tmp = g_strdup(strchr(domain_name, '.')+1);
350 result = g_strdup_printf("%s@%s",
357 static gchar *get_default_server(WizardWindow * wizard, const gchar *type)
359 gchar *domain_name = g_strdup(get_domain_name());
362 if (strchr(domain_name, '.') != strrchr(domain_name, '.')
363 && strlen(strchr(domain_name, '.')) > 6) {
364 gchar *tmp = g_strdup(strchr(domain_name, '.')+1);
367 } else if (strchr(domain_name, '.') == NULL) {
368 /* only hostname found, use email suffix */
370 mail = gtk_editable_get_chars(GTK_EDITABLE(wizard->email), 0, -1);
372 if (strlen (mail) && strstr(mail, "@")) {
374 domain_name = g_strdup(strstr(mail, "@")+1);
378 result = g_strdup_printf("%s.%s",
384 static void wizard_email_changed(GtkWidget *widget, gpointer data)
386 WizardWindow *wizard = (WizardWindow *)data;
387 RecvProtocol protocol;
389 protocol = GPOINTER_TO_INT
390 (g_object_get_data(G_OBJECT(wizard->recv_type), MENU_VAL_ID));
392 text = get_default_server(wizard, "smtp");
393 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
396 if (protocol == A_POP3) {
397 text = get_default_server(wizard, "pop");
398 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
400 } else if (protocol == A_IMAP4) {
401 text = get_default_server(wizard, "imap");
402 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
404 } else if (protocol == A_LOCAL) {
405 gchar *mbox = g_strdup_printf("/var/mail/%s", g_get_user_name());
406 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), mbox);
411 static GtkWidget* user_page (WizardWindow * wizard)
413 GtkWidget *table = gtk_table_new(3,2, FALSE);
417 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
418 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
420 wizard->full_name = gtk_entry_new();
421 gtk_entry_set_text(GTK_ENTRY(wizard->full_name), g_get_real_name());
422 GTK_TABLE_ADD_ROW_AT(table, _("Your name:"),
423 wizard->full_name, i); i++;
425 wizard->email = gtk_entry_new();
426 text = get_default_email_addr();
427 gtk_entry_set_text(GTK_ENTRY(wizard->email), text);
429 GTK_TABLE_ADD_ROW_AT(table, _("Your email address:"),
430 wizard->email, i); i++;
432 wizard->organization = gtk_entry_new();
433 GTK_TABLE_ADD_ROW_AT(table, _("Your organization:"),
434 wizard->organization, i); i++;
436 g_signal_connect(G_OBJECT(wizard->email), "changed",
437 G_CALLBACK(wizard_email_changed),
442 static GtkWidget* mailbox_page (WizardWindow * wizard)
444 GtkWidget *table = gtk_table_new(1,2, FALSE);
447 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
448 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
450 wizard->mailbox_name = gtk_entry_new();
451 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), "Mail");
452 GTK_TABLE_ADD_ROW_AT(table, _("Mailbox name:"),
453 wizard->mailbox_name, i); i++;
458 static GtkWidget* smtp_page (WizardWindow * wizard)
460 GtkWidget *table = gtk_table_new(1,2, FALSE);
464 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
465 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
467 wizard->smtp_server = gtk_entry_new();
468 text = get_default_server(wizard, "smtp");
469 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
471 GTK_TABLE_ADD_ROW_AT(table, _("SMTP server address:"),
472 wizard->smtp_server, i); i++;
476 static void wizard_protocol_changed(GtkMenuItem *menuitem, gpointer data)
478 WizardWindow *wizard = (WizardWindow *)data;
479 RecvProtocol protocol;
481 protocol = GPOINTER_TO_INT
482 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
484 if (protocol == A_POP3) {
485 text = get_default_server(wizard, "pop");
486 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
487 gtk_widget_hide(wizard->recv_imap_label);
488 gtk_widget_hide(wizard->recv_imap_subdir);
489 gtk_widget_show(wizard->recv_username);
490 gtk_widget_show(wizard->recv_password);
491 gtk_widget_show(wizard->recv_username_label);
492 gtk_widget_show(wizard->recv_password_label);
493 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("Server address:"));
495 } else if (protocol == A_IMAP4) {
496 text = get_default_server(wizard, "imap");
497 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
498 gtk_widget_show(wizard->recv_imap_label);
499 gtk_widget_show(wizard->recv_imap_subdir);
500 gtk_widget_show(wizard->recv_username);
501 gtk_widget_show(wizard->recv_password);
502 gtk_widget_show(wizard->recv_username_label);
503 gtk_widget_show(wizard->recv_password_label);
504 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("Server address:"));
506 } else if (protocol == A_LOCAL) {
507 gchar *mbox = g_strdup_printf("/var/mail/%s", g_get_user_name());
508 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), mbox);
510 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("Local mailbox:"));
511 gtk_widget_hide(wizard->recv_imap_label);
512 gtk_widget_hide(wizard->recv_imap_subdir);
513 gtk_widget_hide(wizard->recv_username);
514 gtk_widget_hide(wizard->recv_password);
515 gtk_widget_hide(wizard->recv_username_label);
516 gtk_widget_hide(wizard->recv_password_label);
520 static GtkWidget* recv_page (WizardWindow * wizard)
522 GtkWidget *table = gtk_table_new(5,2, FALSE);
523 GtkWidget *menu = gtk_menu_new();
528 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
529 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
531 wizard->recv_type = gtk_option_menu_new();
533 MENUITEM_ADD (menu, menuitem, _("POP3"), A_POP3);
534 g_signal_connect(G_OBJECT(menuitem), "activate",
535 G_CALLBACK(wizard_protocol_changed),
537 MENUITEM_ADD (menu, menuitem, _("IMAP"), A_IMAP4);
538 g_signal_connect(G_OBJECT(menuitem), "activate",
539 G_CALLBACK(wizard_protocol_changed),
541 MENUITEM_ADD (menu, menuitem, _("Local mbox file"), A_LOCAL);
542 g_signal_connect(G_OBJECT(menuitem), "activate",
543 G_CALLBACK(wizard_protocol_changed),
546 gtk_option_menu_set_menu (GTK_OPTION_MENU (wizard->recv_type), menu);
547 GTK_TABLE_ADD_ROW_AT(table, _("Server type:"),
548 wizard->recv_type, i); i++;
550 wizard->recv_server = gtk_entry_new();
551 text = get_default_server(wizard, "pop");
552 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
555 wizard->recv_label = gtk_label_new(_("Server address:"));
556 gtk_table_attach(GTK_TABLE(table), wizard->recv_label,
557 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
558 if (GTK_IS_MISC(wizard->recv_label))
559 gtk_misc_set_alignment(GTK_MISC(wizard->recv_label), 1, 0.5);
560 gtk_table_attach(GTK_TABLE(table), wizard->recv_server,
561 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
564 wizard->recv_username = gtk_entry_new();
565 wizard->recv_username_label = gtk_label_new(_("Username:"));
566 gtk_table_attach(GTK_TABLE(table), wizard->recv_username_label,
567 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
568 if (GTK_IS_MISC(wizard->recv_username_label))
569 gtk_misc_set_alignment(GTK_MISC(wizard->recv_username_label), 1, 0.5);
570 gtk_table_attach(GTK_TABLE(table), wizard->recv_username,
571 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
574 wizard->recv_password = gtk_entry_new();
575 wizard->recv_password_label = gtk_label_new(_("Password:"));
576 gtk_table_attach(GTK_TABLE(table), wizard->recv_password_label,
577 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
578 if (GTK_IS_MISC(wizard->recv_password_label))
579 gtk_misc_set_alignment(GTK_MISC(wizard->recv_password_label), 1, 0.5);
580 gtk_table_attach(GTK_TABLE(table), wizard->recv_password,
581 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
582 gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_password), FALSE);
585 wizard->recv_imap_subdir = gtk_entry_new();
586 wizard->recv_imap_label = gtk_label_new(_("IMAP server directory:"));
588 gtk_table_attach(GTK_TABLE(table), wizard->recv_imap_label,
589 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
590 if (GTK_IS_MISC(wizard->recv_imap_label))
591 gtk_misc_set_alignment(GTK_MISC(wizard->recv_imap_label), 1, 0.5);
592 gtk_table_attach(GTK_TABLE(table), wizard->recv_imap_subdir,
593 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
601 static GtkWidget* ssl_page (WizardWindow * wizard)
603 GtkWidget *table = gtk_table_new(2,2, FALSE);
606 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
607 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
609 wizard->smtp_use_ssl = gtk_check_button_new_with_label(
610 _("Use SSL to connect to SMTP server"));
611 gtk_table_attach(GTK_TABLE(table), wizard->smtp_use_ssl,
612 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0); i++;
614 wizard->recv_use_ssl = gtk_check_button_new_with_label(
615 _("Use SSL to connect to receiving server"));
616 gtk_table_attach(GTK_TABLE(table), wizard->recv_use_ssl,
617 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
624 wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
626 WizardWindow * wizard = (WizardWindow *)data;
627 int current_page, num_pages;
628 GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(wizard->recv_type));
629 GtkWidget *menuitem = gtk_menu_get_active(GTK_MENU(menu));
630 gint protocol = GPOINTER_TO_INT
631 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
632 gboolean skip_mailbox_page = FALSE;
634 if (protocol == A_IMAP4) {
635 skip_mailbox_page = TRUE;
638 num_pages = g_slist_length(wizard->pages);
640 current_page = gtk_notebook_get_current_page (
641 GTK_NOTEBOOK(wizard->notebook));
642 if (response == CANCEL)
644 wizard->result = FALSE;
645 wizard->finished = TRUE;
646 gtk_widget_destroy (GTK_WIDGET(dialog));
648 else if (response == FINISHED)
650 if (!wizard_write_config(wizard)) {
651 current_page = gtk_notebook_get_current_page (
652 GTK_NOTEBOOK(wizard->notebook));
655 wizard->result = TRUE;
656 wizard->finished = TRUE;
657 gtk_widget_destroy (GTK_WIDGET(dialog));
661 if (response == GO_BACK)
663 if (current_page > 0) {
665 if (current_page == 4 && skip_mailbox_page) {
669 gtk_notebook_set_current_page (
670 GTK_NOTEBOOK(wizard->notebook),
674 else if (response == GO_FORWARD)
676 if (current_page < (num_pages-1)) {
678 if (current_page == 4 && skip_mailbox_page) {
682 gtk_notebook_set_current_page (
683 GTK_NOTEBOOK(wizard->notebook),
688 gtk_dialog_set_response_sensitive (dialog, GO_BACK,
690 gtk_dialog_set_response_sensitive (dialog, GO_FORWARD,
691 current_page < (num_pages - 1));
692 gtk_dialog_set_response_sensitive (dialog, FINISHED,
693 current_page == (num_pages - 1));
694 gtk_dialog_set_response_sensitive (dialog, CANCEL,
695 current_page != (num_pages - 1));
699 static gint wizard_close_cb(GtkWidget *widget, GdkEventAny *event,
702 WizardWindow *wizard = (WizardWindow *)data;
703 wizard->result = FALSE;
704 wizard->finished = TRUE;
709 gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
710 WizardWindow *wizard = g_new0(WizardWindow, 1);
717 wizard->mainwin = mainwin;
718 wizard->create_mailbox = create_mailbox;
720 gtk_widget_hide(mainwin->window);
722 wizard->window = gtk_dialog_new_with_buttons (_("New User"),
724 GTK_STOCK_GO_BACK, GO_BACK,
725 GTK_STOCK_GO_FORWARD, GO_FORWARD,
726 GTK_STOCK_SAVE, FINISHED,
727 GTK_STOCK_QUIT, CANCEL,
730 g_signal_connect(wizard->window, "response",
731 G_CALLBACK(wizard_response_cb), wizard);
732 gtk_widget_realize(wizard->window);
733 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window),
735 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
737 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
739 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
741 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
744 wizard->notebook = gtk_notebook_new();
745 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(wizard->notebook), FALSE);
746 gtk_notebook_set_show_border(GTK_NOTEBOOK(wizard->notebook), FALSE);
747 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(wizard->window)->vbox),
748 wizard->notebook, TRUE, TRUE, 0);
750 wizard->pages = NULL;
753 page = create_page(wizard, _("Welcome to Sylpheed-Claws."));
755 wizard->pages = g_slist_append(wizard->pages, page);
756 widget = stock_pixmap_widget(wizard->window,
757 STOCK_PIXMAP_SYLPHEED_LOGO);
759 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
761 text = g_strdup(_("Welcome to Sylpheed-Claws.\n\n"
762 "It looks like it's the first time you use \n"
763 "Sylpheed-Claws. So, we'll now define some basic\n"
764 "information about yourself and your most common\n"
765 "mail parameters; so that you can begin to use\n"
766 "Sylpheed-Claws in less than five minutes."));
767 widget = gtk_label_new(text);
768 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
772 widget = create_page (wizard, _("About You"));
773 gtk_box_pack_start (GTK_BOX(widget), user_page(wizard), FALSE, FALSE, 0);
774 wizard->pages = g_slist_append(wizard->pages, widget);
777 widget = create_page (wizard, _("Sending mail"));
778 gtk_box_pack_start (GTK_BOX(widget), smtp_page(wizard), FALSE, FALSE, 0);
779 wizard->pages = g_slist_append(wizard->pages, widget);
781 /* recv+auth page: 3 */
782 widget = create_page (wizard, _("Receiving mail"));
783 gtk_box_pack_start (GTK_BOX(widget), recv_page(wizard), FALSE, FALSE, 0);
784 wizard->pages = g_slist_append(wizard->pages, widget);
786 /* mailbox page: 4 */
787 if (create_mailbox) {
788 widget = create_page (wizard, _("Saving mail on disk"));
789 gtk_box_pack_start (GTK_BOX(widget), mailbox_page(wizard), FALSE, FALSE, 0);
790 wizard->pages = g_slist_append(wizard->pages, widget);
794 widget = create_page (wizard, _("Security"));
795 gtk_box_pack_start (GTK_BOX(widget), ssl_page(wizard), FALSE, FALSE, 0);
796 wizard->pages = g_slist_append(wizard->pages, widget);
800 page = create_page(wizard, _("Configuration finished."));
802 wizard->pages = g_slist_append(wizard->pages, page);
803 widget = stock_pixmap_widget(wizard->window,
804 STOCK_PIXMAP_SYLPHEED_LOGO);
806 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
808 text = g_strdup(_("Sylpheed-Claws is now ready to run.\n\n"
809 "Click Save to start."));
810 widget = gtk_label_new(text);
811 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
815 for (cur = wizard->pages; cur && cur->data; cur = cur->next) {
816 gtk_notebook_append_page (GTK_NOTEBOOK(wizard->notebook),
817 GTK_WIDGET(cur->data), NULL);
820 g_signal_connect(G_OBJECT(wizard->window), "delete_event",
821 G_CALLBACK(wizard_close_cb), wizard);
822 gtk_widget_show_all (wizard->window);
824 gtk_widget_hide(wizard->recv_imap_label);
825 gtk_widget_hide(wizard->recv_imap_subdir);
827 while (!wizard->finished)
828 gtk_main_iteration();
830 result = wizard->result;
834 gtk_widget_show(mainwin->window);