[balsa/wip/gtk4: 343/351] balsa-message: Make it private
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/wip/gtk4: 343/351] balsa-message: Make it private
- Date: Wed, 23 May 2018 21:45:49 +0000 (UTC)
commit 075b957997a631c2b1743c74094e3aa550f2fc52
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sun May 6 22:27:58 2018 -0400
balsa-message: Make it private
and provide getters and setters.
src/balsa-message.c | 122 +++++++++++++++++++++++++++++++++++++
src/balsa-message.h | 74 ++++++-----------------
src/balsa-mime-widget-callbacks.c | 21 ++++---
src/balsa-mime-widget-message.c | 23 ++++---
src/balsa-mime-widget-text.c | 13 +++--
src/balsa-mime-widget-vcalendar.c | 2 +-
src/main-window.c | 7 +-
src/message-window.c | 31 ++++++----
8 files changed, 196 insertions(+), 97 deletions(-)
---
diff --git a/src/balsa-message.c b/src/balsa-message.c
index c36d879..feeaa4f 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -165,6 +165,58 @@ balsa_part_info_class_init(BalsaPartInfoClass *klass)
G_DEFINE_TYPE(BalsaPartInfo, balsa_part_info, G_TYPE_OBJECT)
+struct _BalsaMessage {
+ GtkBox parent;
+
+ GtkWidget *stack;
+ GtkWidget *switcher;
+
+ /* Top-level MIME widget */
+ BalsaMimeWidget *bm_widget;
+
+ /* header-related information */
+ ShownHeaders shown_headers;
+
+ /* Widgets to hold content */
+ GtkWidget *scroll;
+
+ /* Widget to hold structure tree */
+ GtkWidget *treeview;
+ gint info_count;
+ GList *save_all_list;
+ GtkWidget *save_all_popup;
+
+ gboolean wrap_text;
+
+ BalsaPartInfo *current_part;
+ GtkWidget *parts_popup;
+ gboolean force_inline;
+
+ LibBalsaMessage *message;
+
+ BalsaMessageFocusState focus_state;
+
+ /* Find-in-message stuff */
+ GtkWidget *find_bar;
+ GtkWidget *find_entry;
+ GtkWidget *find_next;
+ GtkWidget *find_prev;
+ GtkWidget *find_sep;
+ GtkWidget *find_label;
+ GtkTextIter find_iter;
+ gboolean find_forward;
+
+ /* Widget to hold Faces */
+ GtkWidget *face_box;
+
+#ifdef HAVE_HTML_WIDGET
+ gpointer html_find_info;
+#endif /* HAVE_HTML_WIDGET */
+
+ GtkEventController *find_key_controller;
+ gulong key_pressed_id;
+};
+
G_DEFINE_TYPE(BalsaMessage, balsa_message, GTK_TYPE_BOX)
static void
@@ -776,6 +828,7 @@ balsa_message_destroy(GObject * object)
g_clear_object(&bm->save_all_popup);
g_clear_object(&bm->parts_popup);
g_clear_object(&bm->bm_widget);
+ g_clear_object(&bm->face_box);
#ifdef HAVE_HTML_WIDGET
g_clear_object(&bm->html_find_info);
@@ -3249,3 +3302,72 @@ balsa_message_find_in_message(BalsaMessage * bm)
G_CALLBACK(gtk_widget_grab_focus), NULL);
}
}
+
+/*
+ * Getters
+ */
+
+gboolean
+balsa_message_get_wrap_text(BalsaMessage *bm)
+{
+ return bm->wrap_text;
+}
+
+BalsaMessageFocusState
+balsa_message_get_focus_state(BalsaMessage *bm)
+{
+ return bm->focus_state;
+}
+
+GtkScrolledWindow *
+balsa_message_get_scroll(BalsaMessage *bm)
+{
+ return GTK_SCROLLED_WINDOW(bm->scroll);
+}
+
+BalsaMimeWidget *
+balsa_message_get_bm_widget(BalsaMessage *bm)
+{
+ return bm->bm_widget;
+}
+
+LibBalsaMessage *
+balsa_message_get_message(BalsaMessage *bm)
+{
+ return bm->message;
+}
+
+ShownHeaders
+balsa_message_get_shown_headers(BalsaMessage *bm)
+{
+ return bm->shown_headers;
+}
+
+GtkWidget *
+balsa_message_get_face_box(BalsaMessage *bm)
+{
+ return bm->face_box;
+}
+
+GtkWidget *
+balsa_message_get_tree_view(BalsaMessage *bm)
+{
+ return bm->treeview;
+}
+
+/*
+ * Setters
+ */
+void
+balsa_message_set_focus_state(BalsaMessage *bm,
+ BalsaMessageFocusState focus_state)
+{
+ bm->focus_state = focus_state;
+}
+
+void
+balsa_message_set_face_box(BalsaMessage *bm,
+ GtkWidget * face_box)
+{
+ g_set_object(&bm->face_box, face_box);
+}
diff --git a/src/balsa-message.h b/src/balsa-message.h
index c6d3ef3..1bc8fbd 100644
--- a/src/balsa-message.h
+++ b/src/balsa-message.h
@@ -49,61 +49,6 @@ typedef enum {
BALSA_MESSAGE_FOCUS_STATE_HOLD
} BalsaMessageFocusState;
-struct _BalsaMessage {
- GtkBox parent;
-
- GtkWidget *stack;
- GtkWidget *switcher;
-
- /* Top-level MIME widget */
- BalsaMimeWidget *bm_widget;
-
- /* header-related information */
- ShownHeaders shown_headers;
-
- /* Widgets to hold content */
- GtkWidget *scroll;
-
- /* Widget to hold structure tree */
- GtkWidget *treeview;
- gint info_count;
- GList *save_all_list;
- GtkWidget *save_all_popup;
-
- gboolean wrap_text;
-
- BalsaPartInfo *current_part;
- GtkWidget *parts_popup;
- gboolean force_inline;
-
- LibBalsaMessage *message;
-
- BalsaMessageFocusState focus_state;
-
- /* Find-in-message stuff */
- GtkWidget *find_bar;
- GtkWidget *find_entry;
- GtkWidget *find_next;
- GtkWidget *find_prev;
- GtkWidget *find_sep;
- GtkWidget *find_label;
- GtkTextIter find_iter;
- gboolean find_forward;
-
- /* Tab position for headers */
- gint tab_position;
-
- /* Widget to hold Faces */
- GtkWidget *face_box;
-
-#ifdef HAVE_HTML_WIDGET
- gpointer html_find_info;
-#endif /* HAVE_HTML_WIDGET */
-
- GtkEventController *find_key_controller;
- gulong key_pressed_id;
-};
-
GtkWidget *balsa_message_new(void);
@@ -149,6 +94,25 @@ void balsa_message_perform_crypto(LibBalsaMessage *message,
void balsa_message_find_in_message(BalsaMessage *bm);
+/*
+ * Getters
+ */
+gboolean balsa_message_get_wrap_text(BalsaMessage *bm);
+BalsaMessageFocusState balsa_message_get_focus_state(BalsaMessage *bm);
+GtkScrolledWindow * balsa_message_get_scroll(BalsaMessage *bm);
+BalsaMimeWidget * balsa_message_get_bm_widget(BalsaMessage *bm);
+LibBalsaMessage * balsa_message_get_message(BalsaMessage *bm);
+ShownHeaders balsa_message_get_shown_headers(BalsaMessage *bm);
+GtkWidget * balsa_message_get_face_box(BalsaMessage *bm);
+GtkWidget * balsa_message_get_tree_view(BalsaMessage *bm);
+
+/*
+ * Setters
+ */
+void balsa_message_set_focus_state(BalsaMessage *bm,
+ BalsaMessageFocusState focus_state);
+void balsa_message_set_face_box(BalsaMessage *bm, GtkWidget *face_box);
+
G_END_DECLS
#endif /* __BALSA_MESSAGE_H__ */
diff --git a/src/balsa-mime-widget-callbacks.c b/src/balsa-mime-widget-callbacks.c
index 6018fe4..f66a6bb 100644
--- a/src/balsa-mime-widget-callbacks.c
+++ b/src/balsa-mime-widget-callbacks.c
@@ -183,7 +183,7 @@ scroll_change(GtkAdjustment * adj, gint diff, BalsaMessage * bm)
/* We're changing mailboxes, and GtkNotebook will grab the
* focus, so we want to grab it back the next time we lose
* it. */
- bm->focus_state = BALSA_MESSAGE_FOCUS_STATE_HOLD;
+ balsa_message_set_focus_state(bm, BALSA_MESSAGE_FOCUS_STATE_HOLD);
return;
}
@@ -204,7 +204,7 @@ balsa_mime_widget_key_press_event(GtkEventControllerKey *key_controller,
GtkAdjustment *adj;
int page_adjust;
- adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(bm->scroll));
+ adj = gtk_scrolled_window_get_vadjustment(balsa_message_get_scroll(bm));
page_adjust = balsa_app.pgdownmod ?
(gtk_adjustment_get_page_size(adj) * balsa_app.pgdown_percent) /
@@ -265,7 +265,10 @@ void
balsa_mime_widget_check_focus(GtkWidget * widget, GParamSpec * pspec, BalsaMessage * bm)
{
GtkContainer *container =
- GTK_CONTAINER(balsa_mime_widget_get_container(bm->bm_widget));
+ GTK_CONTAINER(balsa_mime_widget_get_container(balsa_message_get_bm_widget(bm)));
+ BalsaMessageFocusState focus_state;
+
+ focus_state = balsa_message_get_focus_state(bm);
if (gtk_widget_has_focus(widget)) {
/* Disable can_focus on other message parts so that TAB does not
@@ -276,17 +279,17 @@ balsa_mime_widget_check_focus(GtkWidget * widget, GParamSpec * pspec, BalsaMessa
gtk_container_set_focus_chain(container, list);
g_list_free(list);
- if (bm->focus_state == BALSA_MESSAGE_FOCUS_STATE_NO)
- bm->focus_state = BALSA_MESSAGE_FOCUS_STATE_YES;
+ if (focus_state == BALSA_MESSAGE_FOCUS_STATE_NO)
+ balsa_message_set_focus_state(bm, BALSA_MESSAGE_FOCUS_STATE_YES);
} else {
gtk_container_unset_focus_chain(container);
- if (bm->message != NULL) {
- if (bm->focus_state == BALSA_MESSAGE_FOCUS_STATE_HOLD) {
+ if (balsa_message_get_message(bm) != NULL) {
+ if (focus_state == BALSA_MESSAGE_FOCUS_STATE_HOLD) {
balsa_message_grab_focus(bm);
- bm->focus_state = BALSA_MESSAGE_FOCUS_STATE_YES;
+ balsa_message_set_focus_state(bm, BALSA_MESSAGE_FOCUS_STATE_YES);
} else
- bm->focus_state = BALSA_MESSAGE_FOCUS_STATE_NO;
+ balsa_message_set_focus_state(bm, BALSA_MESSAGE_FOCUS_STATE_NO);
}
}
}
diff --git a/src/balsa-mime-widget-message.c b/src/balsa-mime-widget-message.c
index 2e9d93a..b08bf10 100644
--- a/src/balsa-mime-widget-message.c
+++ b/src/balsa-mime-widget-message.c
@@ -142,7 +142,7 @@ balsa_mime_widget_new_message(BalsaMessage * bm,
balsa_mime_widget_set_header_widget(mw, header_widget);
bmw_message_set_headers(bm, mw, mime_body,
- bm->shown_headers == HEADERS_ALL);
+ balsa_message_get_shown_headers(bm) == HEADERS_ALL);
} else if (!g_ascii_strcasecmp("text/rfc822-headers", content_type)) {
GtkWidget *widget;
GtkWidget *header_widget;
@@ -482,6 +482,7 @@ bm_header_widget_new(BalsaMessage * bm, GtkWidget * const * buttons)
#endif /* GTK_INFO_BAR_WRAPPING_IS_BROKEN */
GtkWidget *action_area;
GtkWidget *widget;
+ GtkWidget *face_box;
grid = gtk_grid_new();
gtk_grid_set_column_spacing(GTK_GRID(grid), 12);
@@ -516,11 +517,13 @@ bm_header_widget_new(BalsaMessage * bm, GtkWidget * const * buttons)
gtk_button_box_set_layout(GTK_BUTTON_BOX(action_area),
GTK_BUTTONBOX_START);
#endif /* GTK_INFO_BAR_WRAPPING_IS_BROKEN */
- if (!bm->face_box) {
- bm->face_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_pack_start(GTK_BOX(action_area), bm->face_box);
+ face_box = balsa_message_get_face_box(bm);
+ if (face_box == NULL) {
+ face_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ gtk_box_pack_start(GTK_BOX(action_area), face_box);
gtk_button_box_set_child_non_homogeneous(GTK_BUTTON_BOX(action_area),
- bm->face_box, TRUE);
+ face_box, TRUE);
+ balsa_message_set_face_box(bm, face_box);
}
if (buttons) {
@@ -671,7 +674,7 @@ add_header_address_list(BalsaMessage * bm, GtkGrid * grid,
if (list == NULL || internet_address_list_length(list) == 0)
return;
- if (!(bm->shown_headers == HEADERS_ALL ||
+ if (!(balsa_message_get_shown_headers(bm) == HEADERS_ALL ||
libbalsa_find_word(header, balsa_app.selected_headers)))
return;
@@ -723,14 +726,12 @@ bmw_message_set_headers_d(BalsaMessage * bm,
return;
}
- if (bm->shown_headers == HEADERS_NONE) {
+ if (balsa_message_get_shown_headers(bm) == HEADERS_NONE) {
g_signal_connect(G_OBJECT(widget), "realize",
G_CALLBACK(gtk_widget_hide), NULL);
return;
}
- bm->tab_position = 0;
-
add_header_gchar(grid, "subject", _("Subject:"), subject,
show_all_headers);
@@ -830,7 +831,7 @@ balsa_mime_widget_message_set_headers(BalsaMessage * bm,
LibBalsaMessageBody * part)
{
bmw_message_set_headers(bm, mw, part,
- bm->shown_headers == HEADERS_ALL);
+ balsa_message_get_shown_headers(bm) == HEADERS_ALL);
}
void
@@ -841,7 +842,7 @@ balsa_mime_widget_message_set_headers_d(BalsaMessage * bm,
const gchar * subject)
{
bmw_message_set_headers_d(bm, mw, headers, part, subject,
- bm->shown_headers == HEADERS_ALL);
+ balsa_message_get_shown_headers(bm) == HEADERS_ALL);
}
#ifdef HAVE_GPGME
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index 0189ed4..3c3664a 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -279,7 +279,7 @@ balsa_mime_widget_new_text(BalsaMessage * bm, LibBalsaMessageBody * mime_body,
/* Parse, but don't wrap. */
gboolean delsp = libbalsa_message_body_is_delsp(mime_body);
ptr = libbalsa_wrap_rfc2646(ptr, G_MAXINT, FALSE, TRUE, delsp);
- } else if (bm->wrap_text
+ } else if (balsa_message_get_wrap_text(bm)
#if HAVE_GTKSOURCEVIEW
&& !GTK_SOURCE_IS_VIEW(widget)
#endif
@@ -1293,14 +1293,17 @@ static gchar *
check_text_encoding(BalsaMessage * bm, gchar *text_buf)
{
const gchar *target_cs;
+ LibBalsaMessage *message;
+
+ message = balsa_message_get_message(bm);
if (!libbalsa_utf8_sanitize(&text_buf, balsa_app.convert_unknown_8bit,
&target_cs)
- && !g_object_get_data(G_OBJECT(bm->message),
+ && !g_object_get_data(G_OBJECT(message),
BALSA_MIME_WIDGET_NEW_TEXT_NOTIFIED)) {
- LibBalsaMessageHeaders *headers = libbalsa_message_get_headers(bm->message);
+ LibBalsaMessageHeaders *headers = libbalsa_message_get_headers(message);
gchar *from = balsa_message_sender_to_gchar(headers->from, 0);
- gchar *subject = g_strdup(LIBBALSA_MESSAGE_GET_SUBJECT(bm->message));
+ gchar *subject = g_strdup(LIBBALSA_MESSAGE_GET_SUBJECT(message));
libbalsa_utf8_sanitize(&from, balsa_app.convert_unknown_8bit,
NULL);
@@ -1316,7 +1319,7 @@ check_text_encoding(BalsaMessage * bm, gchar *text_buf)
g_free(subject);
g_free(from);
/* Avoid multiple notifications: */
- g_object_set_data(G_OBJECT(bm->message),
+ g_object_set_data(G_OBJECT(message),
BALSA_MIME_WIDGET_NEW_TEXT_NOTIFIED,
GUINT_TO_POINTER(TRUE));
}
diff --git a/src/balsa-mime-widget-vcalendar.c b/src/balsa-mime-widget-vcalendar.c
index 946f3d6..6e7baa0 100644
--- a/src/balsa-mime-widget-vcalendar.c
+++ b/src/balsa-mime-widget-vcalendar.c
@@ -49,7 +49,7 @@ balsa_mime_widget_new_vcalendar(BalsaMessage * bm,
GtkWidget *label;
gchar *text;
GList *l;
- LibBalsaMessage *lbm = bm->message;
+ LibBalsaMessage *lbm = balsa_message_get_message(bm);
gboolean may_reply = FALSE;
InternetAddress *sender = NULL;;
diff --git a/src/main-window.c b/src/main-window.c
index 7c7febc..9a8b0e2 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -4341,6 +4341,7 @@ bw_index_changed_cb(GtkWidget * widget, gpointer user_data)
BalsaWindow *window = BALSA_WINDOW(user_data);
BalsaWindowPrivate *priv = balsa_window_get_instance_private(window);
BalsaIndex *index;
+ LibBalsaMessage *message;
guint current_msgno;
if (widget != priv->current_index)
@@ -4350,8 +4351,8 @@ bw_index_changed_cb(GtkWidget * widget, gpointer user_data)
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;
+ message = balsa_message_get_message(BALSA_MESSAGE(priv->preview));
+ current_msgno = message != NULL ? libbalsa_message_get_msgno(message) : 0;
if (current_msgno != balsa_index_get_current_msgno(index))
bw_idle_replace(window, index);
@@ -4367,7 +4368,7 @@ bw_idle_replace(BalsaWindow * window, BalsaIndex * bindex)
/* Skip if the window is being destroyed: */
if (priv->preview != NULL) {
priv->set_message_id = g_idle_add((GSourceFunc) bw_idle_cb, window);
- if (BALSA_MESSAGE(priv->preview)->message != NULL)
+ if (balsa_message_get_message(BALSA_MESSAGE(priv->preview)) != NULL)
gtk_widget_hide(priv->preview);
}
}
diff --git a/src/message-window.c b/src/message-window.c
index 0d71325..508d064 100644
--- a/src/message-window.c
+++ b/src/message-window.c
@@ -98,7 +98,7 @@ mw_set_active(MessageWindow * mw,
static void
mw_set_part_buttons_sensitive(MessageWindow * mw, BalsaMessage * msg)
{
- if (!msg || !msg->treeview)
+ if (msg == NULL || balsa_message_get_tree_view(msg) == NULL)
return;
mw_set_enabled(mw, "next-part",
@@ -728,8 +728,6 @@ static void
mw_select_part_cb(BalsaMessage * bm, gpointer data)
{
MessageWindow *mw = (MessageWindow *) data;
- gchar *title;
- gchar *from;
#ifdef HAVE_HTML_WIDGET
gboolean enable = bm && balsa_message_can_zoom(bm);
@@ -739,16 +737,23 @@ mw_select_part_cb(BalsaMessage * bm, gpointer data)
#endif /* HAVE_HTML_WIDGET */
/* set window title */
- if (bm && bm->message) {
- LibBalsaMessageHeaders *headers;
-
- headers = libbalsa_message_get_headers(bm->message);
- from = internet_address_list_to_string(headers->from, FALSE);
- title = g_strdup_printf(_("Message from %s: %s"), from,
- LIBBALSA_MESSAGE_GET_SUBJECT(bm->message));
- g_free(from);
- gtk_window_set_title(GTK_WINDOW(mw->window), title);
- g_free(title);
+ if (bm != NULL) {
+ LibBalsaMessage *message;
+
+ message = balsa_message_get_message(bm);
+ if (message != NULL) {
+ LibBalsaMessageHeaders *headers;
+ gchar *from;
+ gchar *title;
+
+ headers = libbalsa_message_get_headers(balsa_message_get_message(bm));
+ from = internet_address_list_to_string(headers->from, FALSE);
+ title = g_strdup_printf(_("Message from %s: %s"), from,
+ LIBBALSA_MESSAGE_GET_SUBJECT(balsa_message_get_message(bm)));
+ g_free(from);
+ gtk_window_set_title(GTK_WINDOW(mw->window), title);
+ g_free(title);
+ }
}
mw_set_part_buttons_sensitive(mw, bm);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]