Changeset 32
- Timestamp:
- 02/09/06 14:46:44
- Files:
-
- trunk/libtinymailui/Makefile.am (modified) (2 diffs)
- trunk/libtinymailui/tny-msg-window-iface.c (added)
- trunk/libtinymailui/tny-msg-window-iface.h (added)
- trunk/tinymail/tny-msg-window.c (modified) (5 diffs)
- trunk/tinymail/tny-msg-window.h (modified) (2 diffs)
- trunk/tinymail/tny-summary-window.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libtinymailui/Makefile.am
r29 r32 8 8 tny-msg-header-list-model.h \ 9 9 tny-account-tree-model.h \ 10 tny-summary-window-iface.h 10 tny-summary-window-iface.h \ 11 tny-msg-window-iface.h 11 12 12 13 libtinymailui_1_0_la_SOURCES = \ … … 14 15 tny-msg-header-list-model.c \ 15 16 tny-account-tree-model.c \ 16 tny-summary-window-iface.c 17 tny-summary-window-iface.c \ 18 tny-msg-window-iface.c 17 19 18 20 libtinymailui_1_0_la_LIBADD = \ trunk/tinymail/tny-msg-window.c
r26 r32 18 18 */ 19 19 20 #include <string.h> 20 21 #include <gtk/gtk.h> 21 22 #include <tny-msg-window.h> 22 23 23 24 static GObjectClass *parent_class = NULL; 25 26 typedef struct _TnyMsgWindowPriv TnyMsgWindowPriv; 27 28 struct _TnyMsgWindowPriv 29 { 30 TnyMsgIface *msg; 31 GtkTextView *textview; 32 }; 33 34 #define TNY_MSG_WINDOW_GET_PRIVATE(o) \ 35 (G_TYPE_INSTANCE_GET_PRIVATE ((o), TNY_MSG_WINDOW_TYPE, TnyMsgWindowPriv)) 36 37 38 static void 39 reload_msg (TnyMsgWindowIface *self) 40 { 41 TnyMsgWindowPriv *priv = TNY_MSG_WINDOW_GET_PRIVATE (self); 42 GtkTextBuffer *buffer = gtk_text_view_get_buffer (priv->textview); 43 44 TnyMsgHeaderIface *header; 45 GList *attachments; 46 TnyMsgBodyIface *body; 47 const gchar *text; 48 49 header = TNY_MSG_HEADER_IFACE (tny_msg_iface_get_header (priv->msg)); 50 body = TNY_MSG_BODY_IFACE (tny_msg_iface_get_body (priv->msg)); 51 attachments = (GList*)tny_msg_iface_get_attachments (priv->msg); 52 text = tny_msg_body_iface_get_data (body); 53 54 gtk_window_set_title (GTK_WINDOW (self), tny_msg_header_iface_get_subject (header)); 55 gtk_text_buffer_set_text (buffer, text, strlen(text)); 56 57 return; 58 } 59 60 static void 61 tny_msg_window_set_msg (TnyMsgWindowIface *self, TnyMsgIface *msg) 62 { 63 TnyMsgWindowPriv *priv = TNY_MSG_WINDOW_GET_PRIVATE (self); 64 65 if (priv->msg) 66 g_object_unref (G_OBJECT (priv->msg)); 67 68 g_object_ref (G_OBJECT (msg)); 69 70 priv->msg = msg; 71 72 reload_msg (self); 73 74 return; 75 } 24 76 25 77 … … 36 88 { 37 89 TnyMsgWindow *self = (TnyMsgWindow *)instance; 38 GtkWindow *window = GTK_WINDOW (self); 90 TnyMsgWindowPriv *priv = TNY_MSG_WINDOW_GET_PRIVATE (self); 91 92 priv->textview = GTK_TEXT_VIEW (gtk_text_view_new ()); 93 gtk_container_set_border_width (GTK_CONTAINER (self), 8); 94 gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (priv->textview)); 39 95 40 gtk_window_set_title (window, "Message"); 41 gtk_container_set_border_width (GTK_CONTAINER (window), 8); 96 gtk_widget_show (GTK_WIDGET (priv->textview)); 42 97 43 98 return; … … 54 109 } 55 110 111 static void 112 tny_msg_window_iface_init (gpointer g_iface, gpointer iface_data) 113 { 114 TnyMsgWindowIfaceClass *klass = (TnyMsgWindowIfaceClass *)g_iface; 115 116 klass->set_msg_func = tny_msg_window_set_msg; 117 118 return; 119 } 56 120 57 121 static void … … 64 128 65 129 object_class->finalize = tny_msg_window_finalize; 130 131 g_type_class_add_private (object_class, sizeof (TnyMsgWindowPriv)); 66 132 67 133 return; … … 88 154 }; 89 155 156 static const GInterfaceInfo tny_msg_window_iface_info = 157 { 158 (GInterfaceInitFunc) tny_msg_window_iface_init, /* interface_init */ 159 NULL, /* interface_finalize */ 160 NULL /* interface_data */ 161 }; 162 90 163 type = g_type_register_static (GTK_TYPE_WINDOW, 91 164 "TnyMsgWindow", 92 165 &info, 0); 166 167 g_type_add_interface_static (type, TNY_MSG_WINDOW_IFACE_TYPE, 168 &tny_msg_window_iface_info); 93 169 94 170 } trunk/tinymail/tny-msg-window.h
r26 r32 23 23 #include <glib-object.h> 24 24 #include <tny-shared.h> 25 26 #include <tny-msg-window-iface.h> 27 #include <tny-msg-header-iface.h> 28 #include <tny-msg-iface.h> 29 #include <tny-msg-body-iface.h> 30 #include <tny-msg-attachment-iface.h> 25 31 26 32 G_BEGIN_DECLS … … 50 56 TnyMsgWindow* tny_msg_window_new (void); 51 57 52 53 58 G_END_DECLS 54 59 trunk/tinymail/tny-summary-window.c
r31 r32 27 27 #include <tny-account.h> 28 28 29 #include <tny-msg-window-iface.h> 30 #include <tny-msg-window.h> 31 29 32 #include <tny-msg-folder-iface.h> 30 33 #include <tny-account-tree-model.h> … … 127 130 } 128 131 129 static GtkWidget*130 create_msg_window (TnyMsgIface *msg)131 {132 TnyMsgHeaderIface *header;133 GList *attachments;134 TnyMsgBodyIface *body;135 136 GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);137 GtkTextView *textview = GTK_TEXT_VIEW (gtk_text_view_new ());138 GtkTextBuffer *buffer = gtk_text_view_get_buffer (textview);139 const gchar *text;140 141 header = TNY_MSG_HEADER_IFACE (tny_msg_iface_get_header (msg));142 body = TNY_MSG_BODY_IFACE (tny_msg_iface_get_body (msg));143 attachments = (GList*)tny_msg_iface_get_attachments (msg);144 text = tny_msg_body_iface_get_data (body);145 146 147 gtk_window_set_title (GTK_WINDOW (window), tny_msg_header_iface_get_subject (header));148 gtk_text_buffer_set_text (buffer, text, strlen(text));149 150 gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (textview));151 152 return window;153 }154 155 156 132 static void 157 133 on_header_view_tree_row_activated (GtkTreeView *treeview, GtkTreePath *path, … … 166 142 { 167 143 TnyMsgHeaderIface *header; 168 169 170 GtkWindow *msgwin; 144 TnyMsgWindowIface *msgwin; 171 145 172 146 gtk_tree_model_get (model, &iter, … … 190 164 tny_msg_header_iface_get_subject (TNY_MSG_HEADER_IFACE (nheader))); 191 165 192 msgwin = GTK_WINDOW (create_msg_window (TNY_MSG_IFACE (msg))); 193 194 gtk_widget_show_all (GTK_WIDGET (msgwin)); 166 msgwin = TNY_MSG_WINDOW_IFACE (tny_msg_window_new ()); 167 tny_msg_window_iface_set_msg (msgwin, TNY_MSG_IFACE (msg)); 168 169 gtk_widget_show (GTK_WIDGET (msgwin)); 195 170 } 196 171 }
