[balsa/wip/gtk4: 339/351] balsa-index: Make it private
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/wip/gtk4: 339/351] balsa-index: Make it private
- Date: Wed, 23 May 2018 21:45:29 +0000 (UTC)
commit 22851c2b96e146b6e1ad921b375df23a09769375
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sun May 6 19:10:14 2018 -0400
balsa-index: Make it private
and provide a few getters.
src/balsa-index.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/balsa-index.h | 42 ++++++------------------
src/main-window.c | 33 ++++++++++---------
3 files changed, 119 insertions(+), 48 deletions(-)
---
diff --git a/src/balsa-index.c b/src/balsa-index.c
index 88b536f..3fe019e 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -151,9 +151,41 @@ static void bndx_select_row(BalsaIndex *index,
/* Other callbacks. */
static void bndx_store_address(gpointer data);
-
/* Class type. */
+struct _BalsaIndex {
+ GtkTreeView tree_view;
+
+ /* the popup menu and some items we need to refer to */
+ GtkWidget *popup_menu;
+ GtkWidget *delete_item;
+ GtkWidget *undelete_item;
+ GtkWidget *move_to_trash_item;
+ GtkWidget *toggle_item;
+ GtkWidget *move_to_item;
+
+ BalsaMailboxNode *mailbox_node;
+ guint current_msgno;
+ guint next_msgno;
+ gboolean current_message_is_deleted : 1;
+ gboolean prev_message : 1;
+ gboolean next_message : 1;
+ gboolean has_selection_changed_idle : 1;
+ gboolean has_mailbox_changed_idle : 1;
+ gboolean collapsing : 1;
+ gint filter_no;
+ gchar *filter_string; /* Quick view filter string, if any */
+
+ /* signal handler ids */
+ gulong row_expanded_id;
+ gulong row_collapsed_id;
+ gulong selection_changed_id;
+
+ LibBalsaMailboxSearchIter *search_iter;
+ BalsaIndexWidthPreference width_preference;
+};
+
+
G_DEFINE_TYPE(BalsaIndex, balsa_index, GTK_TYPE_TREE_VIEW)
/* BalsaIndex class init method. */
@@ -3034,3 +3066,61 @@ balsa_index_set_last_use(BalsaIndex *bindex)
if (mailbox_node != NULL)
balsa_mailbox_node_set_last_use(mailbox_node);
}
+
+
+/*
+ * Getters
+ */
+
+guint
+balsa_index_get_current_msgno(BalsaIndex *bindex)
+{
+ g_return_val_if_fail(BALSA_IS_INDEX(bindex), (time_t) -1);
+
+ return bindex->current_msgno;
+}
+
+
+gint
+balsa_index_get_filter_no(BalsaIndex *bindex)
+{
+ g_return_val_if_fail(BALSA_IS_INDEX(bindex), 0);
+
+ return bindex->filter_no;
+}
+
+
+const gchar *
+balsa_index_get_filter_string(BalsaIndex *bindex)
+{
+ g_return_val_if_fail(BALSA_IS_INDEX(bindex), FALSE);
+
+ return bindex->filter_string;
+}
+
+
+gboolean
+balsa_index_get_next_message(BalsaIndex *bindex)
+{
+ g_return_val_if_fail(BALSA_IS_INDEX(bindex), FALSE);
+
+ return bindex->next_message;
+}
+
+
+gboolean
+balsa_index_get_prev_message(BalsaIndex *bindex)
+{
+ g_return_val_if_fail(BALSA_IS_INDEX(bindex), FALSE);
+
+ return bindex->prev_message;
+}
+
+
+BalsaMailboxNode *
+balsa_index_get_mailbox_node(BalsaIndex *bindex)
+{
+ g_return_val_if_fail(BALSA_IS_INDEX(bindex), FALSE);
+
+ return bindex->mailbox_node;
+}
diff --git a/src/balsa-index.h b/src/balsa-index.h
index 59478d7..1eeb18e 100644
--- a/src/balsa-index.h
+++ b/src/balsa-index.h
@@ -40,38 +40,6 @@ typedef enum {
}
BalsaIndexWidthPreference;
-struct _BalsaIndex {
- GtkTreeView tree_view;
-
- /* the popup menu and some items we need to refer to */
- GtkWidget *popup_menu;
- GtkWidget *delete_item;
- GtkWidget *undelete_item;
- GtkWidget *move_to_trash_item;
- GtkWidget *toggle_item;
- GtkWidget *move_to_item;
-
- BalsaMailboxNode *mailbox_node;
- guint current_msgno;
- guint next_msgno;
- gboolean current_message_is_deleted : 1;
- gboolean prev_message : 1;
- gboolean next_message : 1;
- gboolean has_selection_changed_idle : 1;
- gboolean has_mailbox_changed_idle : 1;
- gboolean collapsing : 1;
- int filter_no;
- gchar *filter_string; /* Quick view filter string, if any */
-
- /* signal handler ids */
- gulong row_expanded_id;
- gulong row_collapsed_id;
- gulong selection_changed_id;
-
- LibBalsaMailboxSearchIter *search_iter;
- BalsaIndexWidthPreference width_preference;
-};
-
/* tree model columns */
enum {
BNDX_MESSAGE_COLUMN,
@@ -190,6 +158,16 @@ LibBalsaMailbox *balsa_index_get_mailbox(BalsaIndex *bindex);
time_t balsa_index_get_last_use(BalsaIndex *bindex);
void balsa_index_set_last_use(BalsaIndex *bindex);
+/*
+ * Getters
+ */
+guint balsa_index_get_current_msgno(BalsaIndex *bindex);
+gint balsa_index_get_filter_no(BalsaIndex *bindex);
+const gchar *balsa_index_get_filter_string(BalsaIndex *bindex);
+gboolean balsa_index_get_next_message(BalsaIndex *bindex);
+gboolean balsa_index_get_prev_message(BalsaIndex *bindex);
+BalsaMailboxNode *balsa_index_get_mailbox_node(BalsaIndex *bindex);
+
#define BALSA_INDEX_VIEW_ON_OPEN "balsa-index-view-on-open"
G_END_DECLS
diff --git a/src/main-window.c b/src/main-window.c
index fe3ce81..7c7febc 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -1120,12 +1120,12 @@ print_activated(GSimpleAction * action,
return;
bindex = BALSA_INDEX(index);
- if (bindex->current_msgno != 0) {
+ if (balsa_index_get_current_msgno(bindex) != 0) {
LibBalsaMailbox *mailbox;
LibBalsaMessage *message;
mailbox = balsa_index_get_mailbox(bindex);
- message = libbalsa_mailbox_get_message(mailbox, bindex->current_msgno);
+ message = libbalsa_mailbox_get_message(mailbox, balsa_index_get_current_msgno(bindex));
if (message != NULL) {
message_print(message, GTK_WINDOW(window));
@@ -1350,7 +1350,7 @@ reset_filter_activated(GSimpleAction * action,
/* do it by resetting the sos filder */
gtk_entry_set_text(GTK_ENTRY(priv->sos_entry), "");
index = balsa_window_find_current_index(window);
- bw_set_view_filter(window, BALSA_INDEX(index)->filter_no,
+ bw_set_view_filter(window, balsa_index_get_filter_no(BALSA_INDEX(index)),
priv->sos_entry);
}
@@ -2522,9 +2522,9 @@ bw_enable_mailbox_menus(BalsaWindow * window, BalsaIndex * index)
bw_actions_set_enabled(window, mailbox_actions,
G_N_ELEMENTS(mailbox_actions), enable);
bw_action_set_enabled(window, "next-message",
- index != NULL && index->next_message);
+ index != NULL && balsa_index_get_next_message(index));
bw_action_set_enabled(window, "previous-message",
- index != NULL && index->prev_message);
+ index != NULL && balsa_index_get_prev_message(index));
bw_action_set_enabled(window, "remove-duplicates", mailbox != NULL &&
libbalsa_mailbox_can_move_duplicates(mailbox));
@@ -2548,8 +2548,8 @@ balsa_window_update_book_menus(BalsaWindow * window)
bw_action_set_enabled(window, "address-book", has_books);
bw_action_set_enabled(window, "store-address", has_books &&
- priv->current_index &&
- BALSA_INDEX(priv->current_index)->current_msgno);
+ priv->current_index != NULL &&
+ balsa_index_get_current_msgno(BALSA_INDEX(priv->current_index)) != 0);
}
/*
@@ -3158,7 +3158,8 @@ bw_close_mailbox_on_timer(BalsaWindow * window)
if (balsa_app.debug)
fprintf(stderr, "Closing Page %d unused for %d s\n",
i, delta_time);
- balsa_window_real_close_mbnode(window, index->mailbox_node);
+ balsa_window_real_close_mbnode(window,
+ balsa_index_get_mailbox_node(index));
if (i < c)
c--;
i--;
@@ -4148,7 +4149,7 @@ bw_reset_filter(BalsaWindow * window)
/* do it by resetting the sos filder */
gtk_entry_set_text(GTK_ENTRY(priv->sos_entry), "");
- bw_set_view_filter(window, bindex->filter_no, priv->sos_entry);
+ bw_set_view_filter(window, balsa_index_get_filter_no(bindex), priv->sos_entry);
}
/* empty_trash:
@@ -4275,6 +4276,7 @@ bw_notebook_switch_page_cb(GtkWidget * notebook,
BalsaIndex *index;
LibBalsaMailbox *mailbox;
gchar *title;
+ const gchar *filter_string;
if (priv->current_index) {
g_object_remove_weak_pointer(G_OBJECT(priv->current_index),
@@ -4313,13 +4315,14 @@ bw_notebook_switch_page_cb(GtkWidget * notebook,
g_object_set_data(G_OBJECT(window), BALSA_INDEX_GRAB_FOCUS, index);
bw_idle_replace(window, index);
- bw_enable_message_menus(window, index->current_msgno);
+ bw_enable_message_menus(window, balsa_index_get_current_msgno(index));
bw_enable_mailbox_menus(window, index);
+ filter_string = balsa_index_get_filter_string(index);
gtk_entry_set_text(GTK_ENTRY(priv->sos_entry),
- index->filter_string ? index->filter_string : "");
+ filter_string != NULL ? filter_string : "");
gtk_combo_box_set_active(GTK_COMBO_BOX(priv->filter_choice),
- index->filter_no);
+ balsa_index_get_filter_no(index));
balsa_mblist_focus_mailbox(balsa_app.mblist, mailbox);
balsa_window_set_statusbar(window, mailbox);
@@ -4344,13 +4347,13 @@ bw_index_changed_cb(GtkWidget * widget, gpointer user_data)
return;
index = BALSA_INDEX(widget);
- bw_enable_message_menus(window, index->current_msgno);
+ bw_enable_message_menus(window, balsa_index_get_current_msgno(index));
bw_enable_mailbox_menus(window, index);
current_msgno = BALSA_MESSAGE(priv->preview)->message ?
libbalsa_message_get_msgno(BALSA_MESSAGE(priv->preview)->message) : 0;
- if (current_msgno != index->current_msgno)
+ if (current_msgno != balsa_index_get_current_msgno(index))
bw_idle_replace(window, index);
}
@@ -4401,7 +4404,7 @@ bw_idle_cb(BalsaWindow * window)
if (index)
balsa_message_set(BALSA_MESSAGE(priv->preview),
balsa_index_get_mailbox(index),
- index->current_msgno);
+ balsa_index_get_current_msgno(index));
else
balsa_message_set(BALSA_MESSAGE(priv->preview), NULL, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]