2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Claws Mail team
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>
54 #include "prefs_account.h"
55 #include "mainwindow.h"
56 #include "stock_pixmap.h"
59 #include "alertpanel.h"
63 #include "prefs_common.h"
73 int WELCOME_PAGE = -1;
77 int MAILBOX_PAGE = -1;
90 GtkWidget *organization;
92 GtkWidget *mailbox_name;
94 GtkWidget *smtp_server;
96 GtkWidget *smtp_username;
97 GtkWidget *smtp_password;
98 GtkWidget *smtp_username_label;
99 GtkWidget *smtp_password_label;
101 GtkWidget *recv_type;
102 GtkWidget *recv_label;
103 GtkWidget *recv_server;
104 GtkWidget *recv_username;
105 GtkWidget *recv_password;
106 GtkWidget *recv_username_label;
107 GtkWidget *recv_password_label;
108 GtkWidget *recv_imap_label;
109 GtkWidget *recv_imap_subdir;
110 GtkWidget *no_imap_warning;
112 GtkWidget *smtp_use_ssl;
113 GtkWidget *recv_use_ssl;
116 gboolean create_mailbox;
122 typedef struct _AccountTemplate {
131 RecvProtocol recvtype;
142 static AccountTemplate tmpl;
144 static PrefParam template_params[] = {
145 {"name", "$USERNAME",
146 &tmpl.name, P_STRING, NULL, NULL, NULL},
147 {"domain", "$DEFAULTDOMAIN",
148 &tmpl.domain, P_STRING, NULL, NULL, NULL},
149 {"email", "$NAME_MAIL@$DOMAIN",
150 &tmpl.email, P_STRING, NULL, NULL, NULL},
152 &tmpl.organization, P_STRING, NULL, NULL, NULL},
153 {"smtpserver", "smtp.$DOMAIN",
154 &tmpl.smtpserver, P_STRING, NULL, NULL, NULL},
155 {"smtpauth", "FALSE",
156 &tmpl.smtpauth, P_BOOL, NULL, NULL, NULL},
158 &tmpl.smtpuser, P_STRING, NULL, NULL, NULL},
160 &tmpl.smtppass, P_STRING, NULL, NULL, NULL},
162 &tmpl.recvtype, P_INT, NULL, NULL, NULL},
163 {"recvserver", "pop.$DOMAIN",
164 &tmpl.recvserver, P_STRING, NULL, NULL, NULL},
165 {"recvuser", "$LOGIN",
166 &tmpl.recvuser, P_STRING, NULL, NULL, NULL},
168 &tmpl.recvpass, P_STRING, NULL, NULL, NULL},
170 &tmpl.imapdir, P_STRING, NULL, NULL, NULL},
171 {"mboxfile", "/var/mail/$LOGIN",
172 &tmpl.mboxfile, P_STRING, NULL, NULL, NULL},
174 &tmpl.mailbox, P_STRING, NULL, NULL, NULL},
176 &tmpl.smtpssl, P_BOOL, NULL, NULL, NULL},
178 &tmpl.recvssl, P_BOOL, NULL, NULL, NULL},
179 {NULL, NULL, NULL, P_INT, NULL, NULL, NULL}
183 static gchar *accountrc_tmpl =
184 "[AccountTemplate]\n"
185 "#you can use $DEFAULTDOMAIN here\n"
186 "#domain must be defined before the variables that use it\n"
187 "#by default, domain is extracted from the hostname\n"
190 "#you can use $USERNAME for name (this is the default)\n"
193 "#you can use $LOGIN, $NAME_MAIL and $DOMAIN here \n"
194 "#$NAME_MAIL is the name without uppercase and with dots instead\n"
196 "#the default is $NAME_MAIL@$DOMAIN\n"
199 "#you can use $DOMAIN here\n"
200 "#the default organization is empty\n"
203 "#you can use $DOMAIN here \n"
204 "#the default is stmp.$DOMAIN\n"
207 "#Whether to use smtp authentication\n"
208 "#the default is 0 (no)\n"
212 "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
213 "#the default is empty (same as reception username)\n"
217 "#the default is empty (same as reception password)\n"
220 "#recvtype can be:\n"
223 "#5 for a local mbox file\n"
226 "#you can use $DOMAIN here \n"
227 "#the default is {pop,imap}.$DOMAIN\n"
230 "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
231 "#default is $LOGIN\n"
234 "#default is empty\n"
237 "#imap dir if imap (relative to the home on the server\n"
238 "#default is empty\n"
241 "#mbox file if local\n"
242 "#you can use $LOGIN here\n"
243 "#default is /var/mail/$LOGIN\n"
246 "#mailbox name if pop3 or local\n"
247 "#relative path from the user's home\n"
248 "#default is \"Mail\"\n"
251 "#whether to use ssl on STMP connections\n"
255 "#whether to use ssl on pop or imap connections\n"
259 static gchar *wizard_get_default_domain_name(void)
261 static gchar *domain_name = NULL;
263 if (domain_name == NULL) {
264 domain_name = g_strdup(get_domain_name());
265 if (strchr(domain_name, '.') != strrchr(domain_name, '.')
266 && strlen(strchr(domain_name, '.')) > 6) {
267 gchar *tmp = g_strdup(strchr(domain_name, '.')+1);
275 static gchar *get_name_for_mail(void)
277 gchar *name = g_strdup(tmpl.name);
281 while(strstr(name, " "))
282 *strstr(name, " ")='.';
287 #define PARSE_DEFAULT(str) { \
288 gchar *tmp = NULL, *new = NULL; \
290 tmp = g_strdup(str); \
291 if (strstr(str, "$USERNAME")) { \
292 tmp = g_strdup(str); \
293 *strstr(tmp, "$USERNAME") = '\0'; \
294 new = g_strconcat(tmp, g_get_real_name(), \
295 strstr(str, "$USERNAME")+strlen("$USERNAME"), \
302 if (strstr(str, "$LOGIN")) { \
303 tmp = g_strdup(str); \
304 *strstr(tmp, "$LOGIN") = '\0'; \
305 new = g_strconcat(tmp, g_get_user_name(), \
306 strstr(str, "$LOGIN")+strlen("$LOGIN"), \
313 if (strstr(str, "$EMAIL")) { \
314 tmp = g_strdup(str); \
315 *strstr(tmp, "$EMAIL") = '\0'; \
316 new = g_strconcat(tmp, tmpl.email, \
317 strstr(str, "$EMAIL")+strlen("$EMAIL"), \
324 if (strstr(str, "$NAME_MAIL")) { \
325 tmp = g_strdup(str); \
326 *strstr(tmp, "$NAME_MAIL") = '\0'; \
327 new = g_strconcat(tmp, get_name_for_mail(), \
328 strstr(str, "$NAME_MAIL")+strlen("$NAME_MAIL"), \
335 if (strstr(str, "$DEFAULTDOMAIN")) { \
336 tmp = g_strdup(str); \
337 *strstr(tmp, "$DEFAULTDOMAIN") = '\0'; \
338 new = g_strconcat(tmp, wizard_get_default_domain_name(), \
339 strstr(str, "$DEFAULTDOMAIN")+strlen("$DEFAULTDOMAIN"), \
346 if (strstr(str, "$DOMAIN")) { \
347 tmp = g_strdup(str); \
348 *strstr(tmp, "$DOMAIN") = '\0'; \
349 new = g_strconcat(tmp, tmpl.domain, \
350 strstr(str, "$DOMAIN")+strlen("$DOMAIN"), \
359 static void wizard_read_defaults(void)
363 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "accountrc.tmpl", NULL);
364 if (!is_file_exist(rcpath)) {
365 str_write_to_file(accountrc_tmpl, rcpath);
368 prefs_read_config(template_params, "AccountTemplate", rcpath, NULL);
370 PARSE_DEFAULT(tmpl.domain);
371 PARSE_DEFAULT(tmpl.name);
372 PARSE_DEFAULT(tmpl.email);
373 PARSE_DEFAULT(tmpl.organization);
374 PARSE_DEFAULT(tmpl.smtpserver);
375 PARSE_DEFAULT(tmpl.smtpuser);
376 PARSE_DEFAULT(tmpl.smtppass);
377 PARSE_DEFAULT(tmpl.recvserver);
378 PARSE_DEFAULT(tmpl.recvuser);
379 PARSE_DEFAULT(tmpl.recvpass);
380 PARSE_DEFAULT(tmpl.imapdir);
381 PARSE_DEFAULT(tmpl.mboxfile);
382 PARSE_DEFAULT(tmpl.mailbox);
385 "%s, %s, %s, %s, %s, %d, %s, %s, %s, %s, %s, %s, %d, %d\n",
386 tmpl.name,tmpl.domain,tmpl.email,tmpl.organization,tmpl.smtpserver,
387 tmpl.recvtype,tmpl.recvserver,tmpl.recvuser,tmpl.recvpass,
388 tmpl.imapdir,tmpl.mboxfile,tmpl.mailbox,tmpl.smtpssl,tmpl.recvssl);
393 static void initialize_fonts(WizardWindow *wizard)
395 GtkWidget *widget = wizard->email;
396 gint size = pango_font_description_get_size(
397 widget->style->font_desc)
401 tmp = g_strdup(prefs_common.textfont);
402 if (strrchr(tmp, ' ')) {
403 *(strrchr(tmp, ' ')) = '\0';
404 new = g_strdup_printf("%s %d", tmp, size);
405 g_free(prefs_common.textfont);
406 prefs_common.textfont = new;
410 tmp = g_strdup(prefs_common.smallfont);
411 if (strrchr(tmp, ' ')) {
412 *(strrchr(tmp, ' ')) = '\0';
413 new = g_strdup_printf("%s %d", tmp, size);
414 g_free(prefs_common.smallfont);
415 prefs_common.smallfont = new;
419 tmp = g_strdup(prefs_common.normalfont);
420 if (strrchr(tmp, ' ')) {
421 *(strrchr(tmp, ' ')) = '\0';
422 new = g_strdup_printf("%s %d", tmp, size);
423 g_free(prefs_common.normalfont);
424 prefs_common.normalfont = new;
429 #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"
430 #define FACE "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJ1BMVEUTGBYnS3BCUE9KVC9acyRy\n\
431 kC6LjITZdGiumnF/p7yrq6jJzc/5+vf7GI+IAAACZ0lEQVQ4y5XUvW/UMBQA8LRl6VZ3QLqNNhVS\n\
432 YSnKFfExEg9lbJNK3QqVoiPHzgpFnAIs5Do9ORNDVOwuFVIgduZWOfuP4vlyybVVkeCdTpHe7z1/\n\
433 RHYc85dw/gEUxi2gS5ZlDKqbUDcpzarroMEOpDU2VtcAmFKlxn+t2VWQUNa1BmAlGrsCqWKMwetv\n\
434 MMbnFaixFn9rh47DFCuzDs6hxPyrxXuOA7WqWQcp2Fhx7gTOcga6bGHSS6FHCHFouLcMJptuaQbp\n\
435 +kff90P6Yn0TMpXN4DxNVz+FQZ8Gob8DGWSsBUIG23seDXwaBBnU0EJKVhNvqx/6aHTHrmMGhNw9\n\
436 XlqkgbdEX/gh1PUcVj84G4HnuHTXDQ+6Dk3IyqFL/UfEpXvj7RChaoEsUX9rYeGE7o83wp0WcCjS\n\
437 9/01AifhLrj0oINeuuJ53kIP+uF+7uL03eQpGWx5yzDu05fM3Z53AJDkvdODwvOfmbH3uOuwcLz+\n\
438 UBWLR8/N+MHnDsoeG4zecDl5Mhqa74NR90p+VEYmo+ioSEan8WnytANhDB8kX06TJFZJcowvfrZz\n\
439 XIMS2vxMIlHJfHMTRLOqC7TovlJFEVVGF7yafFVTkGgij+I851hZCHP5Tk8BWXObjuxhl2fm8pdu\n\
440 O0wluZDKHgJ91nVMKhuKN6cZQf9uQAs85lrjGDYmwmqzDynwClRKTCF/OwfDub0dQyzHxVUt6DzK\n\
441 eY5NseIxb8abwoVSMpZDhJyL9kJamGAxplC7izkHyaXM5/nZHFiNeRHfBFNwLjhOr+fAmw1G3OYl\n\
442 bwoijGGzD40pdeu3ROv/+Pr8AWPP4vVXbP0VAAAAAElFTkSuQmCC"
444 static void write_welcome_email(WizardWindow *wizard)
450 const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name));
451 Folder *folder = folder_find_from_path(mailbox);
452 FolderItem *inbox = folder ? folder->inbox:NULL;
453 gchar *file = get_tmp_file();
454 gchar enc_from_name[BUFFSIZE], enc_to_name[BUFFSIZE], enc_subject[BUFFSIZE];
456 get_rfc822_date(buf_date, sizeof(buf_date));
458 conv_encode_header_full(enc_subject, sizeof(enc_subject),
459 _("Welcome to Claws Mail "),
460 strlen("Subject: "), FALSE, CS_INTERNAL);
461 conv_encode_header_full(enc_to_name, sizeof(enc_to_name),
462 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)),
463 strlen("To: "), TRUE, CS_INTERNAL);
464 conv_encode_header_full(enc_from_name, sizeof(enc_from_name),
465 _("Claws Mail Team"),
466 strlen("From: "), TRUE, CS_INTERNAL);
468 head = g_strdup_printf(
475 "Content-Type: text/plain; charset=UTF-8\n",
479 gtk_entry_get_text(GTK_ENTRY(wizard->email)),
480 buf_date, enc_subject, XFACE, FACE);
481 body = g_strdup_printf(
483 "Welcome to Claws Mail\n"
484 "-------------------------\n"
486 "Now that you have set up your account you can fetch your\n"
487 "mail by clicking the 'Get Mail' button at the left of the\n"
490 "Claws Mail has lots of extra features accessible via plugins,\n"
491 "like anti-spam filtering and learning (via the Bogofilter or\n"
492 "SpamAssassin plugins), privacy protection (via PGP/Mime), an RSS\n"
493 "aggregator, a calendar, and much more. You can load them from\n"
494 "the menu entry '/Configuration/Plugins'.\n"
496 "You can change your Account Preferences by using the menu\n"
497 "entry '/Configuration/Preferences for current account'\n"
498 "and change the general Preferences by using\n"
499 "'/Configuration/Preferences'.\n"
501 "You can find further information in the Claws Mail manual,\n"
502 "which can be accessed by using the menu entry '/Help/Manual'\n"
503 "or online at the URL given below.\n"
511 "Mailing Lists: <%s>\n"
515 "Claws Mail is free software, released under the terms\n"
516 "of the GNU General Public License, version 2 or later, as\n"
517 "published by the Free Software Foundation, 51 Franklin Street,\n"
518 "Fifth Floor, Boston, MA 02110-1301, USA. The license can be\n"
523 "If you wish to donate to the Claws Mail project you can do\n"
525 HOMEPAGE_URI, MANUAL_URI, FAQ_URI, THEMES_URI, MAILING_LIST_URI,
526 GPL_URI, DONATE_URI);
528 msg = g_strconcat(head, body, NULL);
530 if (inbox && inbox->total_msgs == 0
531 && str_write_to_file(msg, file) >= 0) {
532 MsgFlags flags = { MSG_UNREAD|MSG_NEW, 0};
533 folder_item_add_msg(inbox, file, &flags, FALSE);
542 static gboolean wizard_write_config(WizardWindow *wizard)
544 static gboolean mailbox_ok = FALSE;
545 PrefsAccount *prefs_account = prefs_account_new();
546 GList *account_list = NULL;
547 GtkWidget *menu, *menuitem;
548 gchar *smtp_server, *recv_server;
549 gint smtp_port, recv_port;
551 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(wizard->recv_type));
552 menuitem = gtk_menu_get_active(GTK_MENU(menu));
553 prefs_account->protocol = GPOINTER_TO_INT
554 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
557 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4 &&
558 !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)))) {
559 alertpanel_error(_("Please enter the mailbox name."));
560 g_free(prefs_account);
561 gtk_notebook_set_current_page (
562 GTK_NOTEBOOK(wizard->notebook),
568 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
569 mailbox_ok = setup_write_mailbox_path(wizard->mainwin,
571 GTK_ENTRY(wizard->mailbox_name)));
577 /* alertpanel done by setup_write_mailbox_path */
578 g_free(prefs_account);
579 gtk_notebook_set_current_page (
580 GTK_NOTEBOOK(wizard->notebook),
585 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->full_name)))
586 || !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->email)))) {
587 alertpanel_error(_("Please enter your name and email address."));
588 g_free(prefs_account);
589 gtk_notebook_set_current_page (
590 GTK_NOTEBOOK(wizard->notebook),
595 if (prefs_account->protocol != A_LOCAL) {
596 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)))
597 || !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
598 alertpanel_error(_("Please enter your receiving server "
600 g_free(prefs_account);
601 gtk_notebook_set_current_page (
602 GTK_NOTEBOOK(wizard->notebook),
607 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
608 alertpanel_error(_("Please enter your username."));
609 g_free(prefs_account);
610 gtk_notebook_set_current_page (
611 GTK_NOTEBOOK(wizard->notebook),
617 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)))) {
618 alertpanel_error(_("Please enter your SMTP server."));
619 g_free(prefs_account);
620 gtk_notebook_set_current_page (
621 GTK_NOTEBOOK(wizard->notebook),
626 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
627 if (prefs_account->protocol == A_LOCAL
628 && !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)))) {
629 alertpanel_error(_("Please enter your SMTP username."));
630 g_free(prefs_account);
631 gtk_notebook_set_current_page (
632 GTK_NOTEBOOK(wizard->notebook),
635 } /* if it's not local we'll use the reception server */
638 if (prefs_account->protocol != A_LOCAL)
639 prefs_account->account_name = g_strdup_printf("%s@%s",
640 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)),
641 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
643 prefs_account->account_name = g_strdup_printf("%s",
644 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
646 recv_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
647 smtp_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)));
649 if (prefs_account->protocol != A_LOCAL && strstr(recv_server, ":")) {
650 recv_port = atoi(strstr(recv_server, ":")+1);
651 *(strstr(recv_server, ":")) = '\0';
652 if (prefs_account->protocol == A_IMAP4) {
653 prefs_account->set_imapport = TRUE;
654 prefs_account->imapport = recv_port;
655 } else if (prefs_account->protocol == A_POP3) {
656 prefs_account->set_popport = TRUE;
657 prefs_account->popport = recv_port;
660 if (strstr(smtp_server, ":")) {
661 smtp_port = atoi(strstr(smtp_server, ":")+1);
662 *(strstr(smtp_server, ":")) = '\0';
663 prefs_account->set_smtpport = TRUE;
664 prefs_account->smtpport = smtp_port;
667 prefs_account->name = g_strdup(
668 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)));
669 prefs_account->address = g_strdup(
670 gtk_entry_get_text(GTK_ENTRY(wizard->email)));
671 prefs_account->organization = g_strdup(
672 gtk_entry_get_text(GTK_ENTRY(wizard->organization)));
673 prefs_account->smtp_server = g_strdup(smtp_server);
675 if (prefs_account->protocol != A_LOCAL)
676 prefs_account->recv_server = g_strdup(recv_server);
678 prefs_account->local_mbox = g_strdup(recv_server);
683 prefs_account->userid = g_strdup(
684 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)));
685 prefs_account->passwd = g_strdup(
686 gtk_entry_get_text(GTK_ENTRY(wizard->recv_password)));
688 prefs_account->smtp_userid = g_strdup(
689 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)));
690 prefs_account->smtp_passwd = g_strdup(
691 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_password)));
692 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
693 prefs_account->use_smtp_auth = TRUE;
697 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl)))
698 prefs_account->ssl_smtp = SSL_TUNNEL;
699 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl))) {
700 if (prefs_account->protocol == A_IMAP4)
701 prefs_account->ssl_imap = SSL_TUNNEL;
703 prefs_account->ssl_pop = SSL_TUNNEL;
706 if (prefs_account->protocol == A_IMAP4) {
707 gchar *directory = gtk_editable_get_chars(
708 GTK_EDITABLE(wizard->recv_imap_subdir), 0, -1);
709 if (directory && strlen(directory)) {
710 prefs_account->imap_dir = g_strdup(directory);
715 account_list = g_list_append(account_list, prefs_account);
716 prefs_account_write_config_all(account_list);
717 prefs_account_free(prefs_account);
718 account_read_config_all();
720 initialize_fonts(wizard);
721 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4)
722 write_welcome_email(wizard);
725 plugin_load_standard_plugins();
730 static GtkWidget* create_page (WizardWindow *wizard, const char * title)
738 vbox = gtk_vbox_new (FALSE, 6);
739 gtk_container_set_border_width (GTK_CONTAINER(vbox), 10);
741 /* create the titlebar */
742 hbox = gtk_hbox_new (FALSE, 12);
743 image = stock_pixmap_widget(wizard->window,
744 STOCK_PIXMAP_CLAWS_MAIL_ICON);
745 gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 0);
746 title_string = g_strconcat ("<span size=\"xx-large\" weight=\"ultrabold\">", title ? title : "", "</span>", NULL);
747 w = gtk_label_new (title_string);
748 gtk_label_set_use_markup (GTK_LABEL(w), TRUE);
749 g_free (title_string);
750 gtk_box_pack_start (GTK_BOX(hbox), w, FALSE, FALSE, 0);
752 /* pack the titlebar */
753 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
755 /* pack the separator */
756 gtk_box_pack_start (GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
759 w = gtk_alignment_new (0, 0, 0, 0);
760 gtk_widget_set_size_request (w, 0, 6);
761 gtk_box_pack_start (GTK_BOX(vbox), w, FALSE, FALSE, 0);
766 #define GTK_TABLE_ADD_ROW_AT(table,text,entry,i) { \
767 GtkWidget *label = gtk_label_new(text); \
768 gtk_table_attach(GTK_TABLE(table), label, \
769 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0); \
770 gtk_label_set_use_markup(GTK_LABEL(label), TRUE); \
771 if (GTK_IS_MISC(label)) \
772 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); \
773 gtk_table_attach(GTK_TABLE(table), entry, \
774 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0); \
777 static gchar *get_default_server(WizardWindow * wizard, const gchar *type)
779 if (!strcmp(type, "smtp")) {
780 if (!tmpl.smtpserver || !strlen(tmpl.smtpserver))
781 return g_strconcat(type, ".", tmpl.domain, NULL);
783 return g_strdup(tmpl.smtpserver);
785 if (!tmpl.recvserver || !strlen(tmpl.recvserver))
786 return g_strconcat(type, ".", tmpl.domain, NULL);
788 return g_strdup(tmpl.recvserver);
792 static gchar *get_default_account(WizardWindow * wizard)
794 gchar *result = NULL;
796 if (!tmpl.recvuser || !strlen(tmpl.recvuser)) {
797 result = gtk_editable_get_chars(
798 GTK_EDITABLE(wizard->email), 0, -1);
800 if (strstr(result, "@")) {
801 *(strstr(result,"@")) = '\0';
804 result = g_strdup(tmpl.recvuser);
809 static gchar *get_default_smtp_account(WizardWindow * wizard)
811 gchar *result = NULL;
813 if (!tmpl.smtpuser || !strlen(tmpl.smtpuser)) {
816 result = g_strdup(tmpl.smtpuser);
821 static void wizard_email_changed(GtkWidget *widget, gpointer data)
823 WizardWindow *wizard = (WizardWindow *)data;
824 RecvProtocol protocol;
826 protocol = GPOINTER_TO_INT
827 (g_object_get_data(G_OBJECT(wizard->recv_type), MENU_VAL_ID));
829 text = get_default_server(wizard, "smtp");
830 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
833 text = get_default_account(wizard);
834 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
837 if (protocol == A_POP3) {
838 text = get_default_server(wizard, "pop");
839 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
841 } else if (protocol == A_IMAP4) {
842 text = get_default_server(wizard, "imap");
843 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
845 } else if (protocol == A_LOCAL) {
846 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
851 static GtkWidget* user_page (WizardWindow * wizard)
853 GtkWidget *table = gtk_table_new(3,2, FALSE);
856 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
857 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
859 wizard->full_name = gtk_entry_new();
860 gtk_entry_set_text(GTK_ENTRY(wizard->full_name), tmpl.name?tmpl.name:"");
861 GTK_TABLE_ADD_ROW_AT(table, _("<span weight=\"bold\">Your name:</span>"),
862 wizard->full_name, i); i++;
864 wizard->email = gtk_entry_new();
865 gtk_entry_set_text(GTK_ENTRY(wizard->email), tmpl.email?tmpl.email:"");
866 GTK_TABLE_ADD_ROW_AT(table, _("<span weight=\"bold\">Your email address:</span>"),
867 wizard->email, i); i++;
869 wizard->organization = gtk_entry_new();
870 GTK_TABLE_ADD_ROW_AT(table, _("Your organization:"),
871 wizard->organization, i); i++;
872 gtk_entry_set_text(GTK_ENTRY(wizard->organization), tmpl.organization?tmpl.organization:"");
874 g_signal_connect(G_OBJECT(wizard->email), "changed",
875 G_CALLBACK(wizard_email_changed),
880 static GtkWidget* mailbox_page (WizardWindow * wizard)
882 GtkWidget *table = gtk_table_new(1,2, FALSE);
885 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
886 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
888 wizard->mailbox_name = gtk_entry_new();
889 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), tmpl.mailbox?tmpl.mailbox:"");
890 GTK_TABLE_ADD_ROW_AT(table, _("<span weight=\"bold\">Mailbox name:</span>"),
891 wizard->mailbox_name, i); i++;
896 static void smtp_auth_changed (GtkWidget *btn, gpointer data)
898 WizardWindow *wizard = (WizardWindow *)data;
899 gboolean do_auth = gtk_toggle_button_get_active(
900 GTK_TOGGLE_BUTTON(wizard->smtp_auth));
901 gtk_widget_set_sensitive(wizard->smtp_username, do_auth);
902 gtk_widget_set_sensitive(wizard->smtp_username_label, do_auth);
903 gtk_widget_set_sensitive(wizard->smtp_password, do_auth);
904 gtk_widget_set_sensitive(wizard->smtp_password_label, do_auth);
907 static GtkWidget* smtp_page (WizardWindow * wizard)
910 GtkWidget *table = gtk_table_new(5, 2, FALSE);
912 GtkWidget *table = gtk_table_new(4, 2, FALSE);
917 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
918 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
920 wizard->smtp_server = gtk_entry_new();
921 text = get_default_server(wizard, "smtp");
922 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
924 GTK_TABLE_ADD_ROW_AT(table, _("<span weight=\"bold\">SMTP server address:</span>"),
925 wizard->smtp_server, i); i++;
926 wizard->smtp_auth = gtk_check_button_new_with_label(
927 _("Use authentication"));
928 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth),
930 g_signal_connect(G_OBJECT(wizard->smtp_auth), "toggled",
931 G_CALLBACK(smtp_auth_changed),
933 gtk_table_attach(GTK_TABLE(table), wizard->smtp_auth,
934 0,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0); i++;
936 text = get_default_smtp_account(wizard);
938 wizard->smtp_username = gtk_entry_new();
939 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_username), text);
941 wizard->smtp_username_label = gtk_label_new(_("SMTP username:\n"
942 "<span size=\"small\">(empty to use the same as reception)</span>"));
943 gtk_label_set_use_markup(GTK_LABEL(wizard->smtp_username_label), TRUE);
944 gtk_table_attach(GTK_TABLE(table), wizard->smtp_username_label,
945 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
946 if (GTK_IS_MISC(wizard->smtp_username_label))
947 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_username_label), 1, 0.5);
948 gtk_table_attach(GTK_TABLE(table), wizard->smtp_username,
949 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
951 wizard->smtp_password = gtk_entry_new();
952 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_password), tmpl.smtppass?tmpl.smtppass:"");
953 gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_password), FALSE);
954 wizard->smtp_password_label = gtk_label_new(_("SMTP password:\n"
955 "<span size=\"small\">(empty to use the same as reception)</span>"));
956 gtk_label_set_use_markup(GTK_LABEL(wizard->smtp_password_label), TRUE);
957 gtk_table_attach(GTK_TABLE(table), wizard->smtp_password_label,
958 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
959 if (GTK_IS_MISC(wizard->smtp_password_label))
960 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_password_label), 1, 0.5);
961 gtk_table_attach(GTK_TABLE(table), wizard->smtp_password,
962 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
965 wizard->smtp_use_ssl = gtk_check_button_new_with_label(
966 _("Use SSL to connect to SMTP server"));
967 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl),
969 gtk_table_attach(GTK_TABLE(table), wizard->smtp_use_ssl,
970 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
973 smtp_auth_changed(NULL, wizard);
977 static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
981 if (protocol == A_POP3) {
982 text = get_default_server(wizard, "pop");
983 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
984 gtk_widget_hide(wizard->recv_imap_label);
985 gtk_widget_hide(wizard->recv_imap_subdir);
986 gtk_widget_show(wizard->recv_username);
987 gtk_widget_show(wizard->recv_password);
988 gtk_widget_show(wizard->recv_username_label);
989 gtk_widget_show(wizard->recv_password_label);
990 gtk_widget_hide(wizard->no_imap_warning);
992 gtk_widget_show(wizard->recv_use_ssl);
994 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
995 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
996 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
998 } else if (protocol == A_IMAP4) {
1000 text = get_default_server(wizard, "imap");
1001 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1002 gtk_widget_show(wizard->recv_imap_label);
1003 gtk_widget_show(wizard->recv_imap_subdir);
1004 gtk_widget_show(wizard->recv_username);
1005 gtk_widget_show(wizard->recv_password);
1006 gtk_widget_show(wizard->recv_username_label);
1007 gtk_widget_show(wizard->recv_password_label);
1008 gtk_widget_hide(wizard->no_imap_warning);
1010 gtk_widget_show(wizard->recv_use_ssl);
1012 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
1013 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1014 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1017 gtk_widget_hide(wizard->recv_imap_label);
1018 gtk_widget_hide(wizard->recv_imap_subdir);
1019 gtk_widget_hide(wizard->recv_username);
1020 gtk_widget_hide(wizard->recv_password);
1021 gtk_widget_hide(wizard->recv_username_label);
1022 gtk_widget_hide(wizard->recv_password_label);
1023 gtk_widget_show(wizard->no_imap_warning);
1025 gtk_widget_hide(wizard->recv_use_ssl);
1027 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, FALSE);
1029 } else if (protocol == A_LOCAL) {
1030 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
1031 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Local mailbox:</span>"));
1032 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1033 gtk_widget_hide(wizard->no_imap_warning);
1034 gtk_widget_hide(wizard->recv_imap_label);
1035 gtk_widget_hide(wizard->recv_imap_subdir);
1036 gtk_widget_hide(wizard->recv_username);
1037 gtk_widget_hide(wizard->recv_password);
1038 gtk_widget_hide(wizard->recv_username_label);
1039 gtk_widget_hide(wizard->recv_password_label);
1041 gtk_widget_hide(wizard->recv_use_ssl);
1043 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1047 static void wizard_protocol_changed(GtkMenuItem *menuitem, gpointer data)
1049 WizardWindow *wizard = (WizardWindow *)data;
1050 RecvProtocol protocol;
1051 protocol = GPOINTER_TO_INT
1052 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
1054 wizard_protocol_change(wizard, protocol);
1057 static GtkWidget* recv_page (WizardWindow * wizard)
1060 GtkWidget *table = gtk_table_new(6,2, FALSE);
1062 GtkWidget *table = gtk_table_new(5,2, FALSE);
1064 GtkWidget *menu = gtk_menu_new();
1065 GtkWidget *menuitem;
1070 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1071 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1073 wizard->recv_type = gtk_option_menu_new();
1075 MENUITEM_ADD (menu, menuitem, _("POP3"), A_POP3);
1076 g_signal_connect(G_OBJECT(menuitem), "activate",
1077 G_CALLBACK(wizard_protocol_changed),
1080 MENUITEM_ADD (menu, menuitem, _("IMAP"), A_IMAP4);
1081 g_signal_connect(G_OBJECT(menuitem), "activate",
1082 G_CALLBACK(wizard_protocol_changed),
1085 MENUITEM_ADD (menu, menuitem, _("Local mbox file"), A_LOCAL);
1086 g_signal_connect(G_OBJECT(menuitem), "activate",
1087 G_CALLBACK(wizard_protocol_changed),
1090 gtk_option_menu_set_menu (GTK_OPTION_MENU (wizard->recv_type), menu);
1091 switch(tmpl.recvtype) {
1104 gtk_option_menu_set_history(GTK_OPTION_MENU (wizard->recv_type), index);
1105 GTK_TABLE_ADD_ROW_AT(table, _("<span weight=\"bold\">Server type:</span>"),
1106 wizard->recv_type, i); i++;
1108 wizard->recv_server = gtk_entry_new();
1109 text = get_default_server(wizard, "pop");
1110 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1113 wizard->recv_label = gtk_label_new(_("<span weight=\"bold\">Server address:</span>"));
1114 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1115 gtk_table_attach(GTK_TABLE(table), wizard->recv_label,
1116 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
1117 if (GTK_IS_MISC(wizard->recv_label))
1118 gtk_misc_set_alignment(GTK_MISC(wizard->recv_label), 1, 0.5);
1119 gtk_table_attach(GTK_TABLE(table), wizard->recv_server,
1120 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
1123 wizard->recv_username = gtk_entry_new();
1124 wizard->recv_username_label = gtk_label_new(_("<span weight=\"bold\">Username:</span>"));
1125 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_username_label), TRUE);
1126 gtk_table_attach(GTK_TABLE(table), wizard->recv_username_label,
1127 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
1128 if (GTK_IS_MISC(wizard->recv_username_label))
1129 gtk_misc_set_alignment(GTK_MISC(wizard->recv_username_label), 1, 0.5);
1130 gtk_table_attach(GTK_TABLE(table), wizard->recv_username,
1131 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
1134 text = get_default_account(wizard);
1135 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
1138 wizard->recv_password = gtk_entry_new();
1139 gtk_entry_set_text(GTK_ENTRY(wizard->recv_password), tmpl.recvpass?tmpl.recvpass:"");
1140 wizard->recv_password_label = gtk_label_new(_("Password:"));
1141 gtk_table_attach(GTK_TABLE(table), wizard->recv_password_label,
1142 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
1143 if (GTK_IS_MISC(wizard->recv_password_label))
1144 gtk_misc_set_alignment(GTK_MISC(wizard->recv_password_label), 1, 0.5);
1145 gtk_table_attach(GTK_TABLE(table), wizard->recv_password,
1146 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
1147 gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_password), FALSE);
1150 wizard->recv_imap_subdir = gtk_entry_new();
1151 gtk_entry_set_text(GTK_ENTRY(wizard->recv_imap_subdir), tmpl.imapdir?tmpl.imapdir:"");
1152 wizard->recv_imap_label = gtk_label_new(_("IMAP server directory:"));
1154 gtk_table_attach(GTK_TABLE(table), wizard->recv_imap_label,
1155 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
1156 if (GTK_IS_MISC(wizard->recv_imap_label))
1157 gtk_misc_set_alignment(GTK_MISC(wizard->recv_imap_label), 1, 0.5);
1158 gtk_table_attach(GTK_TABLE(table), wizard->recv_imap_subdir,
1159 1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
1163 wizard->no_imap_warning = gtk_label_new(_(
1164 "<span weight=\"bold\">Warning: this version of Claws Mail\n"
1165 "has been built without IMAP support.</span>"));
1166 gtk_label_set_use_markup(GTK_LABEL(wizard->no_imap_warning), TRUE);
1167 gtk_table_attach(GTK_TABLE(table), wizard->no_imap_warning,
1168 0,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
1170 wizard->recv_use_ssl = gtk_check_button_new_with_label(
1171 _("Use SSL to connect to receiving server"));
1172 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl),
1174 gtk_table_attach(GTK_TABLE(table), wizard->recv_use_ssl,
1175 0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
1182 wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
1184 WizardWindow * wizard = (WizardWindow *)data;
1185 int current_page, num_pages;
1186 GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(wizard->recv_type));
1187 GtkWidget *menuitem = gtk_menu_get_active(GTK_MENU(menu));
1188 gint protocol = GPOINTER_TO_INT
1189 (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
1190 gboolean skip_mailbox_page = FALSE;
1192 if (protocol == A_IMAP4) {
1193 skip_mailbox_page = TRUE;
1196 num_pages = g_slist_length(wizard->pages);
1198 current_page = gtk_notebook_get_current_page (
1199 GTK_NOTEBOOK(wizard->notebook));
1200 if (response == CANCEL)
1202 wizard->result = FALSE;
1203 wizard->finished = TRUE;
1204 gtk_widget_destroy (GTK_WIDGET(dialog));
1206 else if (response == FINISHED)
1208 if (!wizard_write_config(wizard)) {
1209 current_page = gtk_notebook_get_current_page (
1210 GTK_NOTEBOOK(wizard->notebook));
1213 wizard->result = TRUE;
1214 wizard->finished = TRUE;
1215 gtk_widget_destroy (GTK_WIDGET(dialog));
1219 if (response == GO_BACK)
1221 if (current_page > 0) {
1223 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1227 gtk_notebook_set_current_page (
1228 GTK_NOTEBOOK(wizard->notebook),
1232 else if (response == GO_FORWARD)
1234 if (current_page < (num_pages-1)) {
1236 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1240 gtk_notebook_set_current_page (
1241 GTK_NOTEBOOK(wizard->notebook),
1246 gtk_dialog_set_response_sensitive (dialog, GO_BACK,
1248 gtk_dialog_set_response_sensitive (dialog, GO_FORWARD,
1249 current_page < (num_pages - 1));
1250 gtk_dialog_set_response_sensitive (dialog, FINISHED,
1251 current_page == (num_pages - 1));
1255 static gint wizard_close_cb(GtkWidget *widget, GdkEventAny *event,
1258 WizardWindow *wizard = (WizardWindow *)data;
1259 wizard->result = FALSE;
1260 wizard->finished = TRUE;
1265 #define PACK_WARNING(text) { \
1266 label = gtk_label_new(text); \
1267 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); \
1268 gtk_box_pack_end(GTK_BOX(widget), label, FALSE, FALSE, 0); \
1271 gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
1272 WizardWindow *wizard = g_new0(WizardWindow, 1);
1280 wizard->mainwin = mainwin;
1281 wizard->create_mailbox = create_mailbox;
1283 gtk_widget_hide(mainwin->window);
1285 wizard_read_defaults();
1287 wizard->window = gtk_dialog_new_with_buttons (_("Claws Mail Setup Wizard"),
1289 GTK_STOCK_GO_BACK, GO_BACK,
1290 GTK_STOCK_GO_FORWARD, GO_FORWARD,
1291 GTK_STOCK_SAVE, FINISHED,
1292 GTK_STOCK_CANCEL, CANCEL,
1295 g_signal_connect(wizard->window, "response",
1296 G_CALLBACK(wizard_response_cb), wizard);
1297 gtk_widget_realize(wizard->window);
1298 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window),
1300 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1302 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1304 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1306 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1309 wizard->notebook = gtk_notebook_new();
1310 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(wizard->notebook), FALSE);
1311 gtk_notebook_set_show_border(GTK_NOTEBOOK(wizard->notebook), FALSE);
1312 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(wizard->window)->vbox),
1313 wizard->notebook, TRUE, TRUE, 0);
1315 wizard->pages = NULL;
1317 /*welcome page: 0 */
1319 page = create_page(wizard, _("Welcome to Claws Mail"));
1321 wizard->pages = g_slist_append(wizard->pages, page);
1322 widget = stock_pixmap_widget(wizard->window,
1323 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1325 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1327 text = g_strdup(_("Welcome to the Claws Mail setup wizard.\n\n"
1328 "We will begin by defining some basic "
1329 "information about you and your most common "
1330 "mail options so that you can start to use "
1331 "Claws Mail in less than five minutes."));
1332 widget = gtk_label_new(text);
1333 gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
1334 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1340 widget = create_page (wizard, _("About You"));
1341 gtk_box_pack_start (GTK_BOX(widget), user_page(wizard), FALSE, FALSE, 0);
1342 PACK_WARNING(_("Bold fields must be completed"));
1344 wizard->pages = g_slist_append(wizard->pages, widget);
1346 /* recv+auth page: 2 */
1349 widget = create_page (wizard, _("Receiving mail"));
1350 gtk_box_pack_start (GTK_BOX(widget), recv_page(wizard), FALSE, FALSE, 0);
1351 PACK_WARNING(_("Bold fields must be completed"));
1353 wizard->pages = g_slist_append(wizard->pages, widget);
1358 widget = create_page (wizard, _("Sending mail"));
1359 gtk_box_pack_start (GTK_BOX(widget), smtp_page(wizard), FALSE, FALSE, 0);
1360 PACK_WARNING(_("Bold fields must be completed"));
1362 wizard->pages = g_slist_append(wizard->pages, widget);
1364 /* mailbox page: 4 */
1365 if (create_mailbox) {
1368 widget = create_page (wizard, _("Saving mail on disk"));
1369 gtk_box_pack_start (GTK_BOX(widget), mailbox_page(wizard), FALSE, FALSE, 0);
1370 PACK_WARNING(_("Bold fields must be completed"));
1372 wizard->pages = g_slist_append(wizard->pages, widget);
1378 page = create_page(wizard, _("Configuration finished"));
1380 wizard->pages = g_slist_append(wizard->pages, page);
1381 widget = stock_pixmap_widget(wizard->window,
1382 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1384 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1386 text = g_strdup(_("Claws Mail is now ready.\n\n"
1387 "Click Save to start."));
1388 widget = gtk_label_new(text);
1389 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1393 for (cur = wizard->pages; cur && cur->data; cur = cur->next) {
1394 gtk_notebook_append_page (GTK_NOTEBOOK(wizard->notebook),
1395 GTK_WIDGET(cur->data), NULL);
1398 g_signal_connect(G_OBJECT(wizard->window), "delete_event",
1399 G_CALLBACK(wizard_close_cb), wizard);
1400 gtk_widget_show_all (wizard->window);
1402 gtk_widget_hide(wizard->recv_imap_label);
1403 gtk_widget_hide(wizard->recv_imap_subdir);
1405 wizard_protocol_change(wizard, tmpl.recvtype);
1407 while (!wizard->finished)
1408 gtk_main_iteration();
1410 result = wizard->result;
1414 gtk_widget_show(mainwin->window);