[balsa/mime-widgets] mime-widget: Declare BalsaMimeWidget derivable
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/mime-widgets] mime-widget: Declare BalsaMimeWidget derivable
- Date: Sat, 31 Aug 2019 19:04:32 +0000 (UTC)
commit ffc5791c1797c05adf1a108f1c603f42bfd17be8
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sat Aug 31 15:03:28 2019 -0400
mime-widget: Declare BalsaMimeWidget derivable
Make the struct private, and provide accessors for the widget,
container, and header_widget members.
* src/balsa-message.c (bm_find_scroll_to_rectangle),
(bm_find_entry_changed_cb), (bm_find_again), (balsa_message_init),
(add_part), (gtk_tree_hide_func), (hide_all_parts), (select_part),
(balsa_message_current_part_widget), (balsa_message_can_select),
(balsa_message_grab_focus), (balsa_message_can_zoom),
(balsa_message_zoom), (balsa_message_find_in_message):
* src/balsa-mime-widget-callbacks.c
(balsa_mime_widget_limit_focus), (balsa_mime_widget_unlimit_focus):
* src/balsa-mime-widget-crypto.c (balsa_mime_widget_new_signature),
(balsa_mime_widget_new_pgpkey):
* src/balsa-mime-widget-image.c (balsa_mime_widget_new_image):
* src/balsa-mime-widget-message.c (balsa_mime_widget_new_message),
(bmw_message_extbody_url), (bmw_message_extbody_mail),
(balsa_mime_widget_new_message_tl), (bmw_message_set_headers_d),
(bmw_message_set_headers):
* src/balsa-mime-widget-multipart.c
(balsa_mime_widget_new_multipart):
* src/balsa-mime-widget-text.c (balsa_mime_widget_new_text),
(bm_widget_new_html), (bm_widget_new_vcard):
* src/balsa-mime-widget-vcalendar.c
(balsa_mime_widget_new_vcalendar):
* src/balsa-mime-widget.c (balsa_mime_widget_init),
(balsa_mime_widget_class_init), (balsa_mime_widget_new),
(balsa_mime_widget_new_unknown), (vadj_change_cb),
(balsa_mime_widget_get_widget), (balsa_mime_widget_get_container),
(balsa_mime_widget_get_header_widget),
(balsa_mime_widget_set_widget), (balsa_mime_widget_set_container),
(balsa_mime_widget_set_header_widget):
* src/balsa-mime-widget.h:
ChangeLog | 37 ++++++++
src/balsa-message.c | 40 +++++----
src/balsa-mime-widget-callbacks.c | 8 +-
src/balsa-mime-widget-crypto.c | 21 +++--
src/balsa-mime-widget-image.c | 9 +-
src/balsa-mime-widget-message.c | 93 ++++++++++++++-------
src/balsa-mime-widget-multipart.c | 21 +++--
src/balsa-mime-widget-text.c | 80 ++++++++++--------
src/balsa-mime-widget-vcalendar.c | 9 +-
src/balsa-mime-widget.c | 172 +++++++++++++++++++++++++-------------
src/balsa-mime-widget.h | 49 +++++------
11 files changed, 349 insertions(+), 190 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 75f955365..d3d717556 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,40 @@
+2019-08-31 Peter Bloomfield <pbloomfield bellsouth net>
+
+ mime-widget: Declare BalsaMimeWidget derivable
+
+ Make the struct private, and provide accessors for the widget,
+ container, and header_widget members.
+
+ * src/balsa-message.c (bm_find_scroll_to_rectangle),
+ (bm_find_entry_changed_cb), (bm_find_again), (balsa_message_init),
+ (add_part), (gtk_tree_hide_func), (hide_all_parts), (select_part),
+ (balsa_message_current_part_widget), (balsa_message_can_select),
+ (balsa_message_grab_focus), (balsa_message_can_zoom),
+ (balsa_message_zoom), (balsa_message_find_in_message):
+ * src/balsa-mime-widget-callbacks.c
+ (balsa_mime_widget_limit_focus), (balsa_mime_widget_unlimit_focus):
+ * src/balsa-mime-widget-crypto.c (balsa_mime_widget_new_signature),
+ (balsa_mime_widget_new_pgpkey):
+ * src/balsa-mime-widget-image.c (balsa_mime_widget_new_image):
+ * src/balsa-mime-widget-message.c (balsa_mime_widget_new_message),
+ (bmw_message_extbody_url), (bmw_message_extbody_mail),
+ (balsa_mime_widget_new_message_tl), (bmw_message_set_headers_d),
+ (bmw_message_set_headers):
+ * src/balsa-mime-widget-multipart.c
+ (balsa_mime_widget_new_multipart):
+ * src/balsa-mime-widget-text.c (balsa_mime_widget_new_text),
+ (bm_widget_new_html), (bm_widget_new_vcard):
+ * src/balsa-mime-widget-vcalendar.c
+ (balsa_mime_widget_new_vcalendar):
+ * src/balsa-mime-widget.c (balsa_mime_widget_init),
+ (balsa_mime_widget_class_init), (balsa_mime_widget_new),
+ (balsa_mime_widget_new_unknown), (vadj_change_cb),
+ (balsa_mime_widget_get_widget), (balsa_mime_widget_get_container),
+ (balsa_mime_widget_get_header_widget),
+ (balsa_mime_widget_set_widget), (balsa_mime_widget_set_container),
+ (balsa_mime_widget_set_header_widget):
+ * src/balsa-mime-widget.h:
+
2019-08-25 Peter Bloomfield <pbloomfield bellsouth net>
* src/balsa-print-object-text.c
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 404897eca..c00335a15 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -376,7 +376,8 @@ bm_find_scroll_to_rectangle(BalsaMessage * balsa_message,
GtkAdjustment *adj;
GtkScrolledWindow *scroll = GTK_SCROLLED_WINDOW(balsa_message->scroll);
- gtk_widget_translate_coordinates(widget, balsa_message->bm_widget->widget,
+ gtk_widget_translate_coordinates(widget,
+ balsa_mime_widget_get_widget(balsa_message->bm_widget),
rectangle->x, rectangle->y,
&x, &y);
@@ -453,7 +454,7 @@ bm_find_entry_changed_cb(GtkEditable * editable, gpointer data)
{
const gchar *text = gtk_entry_get_text(GTK_ENTRY(editable));
BalsaMessage *balsa_message = data;
- GtkWidget *widget = balsa_message->current_part->mime_widget->widget;
+ GtkWidget *widget = balsa_mime_widget_get_widget(balsa_message->current_part->mime_widget);
gboolean found = FALSE;
if (GTK_IS_TEXT_VIEW(widget)) {
@@ -513,7 +514,7 @@ static void
bm_find_again(BalsaMessage * balsa_message, gboolean find_forward)
{
const gchar *text = gtk_entry_get_text(GTK_ENTRY(balsa_message->find_entry));
- GtkWidget *widget = balsa_message->current_part->mime_widget->widget;
+ GtkWidget *widget = balsa_mime_widget_get_widget(balsa_message->current_part->mime_widget);
gboolean found;
balsa_message->find_forward = find_forward;
@@ -717,10 +718,10 @@ balsa_message_init(BalsaMessage * balsa_message)
g_free(buttons);
/* Widget to hold message */
- g_signal_connect(balsa_message->bm_widget->widget, "focus_in_event",
+ g_signal_connect(balsa_mime_widget_get_widget(balsa_message->bm_widget), "focus_in_event",
G_CALLBACK(balsa_mime_widget_limit_focus),
(gpointer) balsa_message);
- g_signal_connect(balsa_message->bm_widget->widget, "focus_out_event",
+ g_signal_connect(balsa_mime_widget_get_widget(balsa_message->bm_widget), "focus_out_event",
G_CALLBACK(balsa_mime_widget_unlimit_focus),
(gpointer) balsa_message);
@@ -728,7 +729,7 @@ balsa_message_init(BalsaMessage * balsa_message)
* provide one, but it would also set it up to scroll on grab-focus,
* which has been really annoying for a long time :-( */
viewport = gtk_viewport_new(NULL, NULL);
- gtk_container_add(GTK_CONTAINER(viewport), balsa_message->bm_widget->widget);
+ gtk_container_add(GTK_CONTAINER(viewport), balsa_mime_widget_get_widget(balsa_message->bm_widget));
gtk_container_add(GTK_CONTAINER(balsa_message->scroll), viewport);
/* structure view */
@@ -2206,6 +2207,7 @@ add_part(BalsaMessage * balsa_message, BalsaPartInfo * info, GtkWidget * contain
GtkTreeSelection *selection;
GtkWidget *widget;
LibBalsaMessageBody *body;
+ GtkWidget *info_container;
if (!info)
return NULL;
@@ -2219,13 +2221,14 @@ add_part(BalsaMessage * balsa_message, BalsaPartInfo * info, GtkWidget * contain
if (info->mime_widget == NULL)
part_info_init(balsa_message, info);
- if ((widget = info->mime_widget->widget))
+ if ((widget = balsa_mime_widget_get_widget(info->mime_widget)))
gtk_box_pack_start(GTK_BOX(container), widget, TRUE, TRUE, 0);
+ info_container = balsa_mime_widget_get_container(info->mime_widget);
body =
add_multipart(balsa_message, info->body,
- info->mime_widget->container ?
- info->mime_widget->container : container);
+ info_container != NULL ?
+ info_container : container);
return body;
}
@@ -2241,7 +2244,7 @@ gtk_tree_hide_func(GtkTreeModel * model, GtkTreePath * path,
if (info) {
GtkWidget *widget, *parent;
- if (info->mime_widget && (widget = info->mime_widget->widget)
+ if (info->mime_widget && (widget = balsa_mime_widget_get_widget(info->mime_widget))
&& (parent = gtk_widget_get_parent(widget)))
gtk_container_remove(GTK_CONTAINER(parent), widget);
g_object_unref(info);
@@ -2263,7 +2266,7 @@ hide_all_parts(BalsaMessage * balsa_message)
balsa_message->current_part = NULL;
}
- gtk_container_foreach(GTK_CONTAINER(balsa_message->bm_widget->container),
+ gtk_container_foreach(GTK_CONTAINER(balsa_mime_widget_get_container(balsa_message->bm_widget)),
(GtkCallback) gtk_widget_destroy, NULL);
}
@@ -2279,7 +2282,8 @@ select_part(BalsaMessage * balsa_message, BalsaPartInfo *info)
hide_all_parts(balsa_message);
bm_disable_find_entry(balsa_message);
- body = add_part(balsa_message, info, balsa_message->bm_widget->container);
+ body = add_part(balsa_message, info,
+ balsa_mime_widget_get_container(balsa_message->bm_widget));
balsa_message->current_part = part_info_from_body(balsa_message, body);
g_signal_emit(balsa_message, balsa_message_signals[SELECT_PART], 0);
@@ -2300,7 +2304,7 @@ balsa_message_current_part_widget(BalsaMessage * balsa_message)
{
if (balsa_message && balsa_message->current_part &&
balsa_message->current_part->mime_widget)
- return balsa_message->current_part->mime_widget->widget;
+ return balsa_mime_widget_get_widget(balsa_message->current_part->mime_widget);
else
return NULL;
}
@@ -2331,7 +2335,7 @@ balsa_message_can_select(BalsaMessage * balsa_message)
g_return_val_if_fail(balsa_message != NULL, FALSE);
if (balsa_message->current_part == NULL
- || (w = balsa_message->current_part->mime_widget->widget) == NULL)
+ || (w = balsa_mime_widget_get_widget(balsa_message->current_part->mime_widget)) == NULL)
return FALSE;
return GTK_IS_EDITABLE(w) || GTK_IS_TEXT_VIEW(w)
@@ -2349,7 +2353,7 @@ balsa_message_grab_focus(BalsaMessage * balsa_message)
g_return_val_if_fail(balsa_message != NULL, FALSE);
g_return_val_if_fail(balsa_message->current_part != NULL, FALSE);
- widget = balsa_message->current_part->mime_widget->widget;
+ widget = balsa_mime_widget_get_widget(balsa_message->current_part->mime_widget);
g_return_val_if_fail(widget != NULL, FALSE);
gtk_widget_set_can_focus(widget, TRUE);
@@ -2649,7 +2653,7 @@ gboolean
balsa_message_can_zoom(BalsaMessage * balsa_message)
{
return balsa_message->current_part
- && libbalsa_html_can_zoom(balsa_message->current_part->mime_widget->widget);
+ && libbalsa_html_can_zoom(balsa_mime_widget_get_widget(balsa_message->current_part->mime_widget));
}
/* Zoom an html item. */
@@ -2671,7 +2675,7 @@ balsa_message_zoom(BalsaMessage * balsa_message, gint in_out)
g_object_set_data(G_OBJECT(balsa_message->message), BALSA_MESSAGE_ZOOM_KEY,
GINT_TO_POINTER(zoom));
- libbalsa_html_zoom(balsa_message->current_part->mime_widget->widget, in_out);
+ libbalsa_html_zoom(balsa_mime_widget_get_widget(balsa_message->current_part->mime_widget), in_out);
}
#endif /* HAVE_HTML_WIDGET */
@@ -3299,7 +3303,7 @@ balsa_message_find_in_message(BalsaMessage * balsa_message)
GtkWidget *w;
if (balsa_message->current_part
- && (w = balsa_message->current_part->mime_widget->widget)
+ && (w = balsa_mime_widget_get_widget(balsa_message->current_part->mime_widget))
&& (GTK_IS_TEXT_VIEW(w)
#ifdef HAVE_HTML_WIDGET
|| libbalsa_html_can_search(w)
diff --git a/src/balsa-mime-widget-callbacks.c b/src/balsa-mime-widget-callbacks.c
index 1149294a8..26504287d 100644
--- a/src/balsa-mime-widget-callbacks.c
+++ b/src/balsa-mime-widget-callbacks.c
@@ -276,9 +276,11 @@ balsa_mime_widget_limit_focus(GtkWidget *widget,
GdkEventFocus *event,
BalsaMessage *bm)
{
+ GtkWidget *container = balsa_mime_widget_get_container(balsa_message_get_bm_widget(bm));
+
/* Disable can_focus on other message parts so that TAB does not
* attempt to move the focus on them. */
- bmw_set_can_focus(balsa_message_get_bm_widget(bm)->container, GINT_TO_POINTER(FALSE));
+ bmw_set_can_focus(container, GINT_TO_POINTER(FALSE));
gtk_widget_set_can_focus(widget, TRUE);
if (balsa_message_get_focus_state(bm) == BALSA_MESSAGE_FOCUS_STATE_NO)
@@ -293,7 +295,9 @@ balsa_mime_widget_unlimit_focus(GtkWidget *widget,
GdkEventFocus *event,
BalsaMessage *bm)
{
- bmw_set_can_focus(balsa_message_get_bm_widget(bm)->container, GINT_TO_POINTER(TRUE));
+ GtkWidget *container = balsa_mime_widget_get_container(balsa_message_get_bm_widget(bm));
+
+ bmw_set_can_focus(container, GINT_TO_POINTER(TRUE));
if (balsa_message_get_message(bm) != NULL) {
BalsaMessageFocusState focus_state = balsa_message_get_focus_state(bm);
diff --git a/src/balsa-mime-widget-crypto.c b/src/balsa-mime-widget-crypto.c
index 681b7bedb..02ff5f8d0 100644
--- a/src/balsa-mime-widget-crypto.c
+++ b/src/balsa-mime-widget-crypto.c
@@ -46,13 +46,13 @@ balsa_mime_widget_new_signature(BalsaMessage * bm,
g_return_val_if_fail(mime_body != NULL, NULL);
g_return_val_if_fail(content_type != NULL, NULL);
-
- if (!mime_body->sig_info)
+
+ if (mime_body->sig_info == NULL)
return NULL;
mw = g_object_new(BALSA_TYPE_MIME_WIDGET, NULL);
- mw->widget = balsa_mime_widget_signature_widget(mime_body, content_type);
-
+ balsa_mime_widget_set_widget(mw, balsa_mime_widget_signature_widget(mime_body, content_type));
+
return mw;
}
@@ -65,7 +65,7 @@ balsa_mime_widget_new_pgpkey(BalsaMessage *bm,
gssize body_size;
gchar *body_buf = NULL;
GError *err = NULL;
- BalsaMimeWidget *mw = NULL;
+ BalsaMimeWidget *mw = NULL;
g_return_val_if_fail(mime_body != NULL, NULL);
g_return_val_if_fail(content_type != NULL, NULL);
@@ -76,15 +76,18 @@ balsa_mime_widget_new_pgpkey(BalsaMessage *bm,
err ? err->message : "Unknown error");
g_clear_error(&err);
} else {
- mw = g_object_new(BALSA_TYPE_MIME_WIDGET, NULL);
- mw->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_VBOX_SPACE);
- if (!create_import_keys_widget(GTK_BOX(mw->widget), body_buf, &err)) {
+ GtkWidget *widget;
+
+ mw = g_object_new(BALSA_TYPE_MIME_WIDGET, NULL);
+ widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_VBOX_SPACE);
+ balsa_mime_widget_set_widget(mw, widget);
+ if (!create_import_keys_widget(GTK_BOX(widget), body_buf, &err)) {
balsa_information(LIBBALSA_INFORMATION_ERROR, _("Could not process GnuPG keys: %s"),
err ? err->message : "Unknown error");
g_clear_error(&err);
g_object_unref(mw);
mw = NULL;
- }
+ }
g_free(body_buf);
}
diff --git a/src/balsa-mime-widget-image.c b/src/balsa-mime-widget-image.c
index 41fc74a32..db7f8613e 100644
--- a/src/balsa-mime-widget-image.c
+++ b/src/balsa-mime-widget-image.c
@@ -79,6 +79,7 @@ balsa_mime_widget_new_image(BalsaMessage * bm,
GError * load_err = NULL;
BalsaMimeWidgetImage *mwi;
BalsaMimeWidget *mw;
+ GtkWidget *widget;
g_return_val_if_fail(mime_body != NULL, NULL);
g_return_val_if_fail(content_type != NULL, NULL);
@@ -97,8 +98,10 @@ balsa_mime_widget_new_image(BalsaMessage * bm,
mwi = g_object_new(BALSA_TYPE_MIME_WIDGET_IMAGE, NULL);
mw = (BalsaMimeWidget *) mwi;
- mw->widget = gtk_event_box_new();
- g_signal_connect(mw->widget, "button-press-event",
+ widget = gtk_event_box_new();
+ balsa_mime_widget_set_widget(mw, widget);
+
+ g_signal_connect(widget, "button-press-event",
G_CALLBACK(balsa_image_button_press_cb), data);
image = gtk_image_new_from_icon_name("image-missing",
@@ -107,7 +110,7 @@ balsa_mime_widget_new_image(BalsaMessage * bm,
GINT_TO_POINTER(gdk_pixbuf_get_width(pixbuf)));
g_object_set_data(G_OBJECT(image), "mime-body", mime_body);
g_object_unref(pixbuf);
- gtk_container_add(GTK_CONTAINER(mw->widget), image);
+ gtk_container_add(GTK_CONTAINER(widget), image);
return mw;
}
diff --git a/src/balsa-mime-widget-message.c b/src/balsa-mime-widget-message.c
index 63cfeff23..bf78a6a82 100644
--- a/src/balsa-mime-widget-message.c
+++ b/src/balsa-mime-widget-message.c
@@ -122,29 +122,44 @@ balsa_mime_widget_new_message(BalsaMessage * bm,
g_free(access_type);
} else if (!g_ascii_strcasecmp("message/rfc822", content_type)) {
GtkWidget *emb_hdrs;
+ GtkWidget *widget;
+ GtkWidget *container;
mw = g_object_new(BALSA_TYPE_MIME_WIDGET, NULL);
- mw->widget = gtk_frame_new(NULL);
+ widget = gtk_frame_new(NULL);
+ balsa_mime_widget_set_widget(mw, widget);
- mw->container = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_MESSAGE_PADDING);
- gtk_container_set_border_width(GTK_CONTAINER(mw->container),
+ container = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_MESSAGE_PADDING);
+ balsa_mime_widget_set_container(mw, container);
+
+ gtk_container_set_border_width(GTK_CONTAINER(container),
BMW_MESSAGE_PADDING);
- gtk_container_add(GTK_CONTAINER(mw->widget), mw->container);
+ gtk_container_add(GTK_CONTAINER(widget), container);
+
+ emb_hdrs = bm_header_widget_new(bm, NULL);
+ balsa_mime_widget_set_header_widget(mw, emb_hdrs);
- mw->header_widget = emb_hdrs = bm_header_widget_new(bm, NULL);
- gtk_box_pack_start(GTK_BOX(mw->container), emb_hdrs, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(container), emb_hdrs, FALSE, FALSE, 0);
bmw_message_set_headers(bm, mw, mime_body,
balsa_message_get_shown_headers(bm) == HEADERS_ALL);
} else if (!g_ascii_strcasecmp("text/rfc822-headers", content_type)) {
+ GtkWidget *widget;
+ GtkWidget *header_widget;
+
mw = g_object_new(BALSA_TYPE_MIME_WIDGET, NULL);
- mw->widget = gtk_frame_new(_("message headers"));
- mw->header_widget = bm_header_widget_new(bm, NULL);
- gtk_widget_set_valign(mw->header_widget, GTK_ALIGN_START);
- gtk_widget_set_vexpand(mw->header_widget, FALSE);
- g_object_set(mw->header_widget, "margin", 5, NULL);
- gtk_container_add(GTK_CONTAINER(mw->widget), mw->header_widget);
+
+ widget = gtk_frame_new(_("message headers"));
+ balsa_mime_widget_set_widget(mw, widget);
+
+ header_widget = bm_header_widget_new(bm, NULL);
+ balsa_mime_widget_set_header_widget(mw, header_widget);
+
+ gtk_widget_set_valign(header_widget, GTK_ALIGN_START);
+ gtk_widget_set_vexpand(header_widget, FALSE);
+ g_object_set(header_widget, "margin", 5, NULL);
+ gtk_container_add(GTK_CONTAINER(widget), header_widget);
bmw_message_set_headers(bm, mw, mime_body, TRUE);
}
@@ -162,6 +177,7 @@ bmw_message_extbody_url(LibBalsaMessageBody * mime_body,
GString *msg = NULL;
gchar *url;
BalsaMimeWidget *mw;
+ GtkWidget *widget;
if (url_type == RFC2046_EXTBODY_LOCALFILE) {
url = libbalsa_message_body_get_parameter(mime_body, "name");
@@ -225,17 +241,19 @@ bmw_message_extbody_url(LibBalsaMessageBody * mime_body,
/* now create & return the widget... */
mw = g_object_new(BALSA_TYPE_MIME_WIDGET, NULL);
-
- mw->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_VBOX_SPACE);
- gtk_container_set_border_width(GTK_CONTAINER(mw->widget),
+
+ widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_VBOX_SPACE);
+ balsa_mime_widget_set_widget(mw, widget);
+
+ gtk_container_set_border_width(GTK_CONTAINER(widget),
BMW_CONTAINER_BORDER);
- gtk_box_pack_start(GTK_BOX(mw->widget), gtk_label_new(msg->str), FALSE,
+ gtk_box_pack_start(GTK_BOX(widget), gtk_label_new(msg->str), FALSE,
FALSE, 0);
g_string_free(msg, TRUE);
button = gtk_button_new_with_label(url);
- gtk_box_pack_start(GTK_BOX(mw->widget), button, FALSE, FALSE,
+ gtk_box_pack_start(GTK_BOX(widget), button, FALSE, FALSE,
BMW_BUTTON_PACK_SPACE);
g_object_set_data_full(G_OBJECT(button), "call_url", url,
(GDestroyNotify) g_free);
@@ -253,6 +271,7 @@ bmw_message_extbody_mail(LibBalsaMessageBody * mime_body)
GString *msg = NULL;
gchar *mail_subject, *mail_site;
BalsaMimeWidget *mw;
+ GtkWidget *widget;
mail_site = libbalsa_message_body_get_parameter(mime_body, "server");
@@ -272,19 +291,21 @@ bmw_message_extbody_mail(LibBalsaMessageBody * mime_body)
/* now create & return the widget... */
mw = g_object_new(BALSA_TYPE_MIME_WIDGET, NULL);
-
- mw->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_VBOX_SPACE);
- gtk_container_set_border_width(GTK_CONTAINER(mw->widget),
+
+ widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_VBOX_SPACE);
+ balsa_mime_widget_set_widget(mw, widget);
+
+ gtk_container_set_border_width(GTK_CONTAINER(widget),
BMW_CONTAINER_BORDER);
- gtk_box_pack_start(GTK_BOX(mw->widget), gtk_label_new(msg->str), FALSE,
+ gtk_box_pack_start(GTK_BOX(widget), gtk_label_new(msg->str), FALSE,
FALSE, 0);
g_string_free(msg, TRUE);
button =
gtk_button_new_with_mnemonic(_
("Se_nd message to obtain this part"));
- gtk_box_pack_start(GTK_BOX(mw->widget), button, FALSE, FALSE,
+ gtk_box_pack_start(GTK_BOX(widget), button, FALSE, FALSE,
BMW_BUTTON_PACK_SPACE);
g_signal_connect(button, "clicked",
G_CALLBACK(extbody_send_mail), (gpointer) mime_body);
@@ -398,19 +419,27 @@ BalsaMimeWidget *
balsa_mime_widget_new_message_tl(BalsaMessage * bm,
GtkWidget * const * tl_buttons)
{
- GtkWidget *headers;
BalsaMimeWidget *mw;
+ GtkWidget *widget;
+ GtkWidget *headers;
+ GtkWidget *container;
mw = g_object_new(BALSA_TYPE_MIME_WIDGET, NULL);
- mw->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_MESSAGE_PADDING);
- gtk_container_set_border_width(GTK_CONTAINER(mw->widget), BMW_MESSAGE_PADDING);
+ widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_MESSAGE_PADDING);
+ balsa_mime_widget_set_widget(mw, widget);
- mw->header_widget = headers = bm_header_widget_new(bm, tl_buttons);
- gtk_box_pack_start(GTK_BOX(mw->widget), headers, FALSE, FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(widget), BMW_MESSAGE_PADDING);
- mw->container = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_MESSAGE_PADDING);
- gtk_box_pack_start(GTK_BOX(mw->widget), mw->container, TRUE, TRUE,
+ headers = bm_header_widget_new(bm, tl_buttons);
+ balsa_mime_widget_set_header_widget(mw, headers);
+
+ gtk_box_pack_start(GTK_BOX(widget), headers, FALSE, FALSE, 0);
+
+ container = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_MESSAGE_PADDING);
+ balsa_mime_widget_set_container(mw, container);
+
+ gtk_box_pack_start(GTK_BOX(widget), container, TRUE, TRUE,
BMW_CONTAINER_BORDER - BMW_MESSAGE_PADDING);
return mw;
@@ -703,7 +732,7 @@ bmw_message_set_headers_d(BalsaMessage * bm,
gchar *date;
GtkWidget * widget;
- if (!(widget = mw->header_widget))
+ if ((widget = balsa_mime_widget_get_header_widget(mw)) == NULL)
return;
grid = bm_header_widget_get_grid(widget);
@@ -801,8 +830,10 @@ bmw_message_set_headers(BalsaMessage * bm,
bmw_message_set_headers_d(bm, mw, part->embhdrs, part->parts,
part->embhdrs ? part->embhdrs->subject : NULL,
show_all_headers);
- if (!(widget = mw->header_widget))
+
+ if ((widget = balsa_mime_widget_get_header_widget(mw)) == NULL)
return;
+
grid = bm_header_widget_get_grid(widget);
gtk_container_foreach(GTK_CONTAINER(grid), (GtkCallback) foreach_label,
part);
diff --git a/src/balsa-mime-widget-multipart.c b/src/balsa-mime-widget-multipart.c
index ef9f5be8c..514f82a2d 100644
--- a/src/balsa-mime-widget-multipart.c
+++ b/src/balsa-mime-widget-multipart.c
@@ -34,19 +34,26 @@ balsa_mime_widget_new_multipart(BalsaMessage * bm,
const gchar * content_type, gpointer data)
{
BalsaMimeWidget *mw;
+ GtkWidget *widget;
g_return_val_if_fail(mime_body != NULL, NULL);
g_return_val_if_fail(content_type != NULL, NULL);
mw = g_object_new(BALSA_TYPE_MIME_WIDGET, NULL);
- mw->widget = mw->container = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_MESSAGE_PADDING);
-
- if (!g_ascii_strcasecmp("multipart/signed", content_type) &&
- mime_body->parts && mime_body->parts->next &&
- mime_body->parts->next->sig_info)
- mw->widget =
- balsa_mime_widget_crypto_frame(mime_body->parts->next, mw->widget,
+ widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_MESSAGE_PADDING);
+ balsa_mime_widget_set_widget(mw, widget);
+ balsa_mime_widget_set_container(mw, widget);
+
+ if (g_ascii_strcasecmp("multipart/signed", content_type) == 0 &&
+ mime_body->parts != NULL &&
+ mime_body->parts->next != NULL &&
+ mime_body->parts->next->sig_info != NULL) {
+ GtkWidget *crypto_frame =
+ balsa_mime_widget_crypto_frame(mime_body->parts->next, widget,
mime_body->was_encrypted, FALSE, NULL);
+ balsa_mime_widget_set_widget(mw, crypto_frame);
+ }
+
return mw;
}
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index d077c07a5..1b6855c72 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -133,7 +133,7 @@ balsa_mime_widget_new_text(BalsaMessage * bm, LibBalsaMessageBody * mime_body,
GList *url_list = NULL;
GError *err = NULL;
gboolean is_text_plain;
-
+ GtkWidget *widget;
g_return_val_if_fail(mime_body != NULL, NULL);
g_return_val_if_fail(content_type != NULL, NULL);
@@ -175,24 +175,25 @@ balsa_mime_widget_new_text(BalsaMessage * bm, LibBalsaMessageBody * mime_body,
/* create the mime object and the text/source view widget */
mw = g_object_new(BALSA_TYPE_MIME_WIDGET, NULL);
- mw->widget = create_text_widget(content_type);
+ widget = create_text_widget(content_type);
+ balsa_mime_widget_set_widget(mw, widget);
/* configure text or source view */
- gtk_text_view_set_editable(GTK_TEXT_VIEW(mw->widget), FALSE);
+ gtk_text_view_set_editable(GTK_TEXT_VIEW(widget), FALSE);
#if GTK_CHECK_VERSION(3, 23, 1)
- gtk_text_view_set_left_margin(GTK_TEXT_VIEW(mw->widget), BALSA_LEFT_MARGIN);
- gtk_text_view_set_right_margin(GTK_TEXT_VIEW(mw->widget), BALSA_RIGHT_MARGIN);
+ gtk_text_view_set_left_margin(GTK_TEXT_VIEW(widget), BALSA_LEFT_MARGIN);
+ gtk_text_view_set_right_margin(GTK_TEXT_VIEW(widget), BALSA_RIGHT_MARGIN);
#else /* GTK_CHECK_VERSION(3, 23, 1) */
- gtk_text_view_set_left_margin(GTK_TEXT_VIEW(mw->widget), 0);
- gtk_text_view_set_right_margin(GTK_TEXT_VIEW(mw->widget), 0);
- gtk_widget_set_margin_start(mw->widget, BALSA_LEFT_MARGIN);
- gtk_widget_set_margin_end(mw->widget, BALSA_RIGHT_MARGIN);
+ gtk_text_view_set_left_margin(GTK_TEXT_VIEW(widget), 0);
+ gtk_text_view_set_right_margin(GTK_TEXT_VIEW(widget), 0);
+ gtk_widget_set_margin_start(widget, BALSA_LEFT_MARGIN);
+ gtk_widget_set_margin_end(widget, BALSA_RIGHT_MARGIN);
#endif /* GTK_CHECK_VERSION(3, 23, 1) */
- gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(mw->widget), GTK_WRAP_WORD_CHAR);
+ gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(widget), GTK_WRAP_WORD_CHAR);
/* set the message font */
if (!balsa_app.use_system_fonts)
- bm_modify_font_from_string(mw->widget, balsa_app.message_font);
+ bm_modify_font_from_string(widget, balsa_app.message_font);
if (libbalsa_message_body_is_flowed(mime_body)) {
/* Parse, but don't wrap. */
@@ -200,43 +201,43 @@ balsa_mime_widget_new_text(BalsaMessage * bm, LibBalsaMessageBody * mime_body,
ptr = libbalsa_wrap_rfc2646(ptr, G_MAXINT, FALSE, TRUE, delsp);
} else if (balsa_message_get_wrap_text(bm)
#if HAVE_GTKSOURCEVIEW
- && !GTK_SOURCE_IS_VIEW(mw->widget)
+ && !GTK_SOURCE_IS_VIEW(widget)
#endif
)
libbalsa_wrap_string(ptr, balsa_app.browse_wrap_length);
- g_signal_connect(mw->widget, "key_press_event",
+ g_signal_connect(widget, "key_press_event",
G_CALLBACK(balsa_mime_widget_key_press_event),
(gpointer) bm);
- g_signal_connect(mw->widget, "populate-popup",
+ g_signal_connect(widget, "populate-popup",
G_CALLBACK(text_view_populate_popup),
(gpointer)mime_body);
- buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(mw->widget));
+ buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget));
- url_list = fill_text_buf_cited(mw->widget, ptr,
+ url_list = fill_text_buf_cited(widget, ptr,
libbalsa_message_body_is_flowed(mime_body),
is_text_plain);
prepare_url_offsets(buffer, url_list);
- g_signal_connect_after(mw->widget, "realize",
+ g_signal_connect_after(widget, "realize",
G_CALLBACK(fix_text_widget), url_list);
if (url_list) {
- g_signal_connect(mw->widget, "button_press_event",
+ g_signal_connect(widget, "button_press_event",
G_CALLBACK(store_button_coords), NULL);
- g_signal_connect(mw->widget, "button_release_event",
+ g_signal_connect(widget, "button_release_event",
G_CALLBACK(check_call_url), url_list);
- g_signal_connect(mw->widget, "motion-notify-event",
+ g_signal_connect(widget, "motion-notify-event",
G_CALLBACK(check_over_url), url_list);
- g_signal_connect(mw->widget, "leave-notify-event",
+ g_signal_connect(widget, "leave-notify-event",
G_CALLBACK(check_over_url), url_list);
- g_object_set_data_full(G_OBJECT(mw->widget), "url-list", url_list,
+ g_object_set_data_full(G_OBJECT(widget), "url-list", url_list,
(GDestroyNotify)free_url_list);
}
if (is_text_plain) {
/* plain-text highlighting */
- g_object_set_data(G_OBJECT(mw->widget), "phrase-highlight",
+ g_object_set_data(G_OBJECT(widget), "phrase-highlight",
GINT_TO_POINTER(PHRASE_HIGHLIGHT_ON));
phrase_highlight(buffer, "hp-bold", '*', "weight", PANGO_WEIGHT_BOLD);
phrase_highlight(buffer, "hp-underline", '_', "underline", PANGO_UNDERLINE_SINGLE);
@@ -244,7 +245,7 @@ balsa_mime_widget_new_text(BalsaMessage * bm, LibBalsaMessageBody * mime_body,
}
/* size allocation may not be correct, so we'll check back later */
- balsa_mime_widget_schedule_resize(mw->widget);
+ balsa_mime_widget_schedule_resize(widget);
g_free(ptr);
@@ -1182,24 +1183,28 @@ bm_widget_new_html(BalsaMessage * bm, LibBalsaMessageBody * mime_body)
{
BalsaMimeWidget *mw = g_object_new(BALSA_TYPE_MIME_WIDGET, NULL);
GtkWidget *widget;
+ GtkWidget *popup_menu;
- mw->widget =
+ widget =
libbalsa_html_new(mime_body,
(LibBalsaHtmlCallback) bm_widget_on_url,
(LibBalsaHtmlCallback) handle_url);
- g_object_set_data(G_OBJECT(mw->widget), "mime-body", mime_body);
+ balsa_mime_widget_set_widget(mw, widget);
+
+ g_object_set_data(G_OBJECT(widget), "mime-body", mime_body);
- g_signal_connect(libbalsa_html_get_view_widget(mw->widget),
+ g_signal_connect(libbalsa_html_get_view_widget(widget),
"key_press_event",
G_CALLBACK(balsa_mime_widget_key_press_event), bm);
- if ((widget = libbalsa_html_popup_menu_widget(mw->widget))) {
- g_object_set_data(G_OBJECT(widget), "balsa-message", bm);
- g_signal_connect(widget, "populate-popup",
- G_CALLBACK(bmwt_populate_popup_cb), mw->widget);
+
+ if ((popup_menu = libbalsa_html_popup_menu_widget(widget)) != NULL) {
+ g_object_set_data(G_OBJECT(popup_menu), "balsa-message", bm);
+ g_signal_connect(popup_menu, "populate-popup",
+ G_CALLBACK(bmwt_populate_popup_cb), widget);
} else {
- g_signal_connect(mw->widget, "button-press-event",
+ g_signal_connect(widget, "button-press-event",
G_CALLBACK(balsa_gtk_html_button_press_cb), bm);
- g_signal_connect(mw->widget, "popup-menu",
+ g_signal_connect(widget, "popup-menu",
G_CALLBACK(balsa_gtk_html_popup), bm);
}
@@ -1226,6 +1231,7 @@ bm_widget_new_vcard(BalsaMessage *bm, LibBalsaMessageBody *mime_body,
BalsaMimeWidget *mw = g_object_new(BALSA_TYPE_MIME_WIDGET, NULL);
LibBalsaAddress *address;
GtkGrid *grid;
+ GtkWidget *widget;
GtkWidget *w;
int row = 1;
@@ -1235,8 +1241,9 @@ bm_widget_new_vcard(BalsaMessage *bm, LibBalsaMessageBody *mime_body,
if (address == NULL)
return NULL;
- mw->widget = gtk_grid_new();
- grid = (GtkGrid*)mw->widget;
+ widget = gtk_grid_new();
+ balsa_mime_widget_set_widget(mw, widget);
+ grid = (GtkGrid *) widget;
gtk_grid_set_row_spacing(grid, 6);
gtk_grid_set_column_spacing(grid, 12);
@@ -1253,7 +1260,8 @@ bm_widget_new_vcard(BalsaMessage *bm, LibBalsaMessageBody *mime_body,
GRID_ATTACH(grid, libbalsa_address_get_organization(address), _("Organization:"));
GRID_ATTACH(grid, libbalsa_address_get_addr(address), _("Email Address:"));
- g_object_set_data(G_OBJECT(mw->widget), "mime-body", mime_body);
+ g_object_set_data(G_OBJECT(widget), "mime-body", mime_body);
+
return mw;
}
diff --git a/src/balsa-mime-widget-vcalendar.c b/src/balsa-mime-widget-vcalendar.c
index 3cb25175c..435346c79 100644
--- a/src/balsa-mime-widget-vcalendar.c
+++ b/src/balsa-mime-widget-vcalendar.c
@@ -44,6 +44,7 @@ balsa_mime_widget_new_vcalendar(BalsaMessage * bm,
{
LibBalsaVCal *vcal_obj;
BalsaMimeWidget *mw;
+ GtkWidget *widget;
GtkWidget *label;
gchar *text;
guint event_no;
@@ -60,7 +61,9 @@ balsa_mime_widget_new_vcalendar(BalsaMessage * bm,
return NULL;
mw = g_object_new(BALSA_TYPE_MIME_WIDGET, NULL);
- mw->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+
+ widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
+ balsa_mime_widget_set_widget(mw, widget);
text = g_strdup_printf(_("This is an iTIP calendar ā%sā message."),
libbalsa_vcal_method_str(vcal_obj));
@@ -68,7 +71,7 @@ balsa_mime_widget_new_vcalendar(BalsaMessage * bm,
g_free(text);
gtk_widget_set_halign(label, GTK_ALIGN_START);
gtk_widget_set_valign(label, GTK_ALIGN_START);
- gtk_container_add(GTK_CONTAINER(mw->widget), label);
+ gtk_container_add(GTK_CONTAINER(widget), label);
/* a reply may be created only for unread requests */
if ((libbalsa_vcal_method(vcal_obj) == ITIP_REQUEST) &&
@@ -98,7 +101,7 @@ balsa_mime_widget_new_vcalendar(BalsaMessage * bm,
GtkWidget *event;
event = balsa_vevent_widget(libbalsa_vcal_vevent(vcal_obj, event_no), may_reply, sender);
- gtk_container_add(GTK_CONTAINER(mw->widget), event);
+ gtk_container_add(GTK_CONTAINER(widget), event);
}
g_object_unref(vcal_obj);
diff --git a/src/balsa-mime-widget.c b/src/balsa-mime-widget.c
index 97eab1564..5fc245c40 100644
--- a/src/balsa-mime-widget.c
+++ b/src/balsa-mime-widget.c
@@ -36,11 +36,6 @@
#include "balsa-mime-widget.h"
-/* object related functions */
-static void balsa_mime_widget_init (GTypeInstance *instance, gpointer g_class);
-static void balsa_mime_widget_class_init(BalsaMimeWidgetClass * klass);
-
-
/* fall-back widget (unknown/unsupported mime type) */
static BalsaMimeWidget *balsa_mime_widget_new_unknown(BalsaMessage * bm,
LibBalsaMessageBody *
@@ -50,51 +45,34 @@ static BalsaMimeWidget *balsa_mime_widget_new_unknown(BalsaMessage * bm,
static void vadj_change_cb(GtkAdjustment *vadj, GtkWidget *widget);
+typedef struct {
+ /* display widget */
+ GtkWidget *widget;
-static GObjectClass *parent_class = NULL;
-
-
-GType
-balsa_mime_widget_get_type()
-{
- static GType balsa_mime_widget_type = 0;
-
- if (!balsa_mime_widget_type) {
- static const GTypeInfo balsa_mime_widget_info = {
- sizeof(BalsaMimeWidgetClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) balsa_mime_widget_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof(BalsaMimeWidget),
- 0, /* n_preallocs */
- (GInstanceInitFunc) balsa_mime_widget_init
- };
-
- balsa_mime_widget_type =
- g_type_register_static(G_TYPE_OBJECT, "BalsaMimeWidget",
- &balsa_mime_widget_info, 0);
- }
+ /* container widget if more sub-parts can be added */
+ GtkWidget *container;
- return balsa_mime_widget_type;
-}
+ /* headers */
+ GtkWidget *header_widget;
+} BalsaMimeWidgetPrivate;
+G_DEFINE_TYPE_WITH_PRIVATE(BalsaMimeWidget, balsa_mime_widget, G_TYPE_OBJECT)
static void
-balsa_mime_widget_init (GTypeInstance *instance, gpointer g_class)
+balsa_mime_widget_init(BalsaMimeWidget *self)
{
- BalsaMimeWidget *self = (BalsaMimeWidget *)instance;
+#ifdef G_OBJECT_NEEDS_TO_BE_INITIALIZED
+ BalsaMimeWidgetPrivate *priv = balsa_mime_widget_get_instance_private(self);
- self->widget = NULL;
- self->container = NULL;
+ priv->widget = NULL;
+ priv->container = NULL;
+ priv->header_widget = NULL;
+#endif /* G_OBJECT_NEEDS_TO_BE_INITIALIZED */
}
-
static void
balsa_mime_widget_class_init(BalsaMimeWidgetClass * klass)
{
- parent_class = g_type_class_ref(G_TYPE_OBJECT);
}
@@ -148,15 +126,17 @@ balsa_mime_widget_new(BalsaMessage * bm, LibBalsaMessageBody * mime_body, gpoint
if (delegate->handler)
mw = (delegate->handler) (bm, mime_body, content_type, data);
/* fall back to default if no handler is present */
- if (!mw)
+ if (mw == NULL)
mw = balsa_mime_widget_new_unknown(bm, mime_body, content_type);
- if (mw) {
- if (mw->widget) {
- g_signal_connect(mw->widget, "focus_in_event",
+ if (mw != NULL) {
+ BalsaMimeWidgetPrivate *priv = balsa_mime_widget_get_instance_private(mw);
+
+ if (priv->widget) {
+ g_signal_connect(priv->widget, "focus_in_event",
G_CALLBACK(balsa_mime_widget_limit_focus),
(gpointer) bm);
- g_signal_connect(mw->widget, "focus_out_event",
+ g_signal_connect(priv->widget, "focus_out_event",
G_CALLBACK(balsa_mime_widget_unlimit_focus),
(gpointer) bm);
if (mime_body->sig_info &&
@@ -165,27 +145,27 @@ balsa_mime_widget_new(BalsaMessage * bm, LibBalsaMessageBody * mime_body, gpoint
g_ascii_strcasecmp("application/x-pkcs7-signature", content_type)) {
GtkWidget * signature =
balsa_mime_widget_signature_widget(mime_body, content_type);
- mw->widget = balsa_mime_widget_crypto_frame(mime_body, mw->widget,
+ priv->widget = balsa_mime_widget_crypto_frame(mime_body, priv->widget,
mime_body->was_encrypted,
FALSE, signature);
} else if (mime_body->was_encrypted &&
g_ascii_strcasecmp("multipart/signed", content_type)) {
- mw->widget = balsa_mime_widget_crypto_frame(mime_body, mw->widget,
+ priv->widget = balsa_mime_widget_crypto_frame(mime_body, priv->widget,
TRUE, TRUE, NULL);
}
- g_object_ref_sink(mw->widget);
+ g_object_ref_sink(priv->widget);
- if (GTK_IS_LAYOUT(mw->widget)) {
+ if (GTK_IS_LAYOUT(priv->widget)) {
GtkAdjustment *vadj;
- g_object_get(mw->widget, "vadjustment", &vadj,
+ g_object_get(priv->widget, "vadjustment", &vadj,
NULL);
g_signal_connect(vadj, "changed",
- G_CALLBACK(vadj_change_cb), mw->widget);
+ G_CALLBACK(vadj_change_cb), priv->widget);
g_object_unref(vadj);
}
- gtk_widget_show_all(mw->widget);
+ gtk_widget_show_all(priv->widget);
}
}
g_free(content_type);
@@ -206,17 +186,20 @@ balsa_mime_widget_new_unknown(BalsaMessage * bm,
gchar *content_desc;
BalsaMimeWidget *mw;
gchar *use_content_type;
+ BalsaMimeWidgetPrivate *priv;
+
+ g_return_val_if_fail(mime_body != NULL, NULL);
- g_return_val_if_fail(mime_body, NULL);
mw = g_object_new(BALSA_TYPE_MIME_WIDGET, NULL);
+ priv = balsa_mime_widget_get_instance_private(mw);
- mw->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_VBOX_SPACE);
- gtk_container_set_border_width(GTK_CONTAINER(mw->widget),
+ priv->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, BMW_VBOX_SPACE);
+ gtk_container_set_border_width(GTK_CONTAINER(priv->widget),
BMW_CONTAINER_BORDER);
if (mime_body->filename) {
msg = g_strdup_printf(_("File name: %s"), mime_body->filename);
- gtk_box_pack_start(GTK_BOX(mw->widget), gtk_label_new(msg), FALSE,
+ gtk_box_pack_start(GTK_BOX(priv->widget), gtk_label_new(msg), FALSE,
FALSE, 0);
g_free(msg);
}
@@ -271,7 +254,7 @@ balsa_mime_widget_new_unknown(BalsaMessage * bm,
msg_label = gtk_label_new(msg);
g_free(msg);
gtk_label_set_ellipsize(GTK_LABEL(msg_label), PANGO_ELLIPSIZE_END);
- gtk_box_pack_start(GTK_BOX(mw->widget), msg_label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(priv->widget), msg_label, FALSE, FALSE, 0);
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, BMW_HBOX_SPACE);
gtk_box_set_homogeneous(GTK_BOX(hbox), TRUE);
@@ -280,7 +263,7 @@ balsa_mime_widget_new_unknown(BalsaMessage * bm,
(gpointer) mime_body)))
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
else
- gtk_box_pack_start(GTK_BOX(mw->widget),
+ gtk_box_pack_start(GTK_BOX(priv->widget),
gtk_label_new(_("No open or view action "
"defined for this content type")),
FALSE, FALSE, 0);
@@ -292,7 +275,7 @@ balsa_mime_widget_new_unknown(BalsaMessage * bm,
G_CALLBACK(balsa_mime_widget_ctx_menu_save),
(gpointer) mime_body);
- gtk_box_pack_start(GTK_BOX(mw->widget), hbox, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(priv->widget), hbox, FALSE, FALSE, 0);
return mw;
}
@@ -343,3 +326,78 @@ vadj_change_cb(GtkAdjustment *vadj, GtkWidget *widget)
g_source_remove(resize_idle_id);
balsa_mime_widget_schedule_resize(widget);
}
+
+/*
+ * Getters
+ */
+
+GtkWidget *
+balsa_mime_widget_get_widget(BalsaMimeWidget * mw)
+{
+ BalsaMimeWidgetPrivate *priv =
+ balsa_mime_widget_get_instance_private(mw);
+
+ g_return_val_if_fail(BALSA_IS_MIME_WIDGET(mw), NULL);
+
+ return priv->widget;
+}
+
+GtkWidget *
+balsa_mime_widget_get_container(BalsaMimeWidget * mw)
+{
+ BalsaMimeWidgetPrivate *priv =
+ balsa_mime_widget_get_instance_private(mw);
+
+ g_return_val_if_fail(BALSA_IS_MIME_WIDGET(mw), NULL);
+
+ return priv->container;
+}
+
+GtkWidget *
+balsa_mime_widget_get_header_widget(BalsaMimeWidget * mw)
+{
+ BalsaMimeWidgetPrivate *priv =
+ balsa_mime_widget_get_instance_private(mw);
+
+ g_return_val_if_fail(BALSA_IS_MIME_WIDGET(mw), NULL);
+
+ return priv->header_widget;
+}
+
+/*
+ * Setters
+ */
+
+void
+balsa_mime_widget_set_widget(BalsaMimeWidget * mw, GtkWidget * widget)
+{
+ BalsaMimeWidgetPrivate *priv =
+ balsa_mime_widget_get_instance_private(mw);
+
+ g_return_if_fail(BALSA_IS_MIME_WIDGET(mw));
+
+ priv->widget = widget;
+}
+
+void
+balsa_mime_widget_set_container(BalsaMimeWidget * mw, GtkWidget * widget)
+{
+ BalsaMimeWidgetPrivate *priv =
+ balsa_mime_widget_get_instance_private(mw);
+
+ g_return_if_fail(BALSA_IS_MIME_WIDGET(mw));
+
+ priv->container = widget;
+}
+
+void
+balsa_mime_widget_set_header_widget(BalsaMimeWidget * mw,
+ GtkWidget * widget)
+{
+ BalsaMimeWidgetPrivate *priv =
+ balsa_mime_widget_get_instance_private(mw);
+
+ g_return_if_fail(BALSA_IS_MIME_WIDGET(mw));
+
+ priv->header_widget = widget;
+}
diff --git a/src/balsa-mime-widget.h b/src/balsa-mime-widget.h
index e08b151c8..afc951159 100644
--- a/src/balsa-mime-widget.h
+++ b/src/balsa-mime-widget.h
@@ -35,41 +35,42 @@ G_BEGIN_DECLS
#define BMW_HEADER_MARGIN_LEFT 2
#define BMW_HEADER_MARGIN_RIGHT 15
-
-#define BALSA_TYPE_MIME_WIDGET (balsa_mime_widget_get_type ())
-#define BALSA_MIME_WIDGET(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, BALSA_TYPE_MIME_WIDGET,
BalsaMimeWidget)
-#define BALSA_MIME_WIDGET_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, BALSA_TYPE_MIME_WIDGET,
BalsaMimeWidgetClass)
-#define BALSA_IS_MIME_WIDGET(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, BALSA_TYPE_MIME_WIDGET)
-
-
-typedef struct _BalsaMimeWidgetClass BalsaMimeWidgetClass;
-
-
-struct _BalsaMimeWidget {
- GObject parent;
-
- /* display widget */
- GtkWidget *widget;
-
- /* container widget if more sub-parts can be added */
- GtkWidget *container;
-
- /* headers */
- GtkWidget *header_widget;
-};
-
+/*
+ * GObject class definitions
+ */
struct _BalsaMimeWidgetClass {
GObjectClass parent;
};
+#define BALSA_TYPE_MIME_WIDGET balsa_mime_widget_get_type()
+
+G_DECLARE_DERIVABLE_TYPE(BalsaMimeWidget, balsa_mime_widget, BALSA, MIME_WIDGET, GObject)
+
+/*
+ * Method definitions.
+ */
-GType balsa_mime_widget_get_type (void);
BalsaMimeWidget *balsa_mime_widget_new(BalsaMessage * bm,
LibBalsaMessageBody * mime_body,
gpointer data);
void balsa_mime_widget_schedule_resize(GtkWidget * widget);
+/*
+ * Getters
+ */
+
+GtkWidget *balsa_mime_widget_get_widget (BalsaMimeWidget * mw);
+GtkWidget *balsa_mime_widget_get_container (BalsaMimeWidget * mw);
+GtkWidget *balsa_mime_widget_get_header_widget(BalsaMimeWidget * mw);
+
+/*
+ * Setters
+ */
+
+void balsa_mime_widget_set_widget (BalsaMimeWidget * mw, GtkWidget * widget);
+void balsa_mime_widget_set_container (BalsaMimeWidget * mw, GtkWidget * widget);
+void balsa_mime_widget_set_header_widget(BalsaMimeWidget * mw, GtkWidget * widget);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]