[balsa] Use an idle callback to rethread the mailbox
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Use an idle callback to rethread the mailbox
- Date: Thu, 2 Mar 2017 03:45:38 +0000 (UTC)
commit 5bcf76a1ea70d9b775ed3278bb27abed66a500ba
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Wed Mar 1 22:44:45 2017 -0500
Use an idle callback to rethread the mailbox
* libbalsa/mailbox.c (libbalsa_mailbox_finalize): remove an
outstanding idle source;
(lbm_need_threading_idle_cb): the idle callback;
(libbalsa_mailbox_check): schedule the idle callback;
(libbalsa_mailbox_msgno_inserted): ditto;
(libbalsa_mailbox_msgno_removed): ditto;
(libbalsa_mailbox_sync_storage): just signal mailbox changed;
(lbm_check_idle): ref the mailbox here...
(lbm_queue_check): not here.
* libbalsa/mailbox.h: add guint
LibBalsaMailbox::need_threading_idle_id;
we no longer need LIBBALSA_MAILBOX_UNTHREADED.
* libbalsa/mailbox_local.c (lbml_info_setup):
LIBBALSA_MAILBOX_UNTHREADED is now irrelevant.
ChangeLog | 19 ++++++++++++
libbalsa/mailbox.c | 69 ++++++++++++++++++----------------------------
libbalsa/mailbox.h | 3 +-
libbalsa/mailbox_local.c | 3 --
4 files changed, 47 insertions(+), 47 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7c34776..937e0c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2017-03-01 Peter Bloomfield <pbloomfield bellsouth net>
+
+ Use an idle callback to rethread the mailbox display.
+
+ * libbalsa/mailbox.c (libbalsa_mailbox_finalize): remove an
+ outstanding idle source;
+ (lbm_need_threading_idle_cb): the idle callback;
+ (libbalsa_mailbox_check): schedule the idle callback;
+ (libbalsa_mailbox_msgno_inserted): ditto;
+ (libbalsa_mailbox_msgno_removed): ditto;
+ (libbalsa_mailbox_sync_storage): just signal mailbox changed;
+ (lbm_check_idle): ref the mailbox here...
+ (lbm_queue_check): not here.
+ * libbalsa/mailbox.h: add guint
+ LibBalsaMailbox::need_threading_idle_id;
+ we no longer need LIBBALSA_MAILBOX_UNTHREADED.
+ * libbalsa/mailbox_local.c (lbml_info_setup):
+ LIBBALSA_MAILBOX_UNTHREADED is now irrelevant.
+
2017-02-21 Peter Bloomfield <pbloomfield bellsouth net>
gtk_show_uri is deprecated in favor of gtk_show_uri_on_window
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index 773aaba..5c6facc 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -484,6 +484,11 @@ libbalsa_mailbox_finalize(GObject * object)
mailbox->queue_check_idle_id = 0;
}
+ if (mailbox->need_threading_idle_id) {
+ g_source_remove(mailbox->need_threading_idle_id);
+ mailbox->need_threading_idle_id = 0;
+ }
+
G_OBJECT_CLASS(parent_class)->finalize(object);
}
@@ -678,8 +683,6 @@ libbalsa_mailbox_progress_notify(LibBalsaMailbox * mailbox,
void
libbalsa_mailbox_check(LibBalsaMailbox * mailbox)
{
- GSList *unthreaded;
-
g_return_if_fail(mailbox != NULL);
g_return_if_fail(LIBBALSA_IS_MAILBOX(mailbox));
@@ -691,19 +694,7 @@ libbalsa_mailbox_check(LibBalsaMailbox * mailbox)
mailbox->queue_check_idle_id = 0;
}
- unthreaded = NULL;
- if (MAILBOX_OPEN(mailbox))
- g_object_set_data(G_OBJECT(mailbox), LIBBALSA_MAILBOX_UNTHREADED,
- &unthreaded);
LIBBALSA_MAILBOX_GET_CLASS(mailbox)->check(mailbox);
- g_object_set_data(G_OBJECT(mailbox), LIBBALSA_MAILBOX_UNTHREADED,
- unthreaded);
- if (unthreaded) {
- lbm_set_threading(mailbox, mailbox->view->threading_type);
- g_slist_free(unthreaded);
- g_object_set_data(G_OBJECT(mailbox), LIBBALSA_MAILBOX_UNTHREADED,
- NULL);
- }
libbalsa_unlock_mailbox(mailbox);
}
@@ -1325,13 +1316,22 @@ libbalsa_mailbox_msgno_changed(LibBalsaMailbox * mailbox, guint seqno)
}
}
+static gboolean
+lbm_need_threading_idle_cb(LibBalsaMailbox *mailbox)
+{
+ lbm_set_threading(mailbox, mailbox->view->threading_type);
+
+ mailbox->need_threading_idle_id = 0;
+
+ return FALSE;
+}
+
void
libbalsa_mailbox_msgno_inserted(LibBalsaMailbox *mailbox, guint seqno,
GNode * parent, GNode ** sibling)
{
GtkTreeIter iter;
GtkTreePath *path;
- GSList **unthreaded;
if (!mailbox->msg_tree)
return;
@@ -1357,11 +1357,10 @@ libbalsa_mailbox_msgno_inserted(LibBalsaMailbox *mailbox, guint seqno,
gtk_tree_path_free(path);
}
- unthreaded =
- g_object_get_data(G_OBJECT(mailbox), LIBBALSA_MAILBOX_UNTHREADED);
- if (unthreaded)
- *unthreaded =
- g_slist_prepend(*unthreaded, GUINT_TO_POINTER(seqno));
+ if (mailbox->need_threading_idle_id == 0) {
+ mailbox->need_threading_idle_id =
+ g_idle_add((GSourceFunc) lbm_need_threading_idle_cb, mailbox);
+ }
mailbox->msg_tree_changed = TRUE;
gdk_threads_leave();
@@ -1463,7 +1462,6 @@ libbalsa_mailbox_msgno_removed(LibBalsaMailbox * mailbox, guint seqno)
* simple. */
parent = dt.node->parent;
while ((child = dt.node->children)) {
- GSList **unthreaded;
/* No need to notify the tree-view about unlinking the child--it
* will assume we already did that when we notify it about
* destroying the parent. */
@@ -1479,11 +1477,11 @@ libbalsa_mailbox_msgno_removed(LibBalsaMailbox * mailbox, guint seqno)
libbalsa_mbox_model_signals[ROW_HAS_CHILD_TOGGLED],
0, path, &iter);
gtk_tree_path_next(path);
+ }
- unthreaded = g_object_get_data(G_OBJECT(mailbox),
- LIBBALSA_MAILBOX_UNTHREADED);
- if (unthreaded)
- *unthreaded = g_slist_prepend(*unthreaded, child->data);
+ if (mailbox->need_threading_idle_id == 0) {
+ mailbox->need_threading_idle_id =
+ g_idle_add((GSourceFunc) lbm_need_threading_idle_cb, mailbox);
}
/* Now it's safe to destroy the node. */
@@ -1902,21 +1900,9 @@ libbalsa_mailbox_sync_storage(LibBalsaMailbox * mailbox, gboolean expunge)
/* When called in an idle handler, the mailbox might have been
* closed, so we must check (with the mailbox locked). */
if (MAILBOX_OPEN(mailbox)) {
- GSList *unthreaded = NULL;
-
- g_object_set_data(G_OBJECT(mailbox), LIBBALSA_MAILBOX_UNTHREADED,
- &unthreaded);
retval =
LIBBALSA_MAILBOX_GET_CLASS(mailbox)->sync(mailbox, expunge);
- g_object_set_data(G_OBJECT(mailbox), LIBBALSA_MAILBOX_UNTHREADED,
- unthreaded);
- if (unthreaded) {
- lbm_set_threading(mailbox, mailbox->view->threading_type);
- g_slist_free(unthreaded);
- g_object_set_data(G_OBJECT(mailbox),
- LIBBALSA_MAILBOX_UNTHREADED, NULL);
- } else
- libbalsa_mailbox_changed(mailbox);
+ libbalsa_mailbox_changed(mailbox);
}
libbalsa_unlock_mailbox(mailbox);
@@ -4210,8 +4196,8 @@ lbm_check_idle(LibBalsaMailbox * mailbox)
{
GThread *check_thread;
- check_thread =
- g_thread_new("lbm_check_real", (GThreadFunc) lbm_check_real, mailbox);
+ check_thread = g_thread_new("lbm_check_real", (GThreadFunc) lbm_check_real,
+ g_object_ref(mailbox));
g_thread_unref(check_thread);
libbalsa_lock_mailbox(mailbox);
@@ -4227,8 +4213,7 @@ lbm_queue_check(LibBalsaMailbox * mailbox)
libbalsa_lock_mailbox(mailbox);
if (!mailbox->queue_check_idle_id)
mailbox->queue_check_idle_id =
- g_idle_add((GSourceFunc) lbm_check_idle,
- g_object_ref(mailbox));
+ g_idle_add((GSourceFunc) lbm_check_idle, mailbox);
libbalsa_unlock_mailbox(mailbox);
}
diff --git a/libbalsa/mailbox.h b/libbalsa/mailbox.h
index 327d7f6..73c7294 100644
--- a/libbalsa/mailbox.h
+++ b/libbalsa/mailbox.h
@@ -68,8 +68,6 @@ do {\
}\
} while (0)
-#define LIBBALSA_MAILBOX_UNTHREADED "libbalsa-mailbox-unthreaded"
-
typedef enum {
LB_MAILBOX_SORT_NO, /* == NATURAL */
@@ -251,6 +249,7 @@ struct _LibBalsaMailbox {
guint changed_idle_id;
guint queue_check_idle_id;
+ guint need_threading_idle_id;
};
/* Search iter */
diff --git a/libbalsa/mailbox_local.c b/libbalsa/mailbox_local.c
index feb119a..d68a5cb 100644
--- a/libbalsa/mailbox_local.c
+++ b/libbalsa/mailbox_local.c
@@ -1444,7 +1444,6 @@ struct _ThreadingInfo {
GNode *root;
GHashTable *id_table;
GHashTable *subject_table;
- GSList *unthreaded;
LibBalsaMailboxThreadingType type;
};
typedef struct _ThreadingInfo ThreadingInfo;
@@ -1471,8 +1470,6 @@ lbml_info_setup(LibBalsaMailbox * mailbox, ThreadingInfo * ti)
ti->root = g_node_new(mailbox->msg_tree);
ti->id_table = g_hash_table_new(g_str_hash, g_str_equal);
ti->subject_table = NULL;
- ti->unthreaded =
- g_object_get_data(G_OBJECT(mailbox), LIBBALSA_MAILBOX_UNTHREADED);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]