2007-03-12 [colin] 2.8.1cvs8
[claws.git] / src / wizard.c
index 5d804e0e5a5653a0e1929d1a51673be0333621e6..7a74bb5d06e97740971c17a1362380e78c65906a 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Claws Mail team
- * This file (C) 2004 Colin Leroy
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2007 Colin Leroy <colin@colino.net> 
+ * and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -107,6 +107,7 @@ typedef struct
        GtkWidget *recv_password_label;
        GtkWidget *recv_imap_label;
        GtkWidget *recv_imap_subdir;
+       GtkWidget *subsonly_checkbtn;
        GtkWidget *no_imap_warning;
 #ifdef USE_OPENSSL
        GtkWidget *smtp_use_ssl;
@@ -135,6 +136,7 @@ typedef struct _AccountTemplate {
        gchar *recvuser;
        gchar *recvpass;
        gchar *imapdir;
+       gboolean subsonly;
        gchar *mboxfile;
        gchar *mailbox;
        gboolean smtpssl;
@@ -170,6 +172,8 @@ static PrefParam template_params[] = {
         &tmpl.recvpass, P_STRING, NULL, NULL, NULL},
        {"imapdir", "",
         &tmpl.imapdir, P_STRING, NULL, NULL, NULL},
+       {"subsonly", "TRUE",
+        &tmpl.subsonly, P_BOOL, NULL, NULL, NULL},
        {"mboxfile", "/var/mail/$LOGIN",
         &tmpl.mboxfile, P_STRING, NULL, NULL, NULL},
        {"mailbox", "Mail",
@@ -236,10 +240,14 @@ static gchar *accountrc_tmpl =
        "#default is empty\n"
        "#recvpass=\n"
        "\n"
-       "#imap dir if imap (relative to the home on the server\n"
+       "#imap dir if imap (relative to the home on the server)\n"
        "#default is empty\n"
        "#imapdir=\n"
        "\n"
+       "#show subscribed folders only, if imap\n"
+       "#default is TRUE\n"
+       "#subsonly=\n"
+       "\n"
        "#mbox file if local\n"
        "#you can use $LOGIN here\n"
        "#default is /var/mail/$LOGIN\n"
@@ -677,6 +685,10 @@ static gboolean wizard_write_config(WizardWindow *wizard)
                                gtk_entry_get_text(GTK_ENTRY(wizard->organization)));
        prefs_account->smtp_server = g_strdup(smtp_server);
 
+       prefs_account->inbox = g_strdup_printf("#mh/%s/inbox",
+                       g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name))));
+       prefs_account->local_inbox = g_strdup(prefs_account->inbox);
+
        if (prefs_account->protocol != A_LOCAL)
                prefs_account->recv_server = g_strdup(recv_server);
        else
@@ -729,6 +741,9 @@ static gboolean wizard_write_config(WizardWindow *wizard)
                if (directory && strlen(directory)) {
                        prefs_account->imap_dir = g_strdup(directory);
                }
+               prefs_account->imap_subsonly = 
+                       gtk_toggle_button_get_active(
+                               GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn));
                g_free(directory);
        }
 
@@ -1025,6 +1040,7 @@ static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
                gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
                gtk_widget_hide(wizard->recv_imap_label);
                gtk_widget_hide(wizard->recv_imap_subdir);
+               gtk_widget_hide(wizard->subsonly_checkbtn);
                gtk_widget_show(wizard->recv_username);
                gtk_widget_show(wizard->recv_password);
                gtk_widget_show(wizard->recv_username_label);
@@ -1044,6 +1060,7 @@ static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
                gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
                gtk_widget_show(wizard->recv_imap_label);
                gtk_widget_show(wizard->recv_imap_subdir);
+               gtk_widget_show(wizard->subsonly_checkbtn);
                gtk_widget_show(wizard->recv_username);
                gtk_widget_show(wizard->recv_password);
                gtk_widget_show(wizard->recv_username_label);
@@ -1060,6 +1077,7 @@ static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
 #else
                gtk_widget_hide(wizard->recv_imap_label);
                gtk_widget_hide(wizard->recv_imap_subdir);
+               gtk_widget_hide(wizard->subsonly_checkbtn);
                gtk_widget_hide(wizard->recv_username);
                gtk_widget_hide(wizard->recv_password);
                gtk_widget_hide(wizard->recv_username_label);
@@ -1078,6 +1096,7 @@ static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
                gtk_widget_hide(wizard->no_imap_warning);
                gtk_widget_hide(wizard->recv_imap_label);
                gtk_widget_hide(wizard->recv_imap_subdir);
+               gtk_widget_hide(wizard->subsonly_checkbtn);
                gtk_widget_hide(wizard->recv_username);
                gtk_widget_hide(wizard->recv_password);
                gtk_widget_hide(wizard->recv_username_label);
@@ -1103,9 +1122,9 @@ static void wizard_protocol_changed(GtkMenuItem *menuitem, gpointer data)
 static GtkWidget* recv_page (WizardWindow * wizard)
 {
 #ifdef USE_OPENSSL
-       GtkWidget *table = gtk_table_new(7,2, FALSE);
+       GtkWidget *table = gtk_table_new(8,2, FALSE);
 #else
-       GtkWidget *table = gtk_table_new(5,2, FALSE);
+       GtkWidget *table = gtk_table_new(6,2, FALSE);
 #endif
        GtkWidget *menu = gtk_menu_new();
        GtkWidget *menuitem;
@@ -1212,6 +1231,16 @@ static GtkWidget* recv_page (WizardWindow * wizard)
 
        i++;
        
+       wizard->subsonly_checkbtn = gtk_check_button_new_with_label(
+                       _("Show only subscribed folders"));
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn),
+                       tmpl.subsonly);
+       gtk_table_attach(GTK_TABLE(table), wizard->subsonly_checkbtn,                         
+                        0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);            
+
+       i++;
+       
+       
        wizard->no_imap_warning = gtk_label_new(_(
                          "<span weight=\"bold\">Warning: this version of Claws Mail\n"
                          "has been built without IMAP support.</span>"));
@@ -1461,6 +1490,7 @@ gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
 
        gtk_widget_hide(wizard->recv_imap_label);
        gtk_widget_hide(wizard->recv_imap_subdir);
+       gtk_widget_hide(wizard->subsonly_checkbtn);
 
        wizard_protocol_change(wizard, tmpl.recvtype);