2008-08-28 [colin] 3.5.0cvs78
[claws.git] / src / account.c
index caad6d8bd8778c4a858edb2a91b4620a9dc73c49..dd6db89d32ed94e23f1ae602c1f40301959be7e6 100644 (file)
@@ -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);
@@ -110,10 +108,11 @@ static gint account_delete_event  (GtkWidget      *widget,
                                         gpointer        data);
 static void account_size_allocate_cb(GtkWidget *widget,
                                         GtkAllocation *allocation);
+#ifndef MAEMO
 static gboolean account_key_pressed    (GtkWidget      *widget,
                                         GdkEventKey    *event,
                                         gpointer        data);
-
+#endif
 static void account_list_view_add      (PrefsAccount   *ac_prefs);
 static void account_list_view_set      (void);
 
@@ -136,7 +135,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);
@@ -181,7 +179,7 @@ static void account_row_changed_while_drag_drop     (GtkTreeModel *model,
                                                 gpointer      arg3,
                                                 GtkTreeView  *list_view);
 
-void account_flush_state(void)
+static void account_flush_state(void)
 {
        account_set_menu();
        main_window_reflect_prefs_all();
@@ -300,11 +298,11 @@ PrefsAccount *account_find_from_smtp_server(const gchar *address,
  * account_find_from_address:
  * @address: Email address string.
  *
- * Find a mail (not news) account with the specified email address.
+ * Find a mail (not news if newsgroups_ok is FALSE) account with the specified email address.
  *
  * Return value: The found account, or NULL if not found.
  */
-PrefsAccount *account_find_from_address(const gchar *address)
+PrefsAccount *account_find_from_address(const gchar *address, gboolean newsgroups_ok)
 {
        GList *cur;
        PrefsAccount *ac;
@@ -313,7 +311,7 @@ PrefsAccount *account_find_from_address(const gchar *address)
 
        for (cur = account_list; cur != NULL; cur = cur->next) {
                ac = (PrefsAccount *)cur->data;
-               if (ac->protocol != A_NNTP && ac->address &&
+               if ((ac->protocol != A_NNTP || newsgroups_ok) && ac->address &&
                    g_ascii_strcasecmp(address, ac->address) == 0)
                        return ac;
        }
@@ -373,7 +371,7 @@ GList *account_get_list(void)
        return account_list;
 }
 
-void account_edit_open(void)
+void account_edit_open(gpointer a, gpointer b)
 {
        inc_lock();
 
@@ -688,7 +686,7 @@ static void account_edit_create(void)
 
        GtkWidget *default_btn;
 
-       GtkWidget *hbbox;
+       GtkWidget *confirm_area;
        GtkWidget *help_btn;
        GtkWidget *close_btn;
 
@@ -721,9 +719,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);
@@ -788,27 +788,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",
@@ -818,7 +810,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);
@@ -1001,6 +992,7 @@ static void account_clone(GtkWidget *widget, gpointer data)
         ACP_FASSIGN(default_encrypt);
        ACP_FASSIGN(default_encrypt_reply);
         ACP_FASSIGN(default_sign);
+       ACP_FASSIGN(default_sign_reply);
        ACP_FASSIGN(save_encrypted_as_clear_text);
        ACP_FASSIGN(encrypt_to_self);
        
@@ -1018,8 +1010,10 @@ static void account_clone(GtkWidget *widget, gpointer data)
         ACP_FASSIGN(mark_crosspost_read);
         ACP_FASSIGN(crosspost_col);
 
+#ifndef G_OS_WIN32
         ACP_FASSIGN(set_tunnelcmd);
         ACP_FDUP(tunnelcmd);
+#endif
 
         ACP_FDUP(imap_dir);
        ACP_FASSIGN(imap_subsonly);
@@ -1230,7 +1224,7 @@ static gint account_delete_event(GtkWidget *widget, GdkEventAny *event,
        account_edit_close(NULL, NULL);
        return TRUE;
 }
-
+#ifndef MAEMO
 static gboolean account_key_pressed(GtkWidget *widget, GdkEventKey *event,
                                    gpointer data)
 {
@@ -1238,7 +1232,7 @@ static gboolean account_key_pressed(GtkWidget *widget, GdkEventKey *event,
                account_edit_close(NULL, NULL);
        return FALSE;
 }
-
+#endif
 static void account_list_view_add(PrefsAccount *ac_prefs)
 {
        GtkTreeView *list_view = GTK_TREE_VIEW(edit_account.list_view);
@@ -1248,7 +1242,7 @@ static void account_list_view_add(PrefsAccount *ac_prefs)
        gboolean getall;
 
        name = ac_prefs->account_name;
-#if USE_OPENSSL
+#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
        protocol = ac_prefs->protocol == A_POP3 ?
                  (ac_prefs->ssl_pop == SSL_TUNNEL ?
                   "POP3 (SSL)" :
@@ -1373,7 +1367,7 @@ PrefsAccount *account_get_reply_account(MsgInfo *msginfo, gboolean reply_autosel
                                if (!strchr(field, ',')) {
                                        Xstrdup_a(to, field, return NULL);
                                        extract_address(to);
-                                       account = account_find_from_address(to);
+                                       account = account_find_from_address(to, FALSE);
                                } else {
                                        gchar **split = g_strsplit(field, ",", -1);
                                        int i = -1;
@@ -1383,7 +1377,7 @@ PrefsAccount *account_get_reply_account(MsgInfo *msginfo, gboolean reply_autosel
                                                        break;
                                                Xstrdup_a(to, split[i], return NULL);
                                                extract_address(to);
-                                               account = account_find_from_address(to);
+                                               account = account_find_from_address(to, FALSE);
                                        } while (!account);
                                        g_strfreev(split);
                                }
@@ -1395,7 +1389,7 @@ PrefsAccount *account_get_reply_account(MsgInfo *msginfo, gboolean reply_autosel
                                (msginfo, deliveredto,sizeof deliveredto , "Delivered-To:")) { 
                                gchar *buf = deliveredto + strlen("Delivered-To:");
                                extract_address(buf);
-                               account = account_find_from_address(buf);
+                               account = account_find_from_address(buf, FALSE);
                        }
                }
        }
@@ -1419,7 +1413,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 */
@@ -1446,7 +1440,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,
@@ -1458,7 +1452,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()).
  *
@@ -1472,7 +1465,9 @@ static GtkWidget *account_list_view_create(void)
 
        list_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)));
        g_object_unref(G_OBJECT(store));
-
+#ifdef GENERIC_UMPC
+       g_object_set(list_view, "allow-checkbox-mode", FALSE, NULL);
+#endif
        gtk_tree_view_set_rules_hint(list_view, prefs_common.use_stripes_everywhere);
        gtk_tree_view_set_reorderable(list_view, TRUE);
        
@@ -1499,26 +1494,11 @@ 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);
+       CLAWS_TIP_DECL();
 
        renderer = gtk_cell_renderer_toggle_new();
        g_object_set(renderer, 
@@ -1531,8 +1511,8 @@ static void account_create_list_view_columns(GtkWidget *list_view)
                 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,
-                       _("'Get Mail' retrieves mail from the checked accounts"), NULL);
+       CLAWS_SET_TIP(column->button,
+                       _("'Get Mail' retrieves mail from the checked accounts"));
        g_signal_connect(G_OBJECT(renderer), "toggled",                      
                         G_CALLBACK(account_get_all_toggled),
                         list_view);
@@ -1541,6 +1521,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);          
        
@@ -1548,6 +1529,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);           
        
@@ -1555,6 +1537,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);           
 }
@@ -1670,20 +1653,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;
 }