sync with sylpheed 0.5.3 plus button
[claws.git] / src / account.c
index cc65a457102ae051d6042eabe71ca35f07f56e2a..94bf40ec34e0acd54b539ee14f9e5fcf518bebf3 100644 (file)
 #include "utils.h"
 #include "alertpanel.h"
 
 #include "utils.h"
 #include "alertpanel.h"
 
+#include "pixmaps/mark.xpm"
+
 typedef enum
 {
        COL_DEFAULT     = 0,
 typedef enum
 {
        COL_DEFAULT     = 0,
-       COL_NAME        = 1,
-       COL_PROTOCOL    = 2,
-       COL_SERVER      = 3
+       COL_GETALL      = 1,
+       COL_NAME        = 2,
+       COL_PROTOCOL    = 3,
+       COL_SERVER      = 4
 } EditAccountColumnPos;
 
 } EditAccountColumnPos;
 
-# define N_EDIT_ACCOUNT_COLS   4
+# define N_EDIT_ACCOUNT_COLS   5
 
 #define PREFSBUFSIZE           1024
 
 
 #define PREFSBUFSIZE           1024
 
@@ -66,6 +69,9 @@ static struct EditAccount {
        GtkWidget *close_btn;
 } edit_account;
 
        GtkWidget *close_btn;
 } edit_account;
 
+static GdkPixmap *markxpm;
+static GdkBitmap *markxpmmask;
+
 static void account_edit_create                (void);
 
 static void account_edit_prefs         (void);
 static void account_edit_create                (void);
 
 static void account_edit_prefs         (void);
@@ -76,6 +82,8 @@ static void account_down              (void);
 
 static void account_set_default                (void);
 
 
 static void account_set_default                (void);
 
