lib: add last_child flag to thread information

With that flag it's possible to reconstruct the entire thread tree
structure in mu4e.
This commit is contained in:
Marcelo Henrique Cerri 2018-04-22 02:18:57 -03:00
parent b4cc67d455
commit 297120dc6c
3 changed files with 13 additions and 6 deletions

View File

@ -571,7 +571,8 @@ count_colons (const char *str)
static MuMsgIterThreadInfo*
thread_info_new (gchar *threadpath, gboolean root, gboolean first_child,
gboolean empty_parent, gboolean has_child, gboolean is_dup)
gboolean last_child, gboolean empty_parent,
gboolean has_child, gboolean is_dup)
{
MuMsgIterThreadInfo *ti;
@ -582,6 +583,7 @@ thread_info_new (gchar *threadpath, gboolean root, gboolean first_child,
ti->prop = MU_MSG_ITER_THREAD_PROP_NONE;
ti->prop |= root ? MU_MSG_ITER_THREAD_PROP_ROOT : 0;
ti->prop |= first_child ? MU_MSG_ITER_THREAD_PROP_FIRST_CHILD : 0;
ti->prop |= last_child ? MU_MSG_ITER_THREAD_PROP_LAST_CHILD : 0;
ti->prop |= empty_parent ? MU_MSG_ITER_THREAD_PROP_EMPTY_PARENT : 0;
ti->prop |= is_dup ? MU_MSG_ITER_THREAD_PROP_DUP : 0;
ti->prop |= has_child ? MU_MSG_ITER_THREAD_PROP_HAS_CHILD : 0;
@ -610,12 +612,13 @@ static void
add_to_thread_info_hash (GHashTable *thread_info_hash, MuContainer *c,
char *threadpath)
{
gboolean is_root, first_child, empty_parent, is_dup, has_child;
gboolean is_root, first_child, last_child, empty_parent, is_dup, has_child;
/* 'root' means we're a child of the dummy root-container */
is_root = (c->parent == NULL);
first_child = is_root ? FALSE : (c->parent->child == c);
last_child = is_root ? FALSE : (c->next == NULL);
empty_parent = is_root ? FALSE : (!c->parent->msg);
is_dup = c->flags & MU_CONTAINER_FLAG_DUP;
has_child = c->child ? TRUE : FALSE;
@ -625,6 +628,7 @@ add_to_thread_info_hash (GHashTable *thread_info_hash, MuContainer *c,
thread_info_new (threadpath,
is_root,
first_child,
last_child,
empty_parent,
has_child,
is_dup));

View File

@ -163,9 +163,10 @@ enum _MuMsgIterThreadProp {
MU_MSG_ITER_THREAD_PROP_ROOT = 1 << 0,
MU_MSG_ITER_THREAD_PROP_FIRST_CHILD = 1 << 1,
MU_MSG_ITER_THREAD_PROP_EMPTY_PARENT = 1 << 2,
MU_MSG_ITER_THREAD_PROP_DUP = 1 << 3,
MU_MSG_ITER_THREAD_PROP_HAS_CHILD = 1 << 4
MU_MSG_ITER_THREAD_PROP_LAST_CHILD = 1 << 2,
MU_MSG_ITER_THREAD_PROP_EMPTY_PARENT = 1 << 3,
MU_MSG_ITER_THREAD_PROP_DUP = 1 << 4,
MU_MSG_ITER_THREAD_PROP_HAS_CHILD = 1 << 5
};
typedef guint8 MuMsgIterThreadProp;

View File

@ -434,11 +434,13 @@ static void
append_sexp_thread_info (GString *gstr, const MuMsgIterThreadInfo *ti)
{
g_string_append_printf
(gstr, "\t:thread (:path \"%s\" :level %u%s%s%s%s)\n",
(gstr, "\t:thread (:path \"%s\" :level %u%s%s%s%s%s)\n",
ti->threadpath,
ti->level,
ti->prop & MU_MSG_ITER_THREAD_PROP_FIRST_CHILD ?
" :first-child t" : "",
ti->prop & MU_MSG_ITER_THREAD_PROP_LAST_CHILD ?
" :last-child t" : "",
ti->prop & MU_MSG_ITER_THREAD_PROP_EMPTY_PARENT ?
" :empty-parent t" : "",
ti->prop & MU_MSG_ITER_THREAD_PROP_DUP ?