2005-07-10 [colin] 1.9.12cvs32
authorColin Leroy <colin@colino.net>
Sun, 10 Jul 2005 04:09:06 +0000 (04:09 +0000)
committerColin Leroy <colin@colino.net>
Sun, 10 Jul 2005 04:09:06 +0000 (04:09 +0000)
* src/folder.c
* src/statusbar.c
* src/statusbar.h
Add visual progress indicator on filtering/processing
Factorize the progress bar code
* src/imap.c
* src/imap.h
* src/etpan/imap-thread.c
Add a reference counter to avoid destroying the Folder
while it's in use by another callback.

ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/etpan/imap-thread.c
src/folder.c
src/imap.c
src/imap.h
src/statusbar.c
src/statusbar.h

index 05fca537b83f1497080f93ec04758b899015a8d0..77fed234f94cb3be462f0b50f5ae0f5ceadebbc9 100644 (file)
@@ -1,3 +1,16 @@
+2005-07-10 [colin]     1.9.12cvs32
+
+       * src/folder.c
+       * src/statusbar.c
+       * src/statusbar.h
+               Add visual progress indicator on filtering/processing
+               Factorize the progress bar code
+       * src/imap.c
+       * src/imap.h
+       * src/etpan/imap-thread.c
+               Add a reference counter to avoid destroying the Folder
+               while it's in use by another callback.
+
 2005-07-09 [hoa]       1.9.12cvs31
 
        * src/imap.c
index 35d538fe79ccac333b09a00bafa5b6fa31e09350..2356d47fda5d734cc6cca5e90529de3b79690708 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.16.2.21 -r 1.16.2.22 src/msgcache.c;  ) > 1.9.12cvs29.patchset
 ( cvs diff -u -r 1.96.2.60 -r 1.96.2.61 src/textview.c;  cvs diff -u -r 1.8.2.5 -r 1.8.2.6 src/unmime.c;  cvs diff -u -r 1.2.2.9 -r 1.2.2.10 src/gtk/inputdialog.c;  ) > 1.9.12cvs30.patchset
 ( cvs diff -u -r 1.179.2.51 -r 1.179.2.52 src/imap.c;  cvs diff -u -r 1.1.4.4 -r 1.1.4.5 src/etpan/imap-thread.c;  ) > 1.9.12cvs31.patchset
+( cvs diff -u -r 1.213.2.40 -r 1.213.2.41 src/folder.c;  cvs diff -u -r 1.179.2.52 -r 1.179.2.53 src/imap.c;  cvs diff -u -r 1.34.2.1 -r 1.34.2.2 src/imap.h;  cvs diff -u -r 1.5.2.4 -r 1.5.2.5 src/statusbar.c;  cvs diff -u -r 1.3.2.1 -r 1.3.2.2 src/statusbar.h;  cvs diff -u -r 1.1.4.5 -r 1.1.4.6 src/etpan/imap-thread.c;  ) > 1.9.12cvs32.patchset
index 1cbadc06043fa82983ba433e9a6a35aed3ce34fe..aba63fcf98fca538842bea1346ebffa0db63435e 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=12
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=31
+EXTRA_VERSION=32
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 1054bf4b4e85a1ecdadf62ec1e86fd109e362aeb..5b492858766a54f95850f5ca73295e2e2572963f 100644 (file)
@@ -5,7 +5,7 @@
 #ifdef HAVE_LIBETPAN
 
 #include "imap-thread.h"
-
+#include <imap.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -171,6 +171,8 @@ static void threaded_run(Folder * folder, void * param, void * result,
        struct etpan_thread * thread;
        int finished;
        
+       imap_folder_ref(folder);
+
        op = etpan_thread_op_new();
        op->param = param;
        op->result = result;
@@ -191,6 +193,8 @@ static void threaded_run(Folder * folder, void * param, void * result,
        }
        
        etpan_thread_op_free(op);
+
+       imap_folder_unref(folder);
 }
 
 
