+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
( 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
MICRO_VERSION=12
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=31
+EXTRA_VERSION=32
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
#ifdef HAVE_LIBETPAN
#include "imap-thread.h"
-
+#include <imap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
struct etpan_thread * thread;
int finished;
+ imap_folder_ref(folder);
+
op = etpan_thread_op_new();
op->param = param;
op->result = result;
}
etpan_thread_op_free(op);
+
+ imap_folder_unref(folder);
}
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) &&
}
g_slist_free(newmsg_list);
+ statusbar_progress_all(0,0,0);
+ statusbar_pop_all();
update_flags |= F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_CONTENT;
}
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,
}
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);
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);
/* 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);
}
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();
GList *ns_others;
GList *ns_shared;
gchar last_seen_separator;
+ guint refcnt;
};
struct _IMAPSession
{
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);
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);
}
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"));
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;
return &imap_class;
}
-
#endif
} 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__ */
#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"
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), "");
+ }
+
+}
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), \