+static void account_set_recv_at_get_all        (void);
+
 static void account_edit_close         (void);
 static gint account_delete_event       (GtkWidget      *widget,
                                         GdkEventAny    *event,
 static void account_edit_close         (void);
 static gint account_delete_event       (GtkWidget      *widget,
                                         GdkEventAny    *event,
@@ -173,22 +181,21 @@ PrefsAccount *account_find_from_smtp_server(const gchar *address,
 }
 
 /*
 }
 
 /*
- * account_find_mail_from_address:
+ * account_find_from_address:
  * @address: Email address string.
  *
  * Find a mail (not news) account with the specified email address.
  *
  * Return value: The found account, or NULL if not found.
  */
  * @address: Email address string.
  *
  * Find a mail (not news) account with the specified email address.
  *
  * Return value: The found account, or NULL if not found.
  */
-PrefsAccount *account_find_mail_from_address(const gchar *address)
+PrefsAccount *account_find_from_address(const gchar *address)
 {
        GList *cur;
        PrefsAccount *ac;
 
        for (cur = account_list; cur != NULL; cur = cur->next) {
                ac = (PrefsAccount *)cur->data;
 {
        GList *cur;
        PrefsAccount *ac;
 
        for (cur = account_list; cur != NULL; cur = cur->next) {
                ac = (PrefsAccount *)cur->data;
-               if (!ac->protocol != A_NNTP &&
-                   !strcmp2(address, ac->address))
+               if (ac->protocol != A_NNTP && !strcmp2(address, ac->address))
                        return ac;
        }
 
                        return ac;
        }
 
@@ -267,6 +274,9 @@ void account_add(void)
        if (ac_prefs->is_default)
                account_set_as_default(ac_prefs);
 
        if (ac_prefs->is_default)
                account_set_as_default(ac_prefs);
 
+       if (ac_prefs->recv_at_getall)
+               account_set_as_recv_at_get_all(ac_prefs);
+
        account_clist_set();
 
        if (ac_prefs->protocol == A_IMAP4 || ac_prefs->protocol == A_NNTP) {
        account_clist_set();
 
        if (ac_prefs->protocol == A_IMAP4 || ac_prefs->protocol == A_NNTP) {
@@ -317,6 +327,24 @@ PrefsAccount *account_get_default(void)
        return NULL;
 }
 
        return NULL;
 }
 
+void account_set_as_recv_at_get_all(PrefsAccount *ac_prefs)
+{
+       PrefsAccount *ap;
+       GList *cur;
+
+       for (cur = account_list; cur != NULL; cur = cur->next) {
+               ap = (PrefsAccount *)cur->data;
+               if (ap->account_name == ac_prefs->account_name) {
+                       if (ap->recv_at_getall == 0)
+                               ap->recv_at_getall = 1;
+                       else
+                               ap->recv_at_getall = 0;
+               }
+        }
+
+}
+
+
 void account_set_missing_folder(void)
 {
        PrefsAccount *ap;
 void account_set_missing_folder(void)
 {
        PrefsAccount *ap;
@@ -383,6 +411,8 @@ static void account_edit_create(void)
 
        GtkWidget *default_btn;
 
 
        GtkWidget *default_btn;
 
+        GtkWidget *recvatgetall_btn;
+
        GtkWidget *hbbox;
        GtkWidget *close_btn;
 
        GtkWidget *hbbox;
        GtkWidget *close_btn;
 
@@ -401,6 +431,7 @@ static void account_edit_create(void)
                            GTK_SIGNAL_FUNC (manage_window_focus_in), NULL);
        gtk_signal_connect (GTK_OBJECT (window), "focus_out_event",
                            GTK_SIGNAL_FUNC (manage_window_focus_out), NULL);
                            GTK_SIGNAL_FUNC (manage_window_focus_in), NULL);
        gtk_signal_connect (GTK_OBJECT (window), "focus_out_event",
                            GTK_SIGNAL_FUNC (manage_window_focus_out), NULL);
+       gtk_widget_realize(window);
 
        vbox = gtk_vbox_new (FALSE, 12);
        gtk_widget_show (vbox);
 
        vbox = gtk_vbox_new (FALSE, 12);
        gtk_widget_show (vbox);
@@ -418,7 +449,8 @@ static void account_edit_create(void)
                                        GTK_POLICY_AUTOMATIC,
                                        GTK_POLICY_AUTOMATIC);
 
                                        GTK_POLICY_AUTOMATIC,
                                        GTK_POLICY_AUTOMATIC);
 
-       titles[COL_DEFAULT]  = "";
+       titles[COL_DEFAULT]  = "D";
+       titles[COL_GETALL]   = "G";
        titles[COL_NAME]     = _("Name");
        titles[COL_PROTOCOL] = _("Protocol");
        titles[COL_SERVER]   = _("Server");
        titles[COL_NAME]     = _("Name");
        titles[COL_PROTOCOL] = _("Protocol");
        titles[COL_SERVER]   = _("Server");
@@ -426,7 +458,8 @@ static void account_edit_create(void)
        clist = gtk_clist_new_with_titles (N_EDIT_ACCOUNT_COLS, titles);
        gtk_widget_show (clist);
        gtk_container_add (GTK_CONTAINER (scrolledwin), clist);
        clist = gtk_clist_new_with_titles (N_EDIT_ACCOUNT_COLS, titles);
        gtk_widget_show (clist);
        gtk_container_add (GTK_CONTAINER (scrolledwin), clist);
-       gtk_clist_set_column_width (GTK_CLIST(clist), COL_DEFAULT , 16);
+       gtk_clist_set_column_width (GTK_CLIST(clist), COL_DEFAULT , 10);
+       gtk_clist_set_column_width (GTK_CLIST(clist), COL_GETALL  , 10);
        gtk_clist_set_column_width (GTK_CLIST(clist), COL_NAME    , 100);
        gtk_clist_set_column_width (GTK_CLIST(clist), COL_PROTOCOL, 70);
        gtk_clist_set_column_width (GTK_CLIST(clist), COL_SERVER  , 100);
        gtk_clist_set_column_width (GTK_CLIST(clist), COL_NAME    , 100);
        gtk_clist_set_column_width (GTK_CLIST(clist), COL_PROTOCOL, 70);
        gtk_clist_set_column_width (GTK_CLIST(clist), COL_SERVER  , 100);
@@ -487,7 +520,13 @@ static void account_edit_create(void)
        gtk_signal_connect (GTK_OBJECT(default_btn), "clicked",
                            GTK_SIGNAL_FUNC (account_set_default), NULL);
 
        gtk_signal_connect (GTK_OBJECT(default_btn), "clicked",
                            GTK_SIGNAL_FUNC (account_set_default), NULL);
 
-       gtkut_button_set_create(&hbbox, &close_btn, _("Close"),
+       recvatgetall_btn = gtk_button_new_with_label (_(" Enable/Disable 'Receive at Get all' "));
+       gtk_widget_show (recvatgetall_btn);
+       gtk_box_pack_start (GTK_BOX (vbox2), recvatgetall_btn, TRUE, FALSE, 0);
+       gtk_signal_connect (GTK_OBJECT(recvatgetall_btn), "clicked",
+                           GTK_SIGNAL_FUNC (account_set_recv_at_get_all), NULL);
+
+        gtkut_button_set_create(&hbbox, &close_btn, _("Close"),
                                NULL, NULL, NULL, NULL);
        gtk_widget_show(hbbox);
        gtk_box_pack_end (GTK_BOX (hbox), hbbox, FALSE, FALSE, 0);
                                NULL, NULL, NULL, NULL);
        gtk_widget_show(hbbox);
        gtk_box_pack_end (GTK_BOX (hbox), hbbox, FALSE, FALSE, 0);
@@ -497,6 +536,8 @@ static void account_edit_create(void)
                            GTK_SIGNAL_FUNC (account_edit_close),
                            NULL);
 
                            GTK_SIGNAL_FUNC (account_edit_close),
                            NULL);
 
+       PIXMAP_CREATE(clist, markxpm, markxpmmask, mark_xpm);
+
        edit_account.window    = window;
        edit_account.clist     = clist;
        edit_account.close_btn = close_btn;
        edit_account.window    = window;
        edit_account.clist     = clist;
        edit_account.close_btn = close_btn;
