![]() |
![]() |
![]() |
Reference Manual of the tinymail framework | ![]() |
---|---|---|---|---|
TnyMimePartView; TnyMimePartViewIface; void tny_mime_part_view_clear (TnyMimePartView *self); void tny_mime_part_view_set_part (TnyMimePartView *self, TnyMimePart *mime_part); TnyMimePart* tny_mime_part_view_get_part (TnyMimePartView *self);
TnyMimePartView is implemented by TnyGtkExpanderMimePartView, TnyMozEmbedMsgView, TnyGtkTextMimePartView, TnyGtkMsgView, TnyGtkMsgWindow, TnyGtkImageMimePartView and TnyGtkAttachmentMimePartView.
typedef struct _TnyMimePartView TnyMimePartView;
A type that can view a TnyMimePart
free-function: g_object_unref
typedef struct { GTypeInterface parent; TnyMimePart* (*get_part) (TnyMimePartView *self); void (*set_part) (TnyMimePartView *self, TnyMimePart *part); void (*clear) (TnyMimePartView *self); } TnyMimePartViewIface;
void tny_mime_part_view_clear (TnyMimePartView *self);
Clear self
, show nothing
self : |
a TnyMimePartView |
Since 1.0 audience: application-developer, type-implementer
void tny_mime_part_view_set_part (TnyMimePartView *self, TnyMimePart *mime_part);
Set the MIME part which self
should display. Note that if possible, try to
wait for as long as possible to call this API. As soon as this API is used,
and the part's data is not available locally, will the part's data be
requested from the service.
If you can delay the need for calling this API, for example by offering the user a feature to make it visible rather than making the part always visible, then this is a smart thing to do to save bandwidth consumption in your final application.
For example GtkExpander and setting it when the child widget gets realized in case you are using libtinymailui-gtk. A convenient TnyGtkExpanderMimePartView is available in libtinymailui-gtk that does exactly this. It will call for the API when you expand the expander (the user presses the expand-arrow).
Note that it's recommended to use tny_mime_part_decode_to_stream_async()
over
tny_mime_part_decode_to_stream()
if you want your user interface to remain
responsive in case Tinymail's engine needs to pull data from a service.
Example:
static void on_mime_part_decoded (TnyMimePart *part, TnyStream *dest, gboolean cancelled, GError *err, gpointer user_data) { TnyMimePartView *self = (TnyMimePartView *) user_data; if (!cancelled && !err) make_part_really_visible_now (self, part); g_object_unref (self); } static void on_status (GObject *part, TnyStatus *status, gpointer user_data) { TnyMimePartView *self = (TnyMimePartView *) user_data; move_progress_bar (self, tny_status_get_fraction (status)); } static void tny_gtk_text_mime_part_view_set_part (TnyMimePartView *self, TnyMimePart *part) { if (part) { GtkTextBuffer *buffer; TnyStream *dest; buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self)); if (buffer && GTK_IS_TEXT_BUFFER (buffer)) gtk_text_buffer_set_text (buffer, "", 0); dest = tny_gtk_text_buffer_stream_new (buffer); tny_stream_reset (dest); tny_mime_part_decode_to_stream_async (part, dest, on_mime_part_decoded, on_status, g_object_ref (self)); tny_stream_reset (dest); g_object_unref (dest); priv->part = TNY_MIME_PART (g_object_ref (part)); } } static void tny_gtk_text_mime_part_view_finalize (TnyGtkTextMimePartView *self) { if (priv->part)) g_object_unref (priv->part); }
self : |
a TnyMimePartView |
mime_part : |
a TnyMimePart |
Since 1.0 audience: application-developer, type-implementer
TnyMimePart* tny_mime_part_view_get_part (TnyMimePartView *self);
Get the current mime part of self
. If self
is not displaying any mime part,
NULL will be returned. Else the return value must be unreferenced after use.
Example:
static TnyMimePart* tny_gtk_text_mime_part_view_get_part (TnyMimePartView *self) { TnyGtkTextMimePartViewPriv *priv = TNY_GTK_TEXT_MIME_PART_VIEW_GET_PRIV (self); return priv->part?TNY_MIME_PART (g_object_ref (priv->part)):NULL; }
self : |
a TnyMimePartView |
Returns : | (null-ok) (caller-owns): a TnyMimePart instance or NULL |
Since 1.0 audience: application-developer, type-implementer