index 97ef715c403db387df8b05273e5702b981def8ea..7ba9420b7261d4e0e31d05598948603a0cc0f56b 100644 (file)
@@ -1780,10 +1780,19 @@ gint folder_item_scan_full(FolderItem *item, gboolean filtering)
        folder_item_update_freeze();
        if (newmsg_list != NULL) {
                GSList *elem;
-
+               int total = g_slist_length(newmsg_list), cur = 0;
+               
+               if ((filtering == TRUE) &&
+                   (item->stype == F_INBOX) &&
+                   (item->folder->account != NULL) && 
+                   (item->folder->account->filter_on_recv)) 
+                       statusbar_print_all(_("Filtering messages...\n"));
+               
                for (elem = newmsg_list; elem != NULL; elem = g_slist_next(elem)) {
                        MsgInfo *msginfo = (MsgInfo *) elem->data;
 
+                       statusbar_progress_all(cur++,total, 10);
+
                        msgcache_add_msg(item->cache, msginfo);
                        if ((filtering == TRUE) &&
                            (item->stype == F_INBOX) &&
@@ -1796,6 +1805,8 @@ gint folder_item_scan_full(FolderItem *item, gboolean filtering)
                }
                g_slist_free(newmsg_list);
 
+               statusbar_progress_all(0,0,0);
+               statusbar_pop_all();
                update_flags |= F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_CONTENT;
        }
 
@@ -2254,17 +2265,7 @@ gint folder_item_fetch_all_msg(FolderItem *item)
                MsgInfo *msginfo = (MsgInfo *)cur->data;
                gchar *msg;
 
-               num++;
-               if (num % 10 == 0) {
-                       gchar buf[32];
-                       g_snprintf(buf, sizeof(buf), "%d / %d",
-                                  num, total);
-                       gtk_progress_bar_set_text
-                               (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar), buf);
-                       gtk_progress_bar_set_fraction
-                       (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar),
-                        (gfloat)num / (gfloat)total);
-               }
+               statusbar_progress_all(num++,total, 10);
 
                if (folder->ui_func)
                        folder->ui_func(folder, item,
@@ -2281,11 +2282,8 @@ gint folder_item_fetch_all_msg(FolderItem *item)
                }
                g_free(msg);
        }
-
-       gtk_progress_bar_set_fraction
-               (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar), 0);
-       gtk_progress_bar_set_text
-               (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar), "");
+       
+       statusbar_progress_all(0,0,0);
        statusbar_pop_all();
        procmsg_msg_list_free(mlist);
 
@@ -3409,7 +3407,6 @@ void folder_item_apply_processing(FolderItem *item)
        GSList *processing_list;
        GSList *mlist, *cur;
        guint total = 0, curmsg = 0;
-       gchar buf[32];
 
        g_return_if_fail(item != NULL);
        g_return_if_fail(item->no_select == FALSE);     
@@ -3428,16 +3425,9 @@ void folder_item_apply_processing(FolderItem *item)
                 /* reset parameters that can be modified by processing */
                 msginfo->hidden = 0;
                 msginfo->score = 0;
-                curmsg ++;
-               if (curmsg % 10 == 0) {
-                       g_snprintf(buf, sizeof(buf), "%d / %d",
-                                  curmsg, total);
-                       gtk_progress_bar_set_text
-                               (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar), buf);
-                       gtk_progress_bar_set_fraction
-                       (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar),
-                        (gfloat)curmsg / (gfloat)total);
-               }
+
+               statusbar_progress_all(curmsg++,total, 10);
+
                 /* apply pre global rules */
                filter_message_by_msginfo(pre_global_processing, msginfo);
                 
@@ -3451,10 +3441,7 @@ void folder_item_apply_processing(FolderItem *item)
        }
        g_slist_free(mlist);
        
-       gtk_progress_bar_set_text
-               (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar), "");
-       gtk_progress_bar_set_fraction
-               (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar), 0);
+       statusbar_progress_all(0,0,0);
        statusbar_pop_all();
 
        folder_item_update_thaw();
index bcdc42f9762234ae789e4f59748f6630118b31bd..9f2f0897ace7189590f8f75767a2370788515a65 100644 (file)
@@ -87,6 +87,7 @@ struct _IMAPFolder
        GList *ns_others;
        GList *ns_shared;
        gchar last_seen_separator;
+       guint refcnt;
 };
 
 struct _IMAPSession