@@ -602,6 +643,23 @@ static void account_set_default(void)
        main_window_reflect_prefs_all();
 }
 
        main_window_reflect_prefs_all();
 }
 
+static void account_set_recv_at_get_all(void)
+{
+       GtkCList *clist = GTK_CLIST(edit_account.clist);
+       gint row;
+       PrefsAccount *ac_prefs;
+
+       if (!clist->selection) return;
+
+       row = GPOINTER_TO_INT(clist->selection->data);
+       ac_prefs = gtk_clist_get_row_data(clist, row);
+
+       if ((ac_prefs->protocol != A_POP3) && (ac_prefs->protocol != A_APOP)) return;
+       
+       account_set_as_recv_at_get_all(ac_prefs);
+       account_clist_set();
+}
+
 static void account_edit_close(void)
 {
        account_list_set();
 static void account_edit_close(void)
 {
        account_list_set();
@@ -649,12 +707,23 @@ static gint account_clist_set_row(PrefsAccount *ac_prefs, gint row)
        gchar *text[N_EDIT_ACCOUNT_COLS];
 
        text[COL_DEFAULT] = ac_prefs->is_default ? "*" : "";
        gchar *text[N_EDIT_ACCOUNT_COLS];
 
        text[COL_DEFAULT] = ac_prefs->is_default ? "*" : "";
+       text[COL_GETALL] = (ac_prefs->protocol == A_POP3 ||
+                           ac_prefs->protocol == A_APOP) &&
+                           ac_prefs->recv_at_getall ? "*" : "";
        text[COL_NAME] = ac_prefs->account_name;
        text[COL_NAME] = ac_prefs->account_name;
+#if !USE_SSL
        text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3  ? "POP3"  :
                             ac_prefs->protocol == A_APOP  ? "APOP"  :
                             ac_prefs->protocol == A_IMAP4 ? "IMAP4" :
                             ac_prefs->protocol == A_LOCAL ? "Local" :
                             ac_prefs->protocol == A_NNTP  ? "NNTP"  :  "";
        text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3  ? "POP3"  :
                             ac_prefs->protocol == A_APOP  ? "APOP"  :
                             ac_prefs->protocol == A_IMAP4 ? "IMAP4" :
                             ac_prefs->protocol == A_LOCAL ? "Local" :
                             ac_prefs->protocol == A_NNTP  ? "NNTP"  :  "";
+#else
+       text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3  ? (!ac_prefs->ssl_pop ? "POP3" : "POP3 (SSL)") :
+                            ac_prefs->protocol == A_APOP  ? (!ac_prefs->ssl_pop ? "APOP" : "APOP (SSL)") :
+                            ac_prefs->protocol == A_IMAP4 ? (!ac_prefs->ssl_imap ? "IMAP4" : "IMAP4 (SSL)") :
+                            ac_prefs->protocol == A_LOCAL ? "Local" :
+                            ac_prefs->protocol == A_NNTP  ? "NNTP"  :  "";
+#endif
        text[COL_SERVER] = ac_prefs->protocol == A_NNTP
                ? ac_prefs->nntp_server : ac_prefs->recv_server;
 
        text[COL_SERVER] = ac_prefs->protocol == A_NNTP
                ? ac_prefs->nntp_server : ac_prefs->recv_server;
 
@@ -662,11 +731,19 @@ static gint account_clist_set_row(PrefsAccount *ac_prefs, gint row)
                row = gtk_clist_append(clist, text);
        else {
                gtk_clist_set_text(clist, row, COL_DEFAULT, text[COL_DEFAULT]);
                row = gtk_clist_append(clist, text);
        else {
                gtk_clist_set_text(clist, row, COL_DEFAULT, text[COL_DEFAULT]);
+               gtk_clist_set_text(clist, row, COL_GETALL, text[COL_GETALL]);
                gtk_clist_set_text(clist, row, COL_NAME, text[COL_NAME]);
                gtk_clist_set_text(clist, row, COL_PROTOCOL, text[COL_PROTOCOL]);
                gtk_clist_set_text(clist, row, COL_SERVER, text[COL_SERVER]);
        }
 
                gtk_clist_set_text(clist, row, COL_NAME, text[COL_NAME]);
                gtk_clist_set_text(clist, row, COL_PROTOCOL, text[COL_PROTOCOL]);
                gtk_clist_set_text(clist, row, COL_SERVER, text[COL_SERVER]);
        }
 
+       if (*text[COL_DEFAULT])
+               gtk_clist_set_pixmap(clist, row, COL_DEFAULT,
+                                    markxpm, markxpmmask);
+       if (*text[COL_GETALL])
+               gtk_clist_set_pixmap(clist, row, COL_GETALL,
+                                    markxpm, markxpmmask);
+
        gtk_clist_set_row_data(clist, row, ac_prefs);
 
        return row;
        gtk_clist_set_row_data(clist, row, ac_prefs);
 
        return row;