TnyMsgView

TnyMsgView — A type that defines a view for a message

Synopsis




                    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);

Object Hierarchy


  GInterface
   +----TnyMsgView

Prerequisites

TnyMsgView requires TnyMimePartView.

Known Derived Interfaces

TnyMsgView is required by TnyMsgWindow.

Known Implementations

TnyMsgView is implemented by TnyMozEmbedMsgView, TnyGtkMsgView and TnyGtkMsgWindow.

Description

A type that defines a view for a TnyMsg implementation. The type is sometimes decorated by a TnyMsgWindow implementation.

Details

TnyMsgView

typedef struct _TnyMsgView TnyMsgView;

A type that can view a TnyMsg and usually inherits from TnyMimePartView

free-function: g_object_unref


TnyMsgViewIface

typedef struct {
	GTypeInterface parent;

	TnyMsg* (*get_msg) (TnyMsgView *self);
	void (*set_msg) (TnyMsgView *self, TnyMsg *msg);
	void (*set_unavailable) (TnyMsgView *self);
	void (*clear) (TnyMsgView *self);
	TnyMimePartView* (*create_mime_part_view_for) (TnyMsgView *self, TnyMimePart *part);
	TnyMsgView* (*create_new_inline_viewer) (TnyMsgView *self);
} TnyMsgViewIface;


tny_msg_view_get_msg ()

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.

When inheriting from a TnyMimePartView, this method is most likely going to be an alias for tny_mime_part_view_get_part(), with the returned TnyMimePart casted to a TnyMsg (in this case, the method in the TnyMimePartView should return a TnyMsg, indeed).

self : a TnyMsgView
Returns : (null-ok) (caller-owns): A TnyMsg instance or NULL

Since 1.0 audience: application-developer, type-implementer


tny_msg_view_set_msg ()

void                tny_msg_view_set_msg                (TnyMsgView *self,
                                                         TnyMsg *msg);

Set the message which view self must display.

Note that 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 a TnyMimePartView that can view the mime part.

When inheriting from a TnyMimePartView this method is most likely going to decorate or alias tny_mime_part_view_set_part(), with the passed TnyMsg casted to a TnyMimePart.

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 (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 (part);
        tny_iterator_next (iterator);
    }
    g_object_unref (iterator);
    g_object_unref (list);
}

ps. For a real and complete working example take a look at the implementation of TnyGtkMsgView in libtinymailui-gtk.

self : a TnyMsgView
msg : a TnyMsg

Since 1.0 audience: application-developer, type-implementer


tny_msg_view_clear ()

void                tny_msg_view_clear                  (TnyMsgView *self);

Clear self, show nothing

self : A TnyMsgView

Since 1.0 audience: application-developer, type-implementer


tny_msg_view_set_unavailable ()

void                tny_msg_view_set_unavailable        (TnyMsgView *self);

Set self to display that a message was unavailable. You can for example implement this method by simply calling tny_msg_view_clear().

self : a TnyMsgView

Since 1.0 audience: application-developer, type-implementer


tny_msg_view_create_mime_part_view_for ()

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. It's recommended to return the result of calling the function on the super of self (like in the example below) in case your type's implementation can't display part.

Example:

static TnyMimePartView*
tny_my_html_msg_view_create_mime_part_view_for (TnyMsgView *self, TnyMimePart *part)
{
   TnyMimePartView *retval = NULL;
   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(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
part : a TnyMimePart
Returns : (caller-owns): a TnyMimePartView instance

Since 1.0 audience: application-developer, type-implementer


tny_msg_view_create_new_inline_viewer ()

TnyMsgView*         tny_msg_view_create_new_inline_viewer
                                                        (TnyMsgView *self);

Create a new TnyMsgView that can be used to display an inline message, like a message/rfc822 MIME part. Usually it will return a new instance of the same type as self. The returned instance must be unreferenced after use.

Example:

static TnyMsgView*
tny_my_html_msg_view_create_new_inline_viewer (TnyMsgView *self)
{
   return tny_my_html_msg_view_new ();
}

self : a TnyMsgView
Returns : (caller-owns): a TnyMsgView instance

Since 1.0 audience: application-developer, type-implementer

See Also

TnyMsg, TnyMsgMimePart, TnyMsgWindow, TnyGtkMsgView, TnyGtkMsgWindow