inital gtk2 patch
[claws.git] / src / inc.c
index 8ad34d99e78506a7d96b50d120c32fc64ef8a264..5d44315c0f6d2d2d43b6b567e15bfa56b9944911 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -84,7 +84,8 @@ static void inc_finished              (MainWindow             *mainwin,
 static gint inc_account_mail           (PrefsAccount           *account,
                                         MainWindow             *mainwin);
 
-static IncProgressDialog *inc_progress_dialog_create   (void);
+static IncProgressDialog *inc_progress_dialog_create
+                                       (gboolean                autocheck);
 static void inc_progress_dialog_set_list(IncProgressDialog     *inc_dialog);
 static void inc_progress_dialog_destroy        (IncProgressDialog      *inc_dialog);
 
@@ -128,10 +129,6 @@ static gint inc_autocheck_func                     (gpointer        data);
 
 static void inc_notify_cmd             (gint new_msgs, 
                                         gboolean notify);
-
-#define FOLDER_SUMMARY_MISMATCH(f, s) \
-       (f) && (s) ? ((s)->newmsgs != (f)->new_msgs) || ((f)->unread_msgs != (s)->unread) || ((f)->total_msgs != (s)->messages) \
-       : FALSE
        
 /**
  * inc_finished:
@@ -155,10 +152,6 @@ static void inc_finished(MainWindow *mainwin, gboolean new_messages)
                item = cur_account && cur_account->inbox
                        ? folder_find_item_from_identifier(cur_account->inbox)
                        : folder_get_default_inbox();
-               if (FOLDER_SUMMARY_MISMATCH(item, mainwin->summaryview)) {      
-                       folderview_unselect(mainwin->folderview);
-                       folderview_select(mainwin->folderview, item);
-               }       
        }
 }
 
@@ -241,7 +234,7 @@ static gint inc_account_mail(PrefsAccount *account, MainWindow *mainwin)
                session = inc_session_new(account);
                if (!session) return 0;
                
-               inc_dialog = inc_progress_dialog_create();
+               inc_dialog = inc_progress_dialog_create(FALSE);
                inc_dialog->queue_list = g_list_append(inc_dialog->queue_list,
                                                       session);
                inc_dialog->mainwin = mainwin;
@@ -263,7 +256,8 @@ static gint inc_account_mail(PrefsAccount *account, MainWindow *mainwin)
        return 0;
 }
 
-void inc_all_account_mail(MainWindow *mainwin, gboolean notify)
+void inc_all_account_mail(MainWindow *mainwin, gboolean autocheck,
+                         gboolean notify)
 {
        GList *list, *queue_list = NULL;
        IncProgressDialog *inc_dialog;
@@ -330,7 +324,7 @@ void inc_all_account_mail(MainWindow *mainwin, gboolean notify)
                return;
        }
 
-       inc_dialog = inc_progress_dialog_create();
+       inc_dialog = inc_progress_dialog_create(autocheck);
        inc_dialog->queue_list = queue_list;
        inc_dialog->mainwin = mainwin;
        inc_progress_dialog_set_list(inc_dialog);
@@ -345,7 +339,7 @@ void inc_all_account_mail(MainWindow *mainwin, gboolean notify)
        inc_autocheck_timer_set();
 }
 
-static IncProgressDialog *inc_progress_dialog_create(void)
+static IncProgressDialog *inc_progress_dialog_create(gboolean autocheck)
 {
        IncProgressDialog *dialog;
        ProgressDialog *progress;
@@ -355,10 +349,10 @@ static IncProgressDialog *inc_progress_dialog_create(void)
        progress = progress_dialog_create();
        gtk_window_set_title(GTK_WINDOW(progress->window),
                             _("Retrieving new messages"));
-       gtk_signal_connect(GTK_OBJECT(progress->cancel_btn), "clicked",
-                          GTK_SIGNAL_FUNC(inc_cancel_cb), dialog);
-       gtk_signal_connect(GTK_OBJECT(progress->window), "delete_event",
-                          GTK_SIGNAL_FUNC(inc_dialog_delete_cb), dialog);
+       g_signal_connect(G_OBJECT(progress->cancel_btn), "clicked",
+                        G_CALLBACK(inc_cancel_cb), dialog);
+       g_signal_connect(G_OBJECT(progress->window), "delete_event",
+                        G_CALLBACK(inc_dialog_delete_cb), dialog);
        /* manage_window_set_transient(GTK_WINDOW(progress->window)); */
 
        progress_dialog_set_value(progress, 0.0);
@@ -371,8 +365,8 @@ static IncProgressDialog *inc_progress_dialog_create(void)
                         &errorxpm, &errorxpmmask);
 
        if (prefs_common.recv_dialog_mode == RECV_DIALOG_ALWAYS ||
-           (prefs_common.recv_dialog_mode == RECV_DIALOG_ACTIVE &&
-            manage_window_get_focus_window())) {
+           (prefs_common.recv_dialog_mode == RECV_DIALOG_MANUAL &&
+            !autocheck)) {
                dialog->show_dialog = TRUE;
                gtk_widget_show_now(progress->window);
        }
