2007-10-04 [paul] 3.0.2cvs7
[claws.git] / src / account.c
index 1a8bb8b902d345a29ab58d580284a37e6a89381d..032f02e30fa238d76ede84c2ce238d28916ea1f8 100644 (file)
@@ -4,7 +4,7 @@
  *
  * 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
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,8 +13,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 #ifdef HAVE_CONFIG_H
@@ -53,7 +53,7 @@
 #include "filtering.h"
 
 enum {
-       ACCOUNT_IS_DEFAULT,             /* GDK_TYPE_PIXMAP! */
+       ACCOUNT_IS_DEFAULT,
        ACCOUNT_ENABLE_GET_ALL, 
        ACCOUNT_NAME,
        ACCOUNT_PROTOCOL,
@@ -87,8 +87,6 @@ static struct EditAccount {
        GtkWidget *close_btn;
 } edit_account;
 
-static GdkPixbuf *mark_pixbuf;
-
 static void account_edit_create                (void);
 static void          account_destroy           (PrefsAccount   *ac_prefs);
 static void          account_set_as_default    (PrefsAccount   *ac_prefs);
@@ -136,7 +134,6 @@ static void account_list_view_insert_account_item (GtkListStore     *list_store,
                                                   PrefsAccount *account_data);
 
 static GtkWidget *account_list_view_create     (void);
-static void account_create_list_view_images    (GtkWidget *list_view);
 static void account_create_list_view_columns   (GtkWidget *list_view);
 
 static gint account_list_view_get_selected_account_id          (GtkWidget *list_view);
@@ -582,6 +579,8 @@ FolderItem *account_get_special_folder(PrefsAccount *ac_prefs,
                if (!item) {
                        if (ac_prefs->folder)
                                item = FOLDER(ac_prefs->folder)->outbox;
+                       if (!item)
+                               item = folder_get_default_outbox_for_class(F_MH);
                        if (!item)
                                item = folder_get_default_outbox();
                }
@@ -594,6 +593,8 @@ FolderItem *account_get_special_folder(PrefsAccount *ac_prefs,
                if (!item) {
                        if (ac_prefs->folder)
                                item = FOLDER(ac_prefs->folder)->draft;
+                       if (!item)
+                               item = folder_get_default_draft_for_class(F_MH);
                        if (!item)
                                item = folder_get_default_draft();
                }
@@ -606,6 +607,8 @@ FolderItem *account_get_special_folder(PrefsAccount *ac_prefs,
                if (!item) {
                        if (ac_prefs->folder)
                                item = FOLDER(ac_prefs->folder)->queue;
+                       if (!item)
+                               item = folder_get_default_queue_for_class(F_MH);
                        if (!item)
                                item = folder_get_default_queue();
                }
@@ -618,6 +621,8 @@ FolderItem *account_get_special_folder(PrefsAccount *ac_prefs,
                if (!item) {
                        if (ac_prefs->folder)
                                item = FOLDER(ac_prefs->folder)->trash;
+                       if (!item)
+                               item = folder_get_default_trash_for_class(F_MH);
                        if (!item)
                                item = folder_get_default_trash();
                }
@@ -680,7 +685,7 @@ static void account_edit_create(void)
 
        GtkWidget *default_btn;
 
-       GtkWidget *hbbox;
+       GtkWidget *confirm_area;
        GtkWidget *help_btn;
        GtkWidget *close_btn;
 
@@ -713,9 +718,11 @@ static void account_edit_create(void)
 
        label = gtk_label_new
                (_("Using 'Get Mail' will retrieve messages from your Accounts "
-                  "in the order given, the checkbox in the 'G' column indicates "
-                  "which accounts will be included."));
+                  "in the order given, the checkbox indicates which accounts "
+                  "will be included. Bold text indicates the default account."));
        gtk_widget_show (label);
+       gtk_widget_set_size_request(GTK_WIDGET(label), 
+                                   prefs_common.accountswin_width-8, -1);
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
        gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
@@ -780,27 +787,19 @@ static void account_edit_create(void)
        gtk_widget_show (hbox);
        gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
-       vbox2 = gtk_vbox_new(FALSE, 0);
-       gtk_widget_show (vbox2);
-       gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
-
        default_btn = gtk_button_new_with_mnemonic
                (_(" _Set as default account "));
        gtk_widget_show (default_btn);
-       gtk_box_pack_start (GTK_BOX (vbox2), default_btn, TRUE, FALSE, 0);
+       gtk_box_pack_start (GTK_BOX (hbox), default_btn, FALSE, FALSE, 0);
        g_signal_connect (G_OBJECT(default_btn), "clicked",
                          G_CALLBACK (account_set_default), NULL);
 
-       hbbox = gtk_hbutton_box_new();
-       gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END);
-       gtk_box_set_spacing(GTK_BOX(hbbox), 5);
-
-       gtkut_stock_button_set_create_with_help(&hbbox, &help_btn,
+       gtkut_stock_button_set_create_with_help(&confirm_area, &help_btn,
                        &close_btn, GTK_STOCK_CLOSE,
                        NULL, NULL, NULL, NULL);
-       gtk_widget_show(hbbox);
+       gtk_widget_show(confirm_area);
 
-       gtk_box_pack_end (GTK_BOX (hbox), hbbox, FALSE, FALSE, 0);
+       gtk_box_pack_end (GTK_BOX (hbox), confirm_area, FALSE, FALSE, 0);
        gtk_widget_grab_default (close_btn);
 
        g_signal_connect (G_OBJECT (close_btn), "clicked",
@@ -810,7 +809,6 @@ static void account_edit_create(void)
                        G_CALLBACK(manual_open_with_anchor_cb),
                        MANUAL_ANCHOR_ACCOUNTPREFS);
 
-       account_create_list_view_images(list_view);
 
        g_signal_connect(G_OBJECT(window), "size_allocate",
                         G_CALLBACK(account_size_allocate_cb), NULL);
@@ -910,33 +908,31 @@ static void account_clone(GtkWidget *widget, gpointer data)
        ACP_FASSIGN(use_mail_command);
        ACP_FDUP(mail_command);
        
-#if USE_OPENSSL
        ACP_FASSIGN(ssl_pop);
        ACP_FASSIGN(ssl_imap);
        ACP_FASSIGN(ssl_nntp);
        ACP_FASSIGN(ssl_smtp);
        ACP_FASSIGN(use_nonblocking_ssl);
-#endif /* USE_OPENSSL */
        
        ac_clon->tmp_pass = NULL;
 
        /* receive */
+       ACP_FASSIGN(use_apop_auth);
        ACP_FASSIGN(rmmail);
        ACP_FASSIGN(msg_leave_time);
-       ACP_FASSIGN(getall);
        ACP_FASSIGN(recv_at_getall);
        ACP_FASSIGN(sd_rmmail_on_download);
-       ACP_FASSIGN(sd_filter_on_recv);
        ACP_FASSIGN(enable_size_limit);
        ACP_FASSIGN(size_limit);
        ACP_FASSIGN(filter_on_recv);
+       ACP_FASSIGN(filterhook_on_recv);
        ACP_FDUP(inbox);
+       ACP_FDUP(local_inbox);
        ACP_FASSIGN(max_articles);
 
        ACP_FASSIGN(imap_auth_type);
 
        /* send */
-       ACP_FASSIGN(gen_msgid);
        ACP_FASSIGN(add_customhdr);
        ACP_FASSIGN(use_smtp_auth);
        ACP_FASSIGN(smtp_auth_type);
@@ -975,10 +971,27 @@ static void account_clone(GtkWidget *widget, gpointer data)
         ACP_FDUP(auto_bcc);
         ACP_FASSIGN(set_autoreplyto);
         ACP_FDUP(auto_replyto);
+       ACP_FASSIGN(enable_default_dictionary);
+       ACP_FDUP(default_dictionary);
+       ACP_FASSIGN(enable_default_alt_dictionary);
+       ACP_FDUP(default_alt_dictionary);
+       ACP_FASSIGN(compose_with_format);
+       ACP_FDUP(compose_subject_format);
+       ACP_FDUP(compose_body_format);
+       ACP_FASSIGN(reply_with_format);
+       ACP_FDUP(reply_quotemark);
+       ACP_FDUP(reply_body_format);
+       ACP_FASSIGN(forward_with_format);
+       ACP_FDUP(forward_quotemark);
+       ACP_FDUP(forward_body_format);
 
         /* privacy */
+       ACP_FDUP(default_privacy_system);
         ACP_FASSIGN(default_encrypt);
+       ACP_FASSIGN(default_encrypt_reply);
         ACP_FASSIGN(default_sign);
+       ACP_FASSIGN(save_encrypted_as_clear_text);
+       ACP_FASSIGN(encrypt_to_self);
        
         /* advanced */
         ACP_FASSIGN(set_smtpport);
@@ -998,9 +1011,13 @@ static void account_clone(GtkWidget *widget, gpointer data)
         ACP_FDUP(tunnelcmd);
 
         ACP_FDUP(imap_dir);
+       ACP_FASSIGN(imap_subsonly);
+       ACP_FASSIGN(low_bandwidth);
 
         ACP_FASSIGN(set_sent_folder);
         ACP_FDUP(sent_folder);
+       ACP_FASSIGN(set_queue_folder);
+       ACP_FDUP(queue_folder);
         ACP_FASSIGN(set_draft_folder);
         ACP_FDUP(draft_folder);
         ACP_FASSIGN(set_trash_folder);
@@ -1234,15 +1251,19 @@ static void account_list_view_add(PrefsAccount *ac_prefs)
                   ac_prefs->protocol == A_NNTP ?
                  (ac_prefs->ssl_nntp == SSL_TUNNEL ?
                   "NNTP (SSL)" : "NNTP") :
-                  "";
+                  ac_prefs->protocol == A_LOCAL ? "Local" :
+                  ac_prefs->protocol == A_NONE ?  "SMTP" : "-";
 #else
        protocol = ac_prefs->protocol == A_POP3  ? "POP3" :
                   ac_prefs->protocol == A_IMAP4 ? "IMAP4" :
                   ac_prefs->protocol == A_LOCAL ? "Local" :
-                  ac_prefs->protocol == A_NNTP  ? "NNTP" : "";
+                  ac_prefs->protocol == A_NNTP  ? "NNTP" :
+                  ac_prefs->protocol == A_NONE ?  "SMTP" : "-";
 #endif
-       server= ac_prefs->protocol == A_NNTP
-               ? ac_prefs->nntp_server : ac_prefs->recv_server;
+       server= ac_prefs->protocol == A_NNTP ? ac_prefs->nntp_server :
+                  ac_prefs->protocol == A_LOCAL ?  "-" :
+                  ac_prefs->protocol == A_NONE ? ac_prefs->smtp_server :
+                  ac_prefs->recv_server;
 
        has_getallbox = (ac_prefs->protocol == A_POP3  ||
                         ac_prefs->protocol == A_IMAP4 ||
@@ -1387,7 +1408,7 @@ PrefsAccount *account_get_reply_account(MsgInfo *msginfo, gboolean reply_autosel
 static GtkListStore* account_create_data_store(void)
 {
        return gtk_list_store_new(N_ACCOUNT_COLUMNS,
-                                GDK_TYPE_PIXBUF,       /* ACCOUNT_IS_DEFAULT */
+                                G_TYPE_INT,            /* ACCOUNT_IS_DEFAULT */
                                 G_TYPE_BOOLEAN,        /* ACCOUNT_ENABLE_GET_ALL */
                                 G_TYPE_STRING,         /* ACCOUNT_NAME */
                                 G_TYPE_STRING,         /* ACCOUNT_PROTOCOL */
@@ -1414,7 +1435,7 @@ static void account_list_view_insert_account_item(GtkListStore *list_store,
        
        gtk_list_store_append(list_store, &iter);
        gtk_list_store_set(list_store, &iter, 
-                          ACCOUNT_IS_DEFAULT,     is_default ? mark_pixbuf : NULL,
+                          ACCOUNT_IS_DEFAULT,     is_default ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
                           ACCOUNT_ENABLE_GET_ALL, is_get_all,
                           ACCOUNT_NAME,           account_name,
                           ACCOUNT_PROTOCOL,       protocol,
@@ -1426,7 +1447,6 @@ static void account_list_view_insert_account_item(GtkListStore *list_store,
 /*!
  *\brief       Create and set up account list view, including tasks like
  *             creating the data store (\ref account_create_data_store()),
- *             creating images for the list view (\ref account_create_list_view_images()),
  *             and setting up the account list's individual columns (\ref 
  *             account_create_list_view_columns()).
  *
@@ -1467,27 +1487,12 @@ static GtkWidget *account_list_view_create(void)
        return GTK_WIDGET(list_view);
 }
 
-static void account_create_list_view_images(GtkWidget *list_view)
-{
-       stock_pixbuf_gdk(list_view, STOCK_PIXMAP_MARK, &mark_pixbuf);
-}
-
 static void account_create_list_view_columns(GtkWidget *list_view)
 {
        GtkTreeViewColumn *column;
        GtkCellRenderer *renderer;
        GtkTooltips *tooltips = gtk_tooltips_new();
 
-       renderer = gtk_cell_renderer_pixbuf_new();
-       column = gtk_tree_view_column_new_with_attributes
-               (Q_("Accounts List Default Column Name|D"), renderer,
-                "pixbuf", ACCOUNT_IS_DEFAULT,
-                NULL);
-       gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), column);           
-       gtk_tree_view_column_set_alignment (column, 0.5);
-       gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), column->button,
-                       _("Default account"), NULL);
-
        renderer = gtk_cell_renderer_toggle_new();
        g_object_set(renderer, 
                     "radio", FALSE, 
@@ -1509,6 +1514,7 @@ static void account_create_list_view_columns(GtkWidget *list_view)
        column = gtk_tree_view_column_new_with_attributes
                (_("Name"), renderer,
                 "text", ACCOUNT_NAME,
+                "weight", ACCOUNT_IS_DEFAULT,
                 NULL);
        gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), column);          
        
@@ -1516,6 +1522,7 @@ static void account_create_list_view_columns(GtkWidget *list_view)
        column = gtk_tree_view_column_new_with_attributes
                (_("Protocol"), renderer,
                 "text", ACCOUNT_PROTOCOL,
+                "weight", ACCOUNT_IS_DEFAULT,
                 NULL);
        gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), column);           
        
@@ -1523,6 +1530,7 @@ static void account_create_list_view_columns(GtkWidget *list_view)
        column = gtk_tree_view_column_new_with_attributes
                (_("Server"), renderer,
                 "text", ACCOUNT_SERVER,
+                "weight", ACCOUNT_IS_DEFAULT,
                 NULL);
        gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), column);           
 }
@@ -1638,20 +1646,19 @@ static gboolean set_new_default_account(GtkTreeModel *model,
                                        gint         *account_id)
 {
        PrefsAccount *account = NULL;
-       GdkPixbuf *pixbuf;
+       PangoWeight weight;
        
        gtk_tree_model_get(model, iter, 
                           ACCOUNT_DATA, &account, 
                           -1);
 
        if (*account_id == account->account_id)
-               pixbuf = NULL;
+               weight = PANGO_WEIGHT_NORMAL;
        else
-               pixbuf = mark_pixbuf;
-       
+               weight = PANGO_WEIGHT_BOLD;
+
        gtk_list_store_set(GTK_LIST_STORE(model), iter, 
-                          ACCOUNT_IS_DEFAULT, pixbuf,
-                          -1);
+                          ACCOUNT_IS_DEFAULT, weight, -1);
 
        return FALSE;
 }