[balsa/threading: 9/16] Add UI for 'merge threads by subject'
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/threading: 9/16] Add UI for 'merge threads by subject'
- Date: Fri, 14 Sep 2018 21:19:04 +0000 (UTC)
commit de17d9bc1ed93b800f597fe394c83213825befb5
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sat Aug 25 15:56:28 2018 -0400
Add UI for 'merge threads by subject'
That is, give the user the choice of simple threading (by references) or
full JWZ, which merges threads with the same subject (after stripping
off 'Re: ', 'Fwd: ', etc).
* libbalsa/mailbox.c (libbalsa_mailbox_set_subject_gather),
(libbalsa_mailbox_get_subject_gather): new methods.
* libbalsa/mailbox.h: add LibBalsaMailboxView::subject_gather
and declare the getter/setter.
* src/balsa-index.c (balsa_index_set_thread_messages): use
thread-messages and subject-gather to decide whether threading
is flat, simple, or JWZ.
* src/mailbox-conf.c (thread_messages_toggled),
(subject_gather_toggled), (mailbox_conf_view_new_full),
(mailbox_conf_view_check): add the UI to the mailbox config
dialog.
* src/main-window.c (bw_enable_mailbox_menus),
(balsa_window_set_thread_messages): export -set-thread-messages.
* src/main-window.h: ditto.
ChangeLog | 19 +++++++++++++++++++
libbalsa/mailbox.c | 23 +++++++++++++++++++++++
libbalsa/mailbox.h | 4 ++++
src/balsa-index.c | 10 ++++++++--
src/mailbox-conf.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
src/main-window.c | 11 +++++------
src/main-window.h | 1 +
7 files changed, 109 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1e2d93719..8319d5204 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -37,6 +37,25 @@
make BalsaWindow::progress_bar a weak pointer and test whether
it is NULL before dereferencing.
+2018-08-25 Peter Bloomfield <pbloomfield bellsouth net>
+
+ Add UI for 'merge threads by subject'
+
+ * libbalsa/mailbox.c (libbalsa_mailbox_set_subject_gather),
+ (libbalsa_mailbox_get_subject_gather): new methods.
+ * libbalsa/mailbox.h: add LibBalsaMailboxView::subject_gather
+ and declare the getter/setter.
+ * src/balsa-index.c (balsa_index_set_thread_messages): use
+ thread-messages and subject-gather to decide whether threading
+ is flat, simple, or JWZ.
+ * src/mailbox-conf.c (thread_messages_toggled),
+ (subject_gather_toggled), (mailbox_conf_view_new_full),
+ (mailbox_conf_view_check): add the UI to the mailbox config
+ dialog.
+ * src/main-window.c (bw_enable_mailbox_menus),
+ (balsa_window_set_thread_messages): export -set-thread-messages.
+ * src/main-window.h: ditto.
+
2018-08-20 Peter Bloomfield <pbloomfield bellsouth net>
Limit use of LibBalsaMailboxThreadingType in src/ to balsa-index.c
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index aca4fffdb..179b2b524 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -2301,6 +2301,7 @@ libbalsa_mailbox_set_threading(LibBalsaMailbox *mailbox)
static LibBalsaMailboxView libbalsa_mailbox_view_default = {
NULL, /* identity_name */
LB_MAILBOX_THREADING_FLAT, /* threading_type */
+ FALSE, /* subject_gather */
0, /* filter */
LB_MAILBOX_SORT_TYPE_ASC, /* sort_type */
LB_MAILBOX_SORT_NO, /* sort_field */
@@ -2385,6 +2386,19 @@ libbalsa_mailbox_set_threading_type(LibBalsaMailbox * mailbox,
}
}
+void
+libbalsa_mailbox_set_subject_gather(LibBalsaMailbox * mailbox,
+ gboolean subject_gather)
+{
+ LibBalsaMailboxView *view = lbm_get_view(mailbox);
+
+ if (view->subject_gather != subject_gather) {
+ view->subject_gather = subject_gather;
+ if (mailbox != NULL)
+ view->in_sync = 0;
+ }
+}
+
void
libbalsa_mailbox_set_sort_type(LibBalsaMailbox * mailbox,
LibBalsaMailboxSortType sort_type)
@@ -2569,6 +2583,15 @@ libbalsa_mailbox_get_threading_type(LibBalsaMailbox * mailbox)
libbalsa_mailbox_view_default.threading_type;
}
+gboolean
+libbalsa_mailbox_get_subject_gather(LibBalsaMailbox * mailbox)
+{
+ return (mailbox != NULL && mailbox->view != NULL) ?
+ mailbox->view->subject_gather :
+ libbalsa_mailbox_view_default.subject_gather;
+}
+
+
LibBalsaMailboxSortType
libbalsa_mailbox_get_sort_type(LibBalsaMailbox * mailbox)
{
diff --git a/libbalsa/mailbox.h b/libbalsa/mailbox.h
index 8d4f4f3cc..cdb4b4ab9 100644
--- a/libbalsa/mailbox.h
+++ b/libbalsa/mailbox.h
@@ -152,6 +152,7 @@ typedef struct _LibBalsaMailboxView LibBalsaMailboxView;
struct _LibBalsaMailboxView {
gchar *identity_name;
LibBalsaMailboxThreadingType threading_type;
+ gboolean subject_gather;
/** filter is a frontend-specific code determining used view
* filter. GUI usually allows to generate only a subset of all
* possible LibBalsaCondition's and mapping from arbitary
@@ -532,6 +533,8 @@ gboolean libbalsa_mailbox_set_identity_name(LibBalsaMailbox * mailbox,
void libbalsa_mailbox_set_threading_type(LibBalsaMailbox * mailbox,
LibBalsaMailboxThreadingType
threading_type);
+void libbalsa_mailbox_set_subject_gather(LibBalsaMailbox * mailbox,
+ gboolean subject_gather);
void libbalsa_mailbox_set_sort_type(LibBalsaMailbox * mailbox,
LibBalsaMailboxSortType sort_type);
void libbalsa_mailbox_set_sort_field(LibBalsaMailbox * mailbox,
@@ -556,6 +559,7 @@ void libbalsa_mailbox_set_mtime (LibBalsaMailbox * mailbox, time_t mtime);
const gchar *libbalsa_mailbox_get_identity_name(LibBalsaMailbox * mailbox);
LibBalsaMailboxThreadingType
libbalsa_mailbox_get_threading_type(LibBalsaMailbox * mailbox);
+gboolean libbalsa_mailbox_get_subject_gather(LibBalsaMailbox * mailbox);
LibBalsaMailboxSortType libbalsa_mailbox_get_sort_type(LibBalsaMailbox *
mailbox);
LibBalsaMailboxSortFields libbalsa_mailbox_get_sort_field(LibBalsaMailbox *
diff --git a/src/balsa-index.c b/src/balsa-index.c
index b260b2526..3a087f92a 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -2069,8 +2069,14 @@ balsa_index_set_thread_messages(BalsaIndex * index,
mailbox = index->mailbox_node->mailbox;
g_return_if_fail(mailbox != NULL);
- threading_type =
- thread_messages ? LB_MAILBOX_THREADING_SIMPLE : LB_MAILBOX_THREADING_FLAT;
+ if (thread_messages) {
+ if (libbalsa_mailbox_get_subject_gather(mailbox))
+ threading_type = LB_MAILBOX_THREADING_JWZ;
+ else
+ threading_type = LB_MAILBOX_THREADING_SIMPLE;
+ } else {
+ threading_type = LB_MAILBOX_THREADING_FLAT;
+ }
if (threading_type == libbalsa_mailbox_get_threading_type(mailbox))
return;
diff --git a/src/mailbox-conf.c b/src/mailbox-conf.c
index e12edd9a6..7b3ba5181 100644
--- a/src/mailbox-conf.c
+++ b/src/mailbox-conf.c
@@ -69,6 +69,9 @@ struct _BalsaMailboxConfView {
#ifdef HAVE_GPGME
GtkWidget *chk_crypt;
#endif
+ GtkWidget *thread_messages;
+ GtkWidget *subject_gather;
+ LibBalsaMailbox *mailbox;
};
typedef struct _MailboxConfWindow MailboxConfWindow;
struct _MailboxConfWindow {
@@ -1295,6 +1298,31 @@ enum {
IDENTITY_COMBO_BOX_N_COLUMNS
};
+static void
+thread_messages_toggled(GtkWidget * widget,
+ BalsaMailboxConfView * view_info)
+{
+ gboolean thread_messages;
+
+ thread_messages = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+ gtk_widget_set_sensitive(view_info->subject_gather, thread_messages);
+ /* Rethread now */
+ balsa_window_set_thread_messages(balsa_app.main_window, thread_messages);
+}
+
+static void
+subject_gather_toggled(GtkWidget * widget,
+ BalsaMailboxConfView * view_info)
+{
+ gboolean subject_gather;
+
+ subject_gather = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+ libbalsa_mailbox_set_subject_gather(view_info->mailbox, subject_gather);
+ /* Rethread now */
+ balsa_window_set_thread_messages(balsa_app.main_window, TRUE);
+}
+
+
static BalsaMailboxConfView *
mailbox_conf_view_new_full(LibBalsaMailbox * mailbox,
GtkWindow * window,
@@ -1307,9 +1335,11 @@ mailbox_conf_view_new_full(LibBalsaMailbox * mailbox,
BalsaMailboxConfView *view_info;
GtkWidget *widget;
const gchar *identity_name;
+ gboolean thread_messages;
view_info = g_new(BalsaMailboxConfView, 1);
g_object_weak_ref(G_OBJECT(window), (GWeakNotify) g_free, view_info);
+ view_info->mailbox = mailbox;
view_info->window = window;
label = libbalsa_create_grid_label(_("_Identity:"), grid, row);
@@ -1391,6 +1421,25 @@ mailbox_conf_view_new_full(LibBalsaMailbox * mailbox,
g_signal_connect_swapped(view_info->subscribe, "toggled",
callback, window);
+ /* Thread messages check button */
+ thread_messages =
+ libbalsa_mailbox_get_threading_type(mailbox) !=
+ LB_MAILBOX_THREADING_FLAT;
+ view_info->thread_messages =
+ libbalsa_create_grid_check(_("_Thread messages"), grid, ++row,
+ thread_messages);
+ g_signal_connect(view_info->thread_messages, "toggled",
+ G_CALLBACK(thread_messages_toggled), view_info);
+
+ /* Subject gather check button */
+ view_info->subject_gather =
+ libbalsa_create_grid_check(_("_Merge threads with the same subject"),
+ grid, ++row,
+ libbalsa_mailbox_get_subject_gather(mailbox));
+ gtk_widget_set_sensitive(view_info->subject_gather, thread_messages);
+ g_signal_connect(view_info->subject_gather, "toggled",
+ G_CALLBACK(subject_gather_toggled), view_info);
+
return view_info;
}
@@ -1440,7 +1489,6 @@ mailbox_conf_view_check(BalsaMailboxConfView * view_info,
changed = FALSE;
libbalsa_mailbox_view_free(mailbox->view);
- g_print("%s set view on %s\n", __func__, mailbox->name);
mailbox->view = config_load_mailbox_view(mailbox->url);
if (!mailbox->view) {
/* The mailbox may not have its URL yet */
diff --git a/src/main-window.c b/src/main-window.c
index fbe39b55e..a5cef07f1 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -142,7 +142,6 @@ static gboolean bw_is_open_mailbox(LibBalsaMailbox *m);
static void bw_mailbox_tab_close_cb(GtkWidget * widget, gpointer data);
-static void bw_set_thread_messages(BalsaWindow * window, gboolean thread_messages);
static void bw_show_mbtree(BalsaWindow * window);
static void bw_set_filter_menu(BalsaWindow * window, int gui_filter);
static LibBalsaCondition *bw_get_view_filter(BalsaWindow * window);
@@ -2435,9 +2434,9 @@ bw_enable_mailbox_menus(BalsaWindow * window, BalsaIndex * index)
libbalsa_mailbox_can_move_duplicates(mailbox));
if (mailbox != NULL) {
- bw_set_thread_messages(window,
- libbalsa_mailbox_get_threading_type(mailbox)
- != LB_MAILBOX_THREADING_FLAT);
+ balsa_window_set_thread_messages(window,
+ libbalsa_mailbox_get_threading_type(mailbox)
+ != LB_MAILBOX_THREADING_FLAT);
bw_set_filter_menu(window, libbalsa_mailbox_get_filter(mailbox));
}
@@ -2622,8 +2621,8 @@ bw_enable_part_menu_items(BalsaWindow * window)
balsa_message_has_previous_part(msg));
}
-static void
-bw_set_thread_messages(BalsaWindow * window, gboolean thread_messages)
+void
+balsa_window_set_thread_messages(BalsaWindow * window, gboolean thread_messages)
{
GtkWidget *index;
BalsaMailboxNode *mbnode;
diff --git a/src/main-window.h b/src/main-window.h
index 5822f8719..9e0d01e12 100644
--- a/src/main-window.h
+++ b/src/main-window.h
@@ -149,6 +149,7 @@ void balsa_window_decrease_activity(BalsaWindow * window,
const gchar * message);
void balsa_window_set_statusbar(BalsaWindow * window,
LibBalsaMailbox * mailbox);
+void balsa_window_set_thread_messages(BalsaWindow * window, gboolean thread_messages);
#if defined(__FILE__) && defined(__LINE__)
# ifdef __FUNCTION__
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]