| Reference Manual of the tinymail framework | ||||
|---|---|---|---|---|
TnyMsgView;
TnyMsgViewIface;
TnyMsg* tny_msg_view_get_msg (TnyMsgView *self);
void tny_msg_view_set_msg (TnyMsgView *self,
TnyMsg *msg);
void tny_msg_view_clear (TnyMsgView *self);
void tny_msg_view_set_unavailable (TnyMsgView *self);
TnyMimePartView* tny_msg_view_create_mime_part_view_for
(TnyMsgView *self,
TnyMimePart *part);
TnyMsgView* tny_msg_view_create_new_inline_viewer
(TnyMsgView *self);
TnyMsgView is implemented by TnyMozEmbedMsgView, TnyGtkMsgView and TnyGtkMsgWindow.
A type that defines a view for a TnyMsg implementation. The type is sometimes decorated by a TnyMsgWindow implementation.
typedef struct {
GTypeInterface parent;
TnyMsg* (*get_msg_func) (TnyMsgView *self);
void (*set_msg_func) (TnyMsgView *self, TnyMsg *msg);
void (*set_unavailable_func) (TnyMsgView *self);
void (*clear_func) (TnyMsgView *self);
TnyMimePartView* (*create_mime_part_view_for_func) (TnyMsgView *self, TnyMimePart *part);
TnyMsgView* (*create_new_inline_viewer_func) (TnyMsgView *self);
} TnyMsgViewIface;
TnyMsg* tny_msg_view_get_msg (TnyMsgView *self);
Get the current message of self. If self is not displaying any message,
NULL will be returned. Else the return value must be unreferenced after use.
Implementors: this method should return the mime part this view is currently viewing. It must add a reference to the instance before returning it. If the view isn't viewing any mime part, it must return NULL.
Usually this method is an alias for tny_mime_part_view_get_part of TnyMimePartView
self : |
A TnyMsgView instance |
| Returns : | A TnyMsg instance or NULL |
void tny_msg_view_set_msg (TnyMsgView *self, TnyMsg *msg);
Set the message which view self must display.
Implementors: this method should cause self to show msg to the user.
This includes showing the header (for which you can make a composition with
a TnyHeaderView), the message body and the attachments (for which you
typically use the TnyMimePartView interface and implementations).
You can get a list of mime parts using the tny_mime_part_get_parts API of the TnyMimePart type. You can use the tny_msg_view_create_mime_part_view_for API to get an instance of a TnyMimePartView that can view the mime part.
Usually this method is an alias or decorator for tny_mime_part_view_set_part of TnyMimePartView
Example:
static void
tny_my_msg_view_set_msg (TnyMsgView *self, TnyMsg *msg)
{
TnyIterator *iterator;
TnyList *list = tny_simple_list_new ();
tny_msg_view_clear (self);
header = tny_msg_get_header (msg);
tny_header_view_set_header (priv->headerview, header);
g_object_unref (G_OBJECT (header));
tny_mime_part_view_set_part (TNY_MIME_PART_VIEW (self),
TNY_MIME_PART (msg));
tny_mime_part_get_parts (TNY_MIME_PART (msg), list);
iterator = tny_list_create_iterator (list);
while (!tny_iterator_is_done (iterator))
{
TnyMimePart *part = tny_iterator_get_current (iterator);
TnyMimePartView *mpview;
mpview = tny_msg_view_create_mime_part_view_for (self, part);
if (mpview)
tny_mime_part_view_set_part (mpview, part);
g_object_unref (G_OBJECT(part));
tny_iterator_next (iterator);
}
g_object_unref (G_OBJECT (iterator));
g_object_unref (G_OBJECT (list));
}
ps. For a real and complete working example take a look at the implementation of TnyGtkMsgView in libtinymailui-gtk.
self : |
A TnyMsgView instance |
msg : |
A TnyMsg instace |
void tny_msg_view_clear (TnyMsgView *self);
Clear self (show nothing)
Implementors: this method should clear self (display nothing and clearup)
self : |
A TnyMsgView instance |
void tny_msg_view_set_unavailable (TnyMsgView *self);
Set self to display that a message was unavailable
Implementors: this method should set self to display a message like
"Message unavailable" or trigger another indication that a specific message
isn't available.
self : |
A TnyMsgView instance |
TnyMimePartView* tny_msg_view_create_mime_part_view_for (TnyMsgView *self, TnyMimePart *part);
Create a TnyMimePartView instance for viewing part. The returned instance
must be unreferenced after use.
Implementors: This method should create and return a new TnyMimePartView
that is suitable for displaying part.
Example:
static TnyMimePartView*
tny_my_html_msg_view_create_mime_part_view_for (TnyMsgView *self, TnyMimePart *part)
{
TnyMimePartView *retval = NULL;
g_assert (TNY_IS_MIME_PART (part));
if (tny_mime_part_content_type_is (part, "text/html"))
{
GtkWidget *widget = (GtkWidget *) self;
retval = tny_my_html_mime_part_view_new ();
} else
retval = TNY_GTK_MSG_VIEW_CLASS (parent_class)->create_mime_part_view_for_func (self, part);
return retval;
}
ps. For a real and complete working example take a look at the implementation of TnyMozEmbedMsgView in libtinymailui-mozembed.
self : |
A TnyMsgView instance |
part : |
A TnyMimePart instance |
| Returns : | A TnyMimePartView instance for viewing part
|
TnyMsgView* tny_msg_view_create_new_inline_viewer (TnyMsgView *self);
Create a new TnyMsgView that can be used to display an inline message.
Usually it will return a new instance of the same type as self. The
returned instance must be unreferenced after use.
Implementors: This method should create and return a new TnyMsgView instance
usually of the same type as self. This method will be used when a
TnyMsgView needs to create a TnyMsgView instance for displaying inlined
messages (like what message/rfc822 mime parts are). For example the
TnyGtkMsgView implementation will use this method to create for itself a
new TnyMsgView instance that it can embed in itself.
Example:
static TnyMsgView*
tny_my_html_msg_view_create_new_inline_viewer (TnyMsgView *self)
{
return tny_my_html_msg_view_new ();
}
Note that if you want to pass contructor parameters, that you will have to store them yourself (for example in a static global field in the .c file) and repeat them in the new instance that will be created by this method.
self : |
A TnyMsgView instance |
| Returns : | A TnyMsgView instance |