@@ -464,6 +465,9 @@ static void imap_folder_destroy(Folder *folder)
 {
        gchar *dir;
 
+       while (imap_folder_get_refcnt(folder) > 0)
+               gtk_main_iteration();
+       
        dir = imap_folder_get_path(folder);
        if (is_dir_exist(dir))
                remove_dir_recursive(dir);
@@ -1842,18 +1846,7 @@ static GSList *imap_get_uncached_messages(IMAPSession *session,
                partial_result =
                        (GSList *)imap_get_uncached_messages_thread(data);
                
-               {
-                       gchar buf[32];
-                       g_snprintf(buf, sizeof(buf), "%d / %d",
-                                  data->cur, data->total);
-                       gtk_progress_bar_set_text
-                               (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar), buf);
-                       gtk_progress_bar_set_fraction
-                               (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar),
-                                (gfloat)data->cur / (gfloat)data->total);
-                       debug_print("update progress %g\n",
-                               (gfloat)data->cur / (gfloat)data->total);
-               }
+               statusbar_progress_all(data->cur,data->total, 1);
                
                g_slist_free(newlist);
                
@@ -1861,10 +1854,7 @@ static GSList *imap_get_uncached_messages(IMAPSession *session,
        }
        g_free(data);
        
-       gtk_progress_bar_set_fraction
-               (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar), 0);
-       gtk_progress_bar_set_text
-               (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar), "");
+       statusbar_progress_all(0,0,0);
        statusbar_pop_all();
        
        log_print(_("IMAP< Done\n"));
@@ -3787,6 +3777,23 @@ static struct mailimap_flag_list * imap_flag_to_lep(IMAPFlags flags)
        
        return flag_list;
 }
+
+guint imap_folder_get_refcnt(Folder *folder)
+{
+       return ((IMAPFolder *)folder)->refcnt;
+}
+
+void imap_folder_ref(Folder *folder)
+{
+       ((IMAPFolder *)folder)->refcnt++;
+}
+
+void imap_folder_unref(Folder *folder)
+{
+       if (((IMAPFolder *)folder)->refcnt > 0)
+               ((IMAPFolder *)folder)->refcnt--;
+}
+
 #else /* HAVE_LIBETPAN */
 
 static FolderClass imap_class;
@@ -3829,5 +3836,4 @@ FolderClass *imap_get_class(void)
 
        return &imap_class;
 }
-
 #endif
index a897ea98af37dad40e3542153d4d278da83a3e63..d088e5c8d8e77d53211e02ca4ead1db9f9d3767c 100644 (file)
@@ -29,5 +29,8 @@ typedef enum
 } IMAPAuthType;
 
 FolderClass *imap_get_class            (void);
+guint imap_folder_get_refcnt(Folder *folder);
+void imap_folder_ref(Folder *folder);
+void imap_folder_unref(Folder *folder);
 
 #endif /* __IMAP_H__ */
index a045641a98c74ba542df5091380dbc27eec20aa0..4ffb5baccd07d6a50ab278257e94aeae44eca88d 100644 (file)
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <gtk/gtkstatusbar.h>
+#include <gtk/gtkprogressbar.h>
 #include <stdarg.h>
 
+#include "mainwindow.h"
 #include "statusbar.h"
 #include "gtkutils.h"
 #include "utils.h"
@@ -143,3 +145,22 @@ void statusbar_verbosity_set(gboolean verbose)
                statusbar_pop_all();
        }
 }
+
+void statusbar_progress_all (gint done, gint total, gint step) 
+{
+       gchar buf[32];
+       g_snprintf(buf, sizeof(buf), "%d / %d", done, total);
+       if (total && done % step == 0) {
+               gtk_progress_bar_set_text
+                       (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar), buf);
+               gtk_progress_bar_set_fraction
+                       (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar),
+                        (gfloat)done / (gfloat)total);
+       } else if (total == 0) {
+               gtk_progress_bar_set_fraction
+                       (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar), 0);
+               gtk_progress_bar_set_text
+                       (GTK_PROGRESS_BAR(mainwindow_get_mainwindow()->progressbar), "");
+       }
+       
+}
index 78387f9cfbe27bf54a9f7f591d9b06a724c27d1b..014a10996f2f102f042136e620b83a93a070ccff 100644 (file)
@@ -36,6 +36,7 @@ void statusbar_print_all      (const gchar    *format, ...)
 void statusbar_pop_all         (void);
 void statusbar_verbosity_set   (gboolean        verbose);
 
+void statusbar_progress_all    (gint done, gint total, gint step);
 #define STATUSBAR_PUSH(mainwin, str) \
 { \
        gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \