[balsa] balsa-message: Use modern macros
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] balsa-message: Use modern macros
- Date: Tue, 23 Jul 2019 03:51:59 +0000 (UTC)
commit b861479a96546b39383dc4e1db3b092bd4218896
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Mon Jul 22 23:49:55 2019 -0400
balsa-message: Use modern macros
Use modern macros to declare and define BalsaMessage.
Make BalsaMessage opaque, and provide and use necessary accessors.
* src/balsa-message.c (balsa_part_info_class_init),
(balsa_message_class_init), (balsa_message_destroy),
(balsa_part_info_init), (balsa_part_info_new),
(balsa_part_info_dispose), (balsa_part_info_finalize),
(balsa_message_get_wrap_text), (balsa_message_get_focus_state),
(balsa_message_get_scroll), (balsa_message_get_bm_widget),
(balsa_message_get_message), (balsa_message_get_shown_headers),
(balsa_message_get_face_box), (balsa_message_get_tree_view),
(balsa_message_set_focus_state), (balsa_message_set_face_box):
* src/balsa-message.h:
* src/balsa-mime-widget-callbacks.c (scroll_change),
(balsa_mime_widget_key_press_event),
(balsa_mime_widget_limit_focus), (balsa_mime_widget_unlimit_focus):
* src/balsa-mime-widget-message.c (balsa_mime_widget_new_message),
(bm_header_widget_new), (add_header_address_list),
(bmw_message_set_headers_d),
(balsa_mime_widget_message_set_headers),
(balsa_mime_widget_message_set_headers_d):
* src/balsa-mime-widget-text.c (balsa_mime_widget_new_text),
(check_text_encoding):
* src/balsa-mime-widget-vcalendar.c
(balsa_mime_widget_new_vcalendar):
* src/main-window.c (bw_index_changed_cb), (bw_idle_replace):
* src/message-window.c (mw_set_part_buttons_sensitive):
ChangeLog | 31 +++++
src/balsa-message.c | 268 +++++++++++++++++++++++---------------
src/balsa-message.h | 88 +++----------
src/balsa-mime-widget-callbacks.c | 20 +--
src/balsa-mime-widget-message.c | 22 ++--
src/balsa-mime-widget-text.c | 11 +-
src/balsa-mime-widget-vcalendar.c | 2 +-
src/main-window.c | 4 +-
src/message-window.c | 22 ++--
9 files changed, 258 insertions(+), 210 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0594c0d05..69ace1175 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2019-07-22 Peter Bloomfield <pbloomfield bellsouth net>
+
+ balsa-message: Use modern macros to declare and define.
+
+ Make BalsaMessage opaque, and provide and use necessary accessors.
+
+ * src/balsa-message.c (balsa_part_info_class_init),
+ (balsa_message_class_init), (balsa_message_destroy),
+ (balsa_part_info_init), (balsa_part_info_new),
+ (balsa_part_info_dispose), (balsa_part_info_finalize),
+ (balsa_message_get_wrap_text), (balsa_message_get_focus_state),
+ (balsa_message_get_scroll), (balsa_message_get_bm_widget),
+ (balsa_message_get_message), (balsa_message_get_shown_headers),
+ (balsa_message_get_face_box), (balsa_message_get_tree_view),
+ (balsa_message_set_focus_state), (balsa_message_set_face_box):
+ * src/balsa-message.h:
+ * src/balsa-mime-widget-callbacks.c (scroll_change),
+ (balsa_mime_widget_key_press_event),
+ (balsa_mime_widget_limit_focus), (balsa_mime_widget_unlimit_focus):
+ * src/balsa-mime-widget-message.c (balsa_mime_widget_new_message),
+ (bm_header_widget_new), (add_header_address_list),
+ (bmw_message_set_headers_d),
+ (balsa_mime_widget_message_set_headers),
+ (balsa_mime_widget_message_set_headers_d):
+ * src/balsa-mime-widget-text.c (balsa_mime_widget_new_text),
+ (check_text_encoding):
+ * src/balsa-mime-widget-vcalendar.c
+ (balsa_mime_widget_new_vcalendar):
+ * src/main-window.c (bw_index_changed_cb), (bw_idle_replace):
+ * src/message-window.c (mw_set_part_buttons_sensitive):
+
2019-07-22 Peter Bloomfield <pbloomfield bellsouth net>
balsa-mblist: Use modern macros to declare and define.
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 242a2ec72..031d5c362 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -76,7 +76,7 @@ enum {
NUM_COLUMNS
};
-typedef struct _BalsaPartInfoClass BalsaPartInfoClass;
+G_DECLARE_FINAL_TYPE(BalsaPartInfo, balsa_part_info, BALSA, PART_INFO, GObject)
struct _BalsaPartInfo {
GObject parent_object;
@@ -93,25 +93,11 @@ struct _BalsaPartInfo {
GtkTreePath *path;
};
-struct _BalsaPartInfoClass {
- GObjectClass parent_class;
-};
-
-static GType balsa_part_info_get_type();
-
-#define TYPE_BALSA_PART_INFO \
- (balsa_part_info_get_type ())
-#define BALSA_PART_INFO(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BALSA_PART_INFO, BalsaPartInfo))
-#define IS_BALSA_PART_INFO(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BALSA_PART_INFO))
+#define TYPE_BALSA_PART_INFO (balsa_part_info_get_type())
static gint balsa_message_signals[LAST_SIGNAL];
/* widget */
-static void balsa_message_class_init(BalsaMessageClass * klass);
-static void balsa_message_init(BalsaMessage * bm);
-
static void balsa_message_destroy(GObject * object);
static void display_headers(BalsaMessage * bm);
@@ -134,8 +120,6 @@ static void part_context_save_all_cb(GtkWidget * menu_item, GList * info_list);
static void part_context_dump_all_cb(GtkWidget * menu_item, GList * info_list);
static void part_create_menu (BalsaPartInfo* info);
-static GtkNotebookClass *parent_class = NULL;
-
/* stuff needed for sending Message Disposition Notifications */
static void handle_mdn_request(GtkWindow *parent, LibBalsaMessage *message,
LibBalsaMessageHeaders *headers);
@@ -149,9 +133,9 @@ static GtkWidget* create_mdn_dialog (GtkWindow *parent, gchar *sender,
static void mdn_dialog_response(GtkWidget * dialog, gint response,
gpointer user_data);
-static void balsa_part_info_init(GObject *object, gpointer data);
static BalsaPartInfo* balsa_part_info_new(LibBalsaMessageBody* body);
-static void balsa_part_info_free(GObject * object);
+static void balsa_part_info_dispose(GObject * object);
+static void balsa_part_info_finalize(GObject * object);
static LibBalsaMsgProtectState balsa_message_scan_signatures(LibBalsaMessageBody *body,
LibBalsaMessage * message);
@@ -164,63 +148,67 @@ static void message_recheck_crypto_cb(GtkWidget * button, BalsaMessage * bm);
static inline gboolean autocrypt_in_use(void);
#endif
+G_DEFINE_TYPE(BalsaPartInfo, balsa_part_info, G_TYPE_OBJECT)
+
static void
balsa_part_info_class_init(BalsaPartInfoClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
- object_class->finalize = balsa_part_info_free;
+ object_class->dispose = balsa_part_info_dispose;
+ object_class->finalize = balsa_part_info_finalize;
}
-static GType
-balsa_part_info_get_type()
-{
- static GType balsa_part_info_type = 0 ;
+struct _BalsaMessage {
+ GtkBox parent;
- if (!balsa_part_info_type) {
- static const GTypeInfo balsa_part_info_info =
- {
- sizeof (BalsaPartInfoClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) balsa_part_info_class_init,
- (GClassFinalizeFunc) NULL,
- NULL,
- sizeof(BalsaPartInfo),
- 0,
- (GInstanceInitFunc) balsa_part_info_init
- };
- balsa_part_info_type =
- g_type_register_static (G_TYPE_OBJECT, "BalsaPartInfo",
- &balsa_part_info_info, 0);
- }
- return balsa_part_info_type;
-}
+ GtkWidget *stack;
+ GtkWidget *switcher;
-GType
-balsa_message_get_type()
-{
- static GType balsa_message_type = 0;
+ /* Top-level MIME widget */
+ BalsaMimeWidget *bm_widget;
- if (!balsa_message_type) {
- static const GTypeInfo balsa_message_info = {
- sizeof(BalsaMessageClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) balsa_message_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof(BalsaMessage),
- 0, /* n_preallocs */
- (GInstanceInitFunc) balsa_message_init
- };
+ /* header-related information */
+ ShownHeaders shown_headers;
- balsa_message_type =
- g_type_register_static(GTK_TYPE_BOX, "BalsaMessage", &balsa_message_info, 0);
- }
+ /* Widgets to hold content */
+ GtkWidget *scroll;
- return balsa_message_type;
-}
+ /* 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 */
+};
+
+G_DEFINE_TYPE(BalsaMessage, balsa_message, GTK_TYPE_BOX)
static void
balsa_message_class_init(BalsaMessageClass * klass)
@@ -233,17 +221,12 @@ balsa_message_class_init(BalsaMessageClass * klass)
g_signal_new("select-part",
G_TYPE_FROM_CLASS(object_class),
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET(BalsaMessageClass, select_part),
+ 0,
NULL, NULL,
NULL,
G_TYPE_NONE, 0);
object_class->dispose = balsa_message_destroy;
-
- parent_class = g_type_class_peek_parent(klass);
-
- klass->select_part = NULL;
-
}
/* Helpers for balsa_message_init. */
@@ -838,15 +821,9 @@ balsa_message_destroy(GObject * object)
g_list_free(bm->save_all_list);
bm->save_all_list = NULL;
- if (bm->save_all_popup) {
- g_object_unref(bm->save_all_popup);
- bm->save_all_popup = NULL;
- }
-
- if (bm->parts_popup) {
- g_object_unref(bm->parts_popup);
- bm->parts_popup = NULL;
- }
+ g_clear_object(&bm->save_all_popup);
+ g_clear_object(&bm->parts_popup);
+ g_clear_object(&bm->bm_widget);
#ifdef HAVE_HTML_WIDGET
if (bm->html_find_info) {
@@ -855,13 +832,7 @@ balsa_message_destroy(GObject * object)
}
#endif /* HAVE_HTML_WIDGET */
- if (bm->bm_widget) {
- g_object_unref(bm->bm_widget);
- bm->bm_widget = NULL;
- }
-
- if (G_OBJECT_CLASS(parent_class)->dispose)
- (*G_OBJECT_CLASS(parent_class)->dispose) (object);
+ G_OBJECT_CLASS(balsa_message_parent_class)->dispose(object);
}
GtkWidget *
@@ -1727,12 +1698,9 @@ part_create_menu (BalsaPartInfo* info)
g_free (content_type);
}
-
static void
-balsa_part_info_init(GObject *object, gpointer data)
+balsa_part_info_init(BalsaPartInfo *info)
{
- BalsaPartInfo * info = BALSA_PART_INFO(object);
-
info->body = NULL;
info->mime_widget = NULL;
info->popup_menu = NULL;
@@ -1743,31 +1711,31 @@ static BalsaPartInfo*
balsa_part_info_new(LibBalsaMessageBody* body)
{
BalsaPartInfo * info = g_object_new(TYPE_BALSA_PART_INFO, NULL);
+
info->body = body;
+
return info;
}
static void
-balsa_part_info_free(GObject * object)
+balsa_part_info_dispose(GObject * object)
{
- BalsaPartInfo * info;
- GObjectClass *part_info_parent_class;
+ BalsaPartInfo *info = (BalsaPartInfo *) object;
- g_return_if_fail(object != NULL);
- g_return_if_fail(IS_BALSA_PART_INFO(object));
- info = BALSA_PART_INFO(object);
+ g_clear_object(&info->mime_widget);
+ g_clear_object(&info->popup_menu);
- if (info->mime_widget) {
- g_object_unref(G_OBJECT(info->mime_widget));
- info->mime_widget = NULL;
- }
- if (info->popup_menu)
- g_object_unref(info->popup_menu);
+ G_OBJECT_CLASS(balsa_part_info_parent_class)->dispose(object);
+}
+
+static void
+balsa_part_info_finalize(GObject * object)
+{
+ BalsaPartInfo *info = (BalsaPartInfo *) object;
gtk_tree_path_free(info->path);
- part_info_parent_class = g_type_class_peek_parent(G_OBJECT_GET_CLASS(object));
- part_info_parent_class->finalize(object);
+ G_OBJECT_CLASS(balsa_part_info_parent_class)->finalize(object);
}
static void
@@ -3381,3 +3349,93 @@ autocrypt_in_use(void)
return result;
}
#endif
+
+/*
+ * Getters
+ */
+
+gboolean
+balsa_message_get_wrap_text(BalsaMessage *bm)
+{
+ g_return_val_if_fail(BALSA_IS_MESSAGE(bm), FALSE);
+
+ return bm->wrap_text;
+}
+
+BalsaMessageFocusState
+balsa_message_get_focus_state(BalsaMessage *bm)
+{
+ g_return_val_if_fail(BALSA_IS_MESSAGE(bm), 0);
+
+ return bm->focus_state;
+}
+
+GtkScrolledWindow *
+balsa_message_get_scroll(BalsaMessage *bm)
+{
+ g_return_val_if_fail(BALSA_IS_MESSAGE(bm), NULL);
+
+ return GTK_SCROLLED_WINDOW(bm->scroll);
+}
+
+BalsaMimeWidget *
+balsa_message_get_bm_widget(BalsaMessage *bm)
+{
+ g_return_val_if_fail(BALSA_IS_MESSAGE(bm), NULL);
+
+ return bm->bm_widget;
+}
+
+LibBalsaMessage *
+balsa_message_get_message(BalsaMessage *bm)
+{
+ g_return_val_if_fail(BALSA_IS_MESSAGE(bm), NULL);
+
+ return bm->message;
+}
+
+ShownHeaders
+balsa_message_get_shown_headers(BalsaMessage *bm)
+{
+ g_return_val_if_fail(BALSA_IS_MESSAGE(bm), 0);
+
+ return bm->shown_headers;
+}
+
+GtkWidget *
+balsa_message_get_face_box(BalsaMessage *bm)
+{
+ g_return_val_if_fail(BALSA_IS_MESSAGE(bm), NULL);
+
+ return bm->face_box;
+}
+
+GtkWidget *
+balsa_message_get_tree_view(BalsaMessage *bm)
+{
+ g_return_val_if_fail(BALSA_IS_MESSAGE(bm), NULL);
+
+ return bm->treeview;
+}
+
+/*
+ * Setters
+ */
+
+void
+balsa_message_set_focus_state(BalsaMessage *bm,
+ BalsaMessageFocusState focus_state)
+{
+ g_return_if_fail(BALSA_IS_MESSAGE(bm));
+
+ bm->focus_state = focus_state;
+}
+
+void
+balsa_message_set_face_box(BalsaMessage *bm,
+ GtkWidget * face_box)
+{
+ g_return_if_fail(BALSA_IS_MESSAGE(bm));
+
+ g_set_object(&bm->face_box, face_box);
+}
diff --git a/src/balsa-message.h b/src/balsa-message.h
index 8fd06f57b..104b4c5af 100644
--- a/src/balsa-message.h
+++ b/src/balsa-message.h
@@ -29,15 +29,9 @@
G_BEGIN_DECLS
+#define BALSA_TYPE_MESSAGE (balsa_message_get_type ())
-#define BALSA_TYPE_MESSAGE (balsa_message_get_type ())
-#define BALSA_MESSAGE(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, BALSA_TYPE_MESSAGE, BalsaMessage)
-#define BALSA_MESSAGE_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, BALSA_TYPE_MESSAGE, BalsaMessageClass)
-#define BALSA_IS_MESSAGE(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, BALSA_TYPE_MESSAGE)
-
-
-typedef struct _BalsaMessage BalsaMessage;
-typedef struct _BalsaMessageClass BalsaMessageClass;
+G_DECLARE_FINAL_TYPE(BalsaMessage, balsa_message, BALSA, MESSAGE, GtkBox)
typedef struct _BalsaPartInfo BalsaPartInfo;
@@ -49,65 +43,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 */
-};
-
-struct _BalsaMessageClass {
- GtkNotebookClass parent_class;
-
- void (*select_part) (BalsaMessage * message);
-};
-
-GType balsa_message_get_type(void);
GtkWidget *balsa_message_new(void);
gboolean balsa_message_set(BalsaMessage * bmessage,
@@ -143,6 +78,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 080f56652..1149294a8 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;
}
@@ -201,7 +201,7 @@ balsa_mime_widget_key_press_event(GtkWidget * widget, GdkEventKey * event,
int page_adjust;
adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW
- (bm->scroll));
+ (balsa_message_get_scroll(bm)));
page_adjust = balsa_app.pgdownmod ?
(gtk_adjustment_get_page_size(adj) * balsa_app.pgdown_percent) /
@@ -278,11 +278,11 @@ balsa_mime_widget_limit_focus(GtkWidget *widget,
{
/* Disable can_focus on other message parts so that TAB does not
* attempt to move the focus on them. */
- bmw_set_can_focus(bm->bm_widget->container, GINT_TO_POINTER(FALSE));
+ bmw_set_can_focus(balsa_message_get_bm_widget(bm)->container, GINT_TO_POINTER(FALSE));
gtk_widget_set_can_focus(widget, TRUE);
- if (bm->focus_state == BALSA_MESSAGE_FOCUS_STATE_NO)
- bm->focus_state = BALSA_MESSAGE_FOCUS_STATE_YES;
+ if (balsa_message_get_focus_state(bm) == BALSA_MESSAGE_FOCUS_STATE_NO)
+ balsa_message_set_focus_state(bm, BALSA_MESSAGE_FOCUS_STATE_YES);
return FALSE;
}
@@ -293,16 +293,16 @@ balsa_mime_widget_unlimit_focus(GtkWidget *widget,
GdkEventFocus *event,
BalsaMessage *bm)
{
- bmw_set_can_focus(bm->bm_widget->container, GINT_TO_POINTER(TRUE));
+ bmw_set_can_focus(balsa_message_get_bm_widget(bm)->container, GINT_TO_POINTER(TRUE));
- if (bm->message != NULL) {
- BalsaMessageFocusState focus_state = bm->focus_state;
+ if (balsa_message_get_message(bm) != NULL) {
+ BalsaMessageFocusState focus_state = balsa_message_get_focus_state(bm);
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);
}
return FALSE;
diff --git a/src/balsa-mime-widget-message.c b/src/balsa-mime-widget-message.c
index f85d2a261..b43d8add3 100644
--- a/src/balsa-mime-widget-message.c
+++ b/src/balsa-mime-widget-message.c
@@ -136,7 +136,7 @@ balsa_mime_widget_new_message(BalsaMessage * bm,
gtk_box_pack_start(GTK_BOX(mw->container), emb_hdrs, FALSE, FALSE, 0);
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)) {
mw = g_object_new(BALSA_TYPE_MIME_WIDGET, NULL);
mw->widget = gtk_frame_new(_("message headers"));
@@ -507,11 +507,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_container_add(GTK_CONTAINER(action_area), bm->face_box);
+ if (balsa_message_get_face_box(bm) == NULL) {
+ GtkWidget *face_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+
+ balsa_message_set_face_box(bm, face_box);
+ gtk_container_add(GTK_CONTAINER(action_area), face_box);
gtk_button_box_set_child_non_homogeneous(GTK_BUTTON_BOX(action_area),
- bm->face_box, TRUE);
+ face_box, TRUE);
}
if (buttons) {
@@ -664,7 +666,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;
@@ -716,14 +718,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);
@@ -814,7 +814,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
@@ -825,7 +825,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);
}
/*
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index 14ecd1be1..f38a5a182 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -198,7 +198,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(mw->widget)
#endif
@@ -1257,16 +1257,17 @@ bm_widget_new_vcard(BalsaMessage *bm, LibBalsaMessageBody *mime_body,
static gchar *
check_text_encoding(BalsaMessage * bm, gchar *text_buf)
{
+ LibBalsaMessage *message = balsa_message_get_message(bm);
const gchar *target_cs;
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)) {
gchar *from =
- balsa_message_sender_to_gchar(libbalsa_message_get_headers(bm->message)->from, 0);
+ balsa_message_sender_to_gchar(libbalsa_message_get_headers(message)->from, 0);
gchar *subject =
- g_strdup(LIBBALSA_MESSAGE_GET_SUBJECT(bm->message));
+ g_strdup(LIBBALSA_MESSAGE_GET_SUBJECT(message));
libbalsa_utf8_sanitize(&from, balsa_app.convert_unknown_8bit,
NULL);
@@ -1282,7 +1283,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 01b8c2036..e98e775b3 100644
--- a/src/balsa-mime-widget-vcalendar.c
+++ b/src/balsa-mime-widget-vcalendar.c
@@ -47,7 +47,7 @@ balsa_mime_widget_new_vcalendar(BalsaMessage * bm,
GtkWidget *label;
gchar *text;
guint event_no;
- 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 79af27256..946891454 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -4196,7 +4196,7 @@ bw_index_changed_cb(GtkWidget * widget, gpointer data)
bw_enable_message_menus(window, balsa_index_get_current_msgno(index));
bw_enable_mailbox_menus(window, index);
- message = BALSA_MESSAGE(window->preview)->message;
+ message = balsa_message_get_message(BALSA_MESSAGE(window->preview));
current_msgno = message != NULL ? libbalsa_message_get_msgno(message) : 0;
if (current_msgno != balsa_index_get_current_msgno(index))
@@ -4211,7 +4211,7 @@ bw_idle_replace(BalsaWindow * window, BalsaIndex * bindex)
/* Skip if the window is being destroyed: */
if (window->preview != NULL) {
window->set_message_id = g_idle_add((GSourceFunc) bw_idle_cb, window);
- if (BALSA_MESSAGE(window->preview)->message != NULL)
+ if (balsa_message_get_message(BALSA_MESSAGE(window->preview)) != NULL)
gtk_widget_hide(window->preview);
}
}
diff --git a/src/message-window.c b/src/message-window.c
index 0d9c4479f..121cc6132 100644
--- a/src/message-window.c
+++ b/src/message-window.c
@@ -99,7 +99,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",
@@ -731,14 +731,18 @@ mw_select_part_cb(BalsaMessage * bm, gpointer data)
#endif /* HAVE_HTML_WIDGET */
/* set window title */
- if (bm && bm->message) {
- from = internet_address_list_to_string(libbalsa_message_get_headers(bm->message)->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 = balsa_message_get_message(bm);
+
+ if (message != NULL) {
+ from = internet_address_list_to_string(libbalsa_message_get_headers(message)->from,
+ FALSE);
+ title = g_strdup_printf(_("Message from %s: %s"), from,
+ LIBBALSA_MESSAGE_GET_SUBJECT(message));
+ 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]