@@ -408,12 +402,11 @@ static void inc_progress_dialog_clear(IncProgressDialog *inc_dialog)
 {
        progress_dialog_set_value(inc_dialog->dialog, 0.0);
        progress_dialog_set_label(inc_dialog->dialog, "");
-       if (inc_dialog->mainwin) {
-               gtk_progress_bar_update
-                       (GTK_PROGRESS_BAR(inc_dialog->mainwin->progressbar), 0.0);
+       if (inc_dialog->mainwin)
                gtk_progress_set_show_text
                        (GTK_PROGRESS(inc_dialog->mainwin->progressbar), FALSE);
-       }
+       gtk_progress_bar_update
+               (GTK_PROGRESS_BAR(inc_dialog->mainwin->progressbar), 0.0);
 }
 
 static void inc_progress_dialog_destroy(IncProgressDialog *inc_dialog)
@@ -422,12 +415,12 @@ static void inc_progress_dialog_destroy(IncProgressDialog *inc_dialog)
 
        inc_dialog_list = g_list_remove(inc_dialog_list, inc_dialog);
 
-       if (inc_dialog->mainwin) {
+       if (inc_dialog->mainwin)
                gtk_progress_set_show_text
                        (GTK_PROGRESS(inc_dialog->mainwin->progressbar), FALSE);
-               gtk_progress_bar_update
-                       (GTK_PROGRESS_BAR(inc_dialog->mainwin->progressbar), 0.0);
-       }
+       gtk_progress_bar_update
+               (GTK_PROGRESS_BAR(inc_dialog->mainwin->progressbar), 0.0);
+
        progress_dialog_destroy(inc_dialog->dialog);
 
        g_free(inc_dialog);
@@ -589,7 +582,7 @@ static gint inc_start(IncProgressDialog *inc_dialog)
                if (pop3_session->error_val == PS_AUTHFAIL) {
                        if(!prefs_common.no_recv_err_panel) {
                                if((prefs_common.recv_dialog_mode == RECV_DIALOG_ALWAYS) ||
-                                   ((prefs_common.recv_dialog_mode == RECV_DIALOG_ACTIVE) && focus_window)) {
+                                   ((prefs_common.recv_dialog_mode == RECV_DIALOG_MANUAL) && focus_window)) {
                                        manage_window_focus_in(inc_dialog->dialog->window, NULL, NULL);
                                }
                                alertpanel_error
@@ -746,7 +739,7 @@ static IncState inc_pop3_session_do(IncSession *session)
                            server, port);
                if(!prefs_common.no_recv_err_panel) {
                        if((prefs_common.recv_dialog_mode == RECV_DIALOG_ALWAYS) ||
-                           ((prefs_common.recv_dialog_mode == RECV_DIALOG_ACTIVE) && focus_window)) {
+                           ((prefs_common.recv_dialog_mode == RECV_DIALOG_MANUAL) && focus_window)) {
                                manage_window_focus_in(inc_dialog->dialog->window, NULL, NULL);
                        }
                        alertpanel_error(_("Can't connect to POP3 server: %s:%d"),
@@ -968,7 +961,7 @@ gint inc_drop_message(const gchar *file, Pop3Session *session)
        dropfolder = folder_get_default_processing();
 
        /* add msg file to drop folder */
-       if ((msgnum = folder_item_add_msg(dropfolder, file, TRUE)) < 0) {
+       if ((msgnum = folder_item_add_msg(dropfolder, file, NULL, TRUE)) < 0) {
                unlink(file);
                return -1;
        }
@@ -1107,7 +1100,8 @@ static gint inc_dialog_delete_cb(GtkWidget *widget, GdkEventAny *event,
 
 static gint inc_spool(void)
 {
-       gchar *mbox, *logname;
+       gchar *mbox;
+       const gchar *logname;
        gint msgs;
 
        logname = g_get_user_name();
@@ -1272,7 +1266,7 @@ static gint inc_autocheck_func(gpointer data)
                return FALSE;
        }
 
-       inc_all_account_mail(mainwin, prefs_common.newmail_notify_auto);
+       inc_all_account_mail(mainwin, TRUE, prefs_common.newmail_notify_auto);
 
        return FALSE;
 }