Changeset 994
- Timestamp:
- 10/15/06 13:32:14
- Files:
-
- trunk/ChangeLog (modified) (2 diffs)
- trunk/libtinymail-gnome-desktop/tny-gnome-platform-factory.c (modified) (2 diffs)
- trunk/libtinymail-gpe/tny-gpe-platform-factory.c (modified) (2 diffs)
- trunk/libtinymail-maemo/tny-maemo-platform-factory.c (modified) (2 diffs)
- trunk/libtinymail-olpc/tny-olpc-platform-factory.c (modified) (2 diffs)
- trunk/libtinymail/Makefile.am (modified) (1 diff)
- trunk/libtinymailui-gtk/tny-gtk-attachment-mime-part-view.c (modified) (6 diffs)
- trunk/libtinymailui-gtk/tny-gtk-attachment-mime-part-view.h (modified) (1 diff)
- trunk/libtinymailui-gtk/tny-gtk-msg-view.c (modified) (16 diffs)
- trunk/libtinymailui-gtk/tny-gtk-msg-view.h (modified) (3 diffs)
- trunk/libtinymailui-gtk/tny-gtk-msg-window.c (modified) (2 diffs)
- trunk/libtinymailui-gtk/tny-gtk-text-mime-part-view.c (modified) (6 diffs)
- trunk/libtinymailui-gtk/tny-gtk-text-mime-part-view.h (modified) (1 diff)
- trunk/libtinymailui-mozembed/tny-moz-embed-html-mime-part-view.c (modified) (6 diffs)
- trunk/libtinymailui-mozembed/tny-moz-embed-html-mime-part-view.h (modified) (1 diff)
- trunk/libtinymailui-mozembed/tny-moz-embed-msg-view.c (modified) (4 diffs)
- trunk/libtinymailui-mozembed/tny-moz-embed-msg-view.h (modified) (1 diff)
- trunk/libtinymailui/Makefile.am (modified) (2 diffs)
- trunk/libtinymailui/tny-mime-part-saver.c (added)
- trunk/libtinymailui/tny-mime-part-saver.h (added)
- trunk/libtinymailui/tny-mime-part-view.c (modified) (3 diffs)
- trunk/libtinymailui/tny-mime-part-view.h (modified) (2 diffs)
- trunk/libtinymailui/tny-msg-view.c (modified) (2 diffs)
- trunk/libtinymailui/tny-msg-view.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r991 r994 1 2006-10-13 Philip Van Hoof <pvanhoof@gnome.org> 1 2006-10-15 Philip Van Hoof <pvanhoof@gnome.org> 2 3 * Major refactoring in the TnySaveStrategy stuff 4 * Introduced a new client-type for the strategy pattern: 5 the TnyMimePartSaver 6 * Removed all saving functionality from the default gtk+ 7 types: the developer who will create an E-mail client is 8 the person who should connect the dots (inherit a TnyMsgView 9 and/or a TnyMimePartView, or implement it fully, and let that 10 type also implement the TnyMimePartSaver) 11 12 * This was a major API change in libtinymailui 13 14 2006-10-13 Philip Van Hoof <pvanhoof@gnome.org> 2 15 3 16 * Added the TnyGtkAttachmentMimePartView type 4 17 18 * This was a major API change in libtinymailui-gtk 19 5 20 2006-10-12 Philip Van Hoof <pvanhoof@gnome.org> 6 21 … … 9 24 * The TnyMimePartView API implemented for GtkMozEmbed 10 25 26 * This was a major API change in libtinymailui 27 11 28 2006-09-26 Philip Van Hoof <pvanhoof@gnome.org> 12 29 trunk/libtinymail-gnome-desktop/tny-gnome-platform-factory.c
r900 r994 20 20 21 21 #include <tny-gnome-platform-factory.h> 22 23 #include <tny-save-strategy.h>24 #include <tny-gtk-save-strategy.h>25 22 26 23 #include <tny-account-store.h> … … 62 59 tny_gnome_platform_factory_new_msg_view (TnyPlatformFactory *self) 63 60 { 64 TnySaveStrategy *save_strategy = tny_gtk_save_strategy_new ();65 61 TnyMsgView *retval; 66 62 67 63 #ifdef MOZEMBED 68 retval = tny_moz_embed_msg_view_new ( save_strategy);64 retval = tny_moz_embed_msg_view_new (); 69 65 #else 70 retval = tny_gtk_msg_view_new ( save_strategy);66 retval = tny_gtk_msg_view_new (); 71 67 #endif 72 73 g_object_unref (G_OBJECT (save_strategy));74 68 75 69 return retval; trunk/libtinymail-gpe/tny-gpe-platform-factory.c
r971 r994 20 20 21 21 #include <tny-gpe-platform-factory.h> 22 23 #include <tny-save-strategy.h>24 #include <tny-gtk-save-strategy.h>25 22 26 23 #include <tny-account-store.h> … … 57 54 tny_gpe_platform_factory_new_msg_view (TnyPlatformFactory *self) 58 55 { 59 TnySaveStrategy *save_strategy = tny_gtk_save_strategy_new (); 60 TnyMsgView *retval = tny_gtk_msg_view_new (save_strategy); 61 62 g_object_unref (G_OBJECT (save_strategy)); 63 64 return retval; 56 return tny_gtk_msg_view_new (); 65 57 } 66 58 trunk/libtinymail-maemo/tny-maemo-platform-factory.c
r971 r994 20 20 21 21 #include <tny-maemo-platform-factory.h> 22 23 #include <tny-save-strategy.h>24 #include <tny-gtk-save-strategy.h>25 22 26 23 #include <tny-account-store.h> … … 57 54 tny_maemo_platform_factory_new_msg_view (TnyPlatformFactory *self) 58 55 { 59 TnySaveStrategy *save_strategy = tny_gtk_save_strategy_new (); 60 TnyMsgView *retval = tny_gtk_msg_view_new (save_strategy); 61 62 g_object_unref (G_OBJECT (save_strategy)); 63 64 return retval; 56 return tny_gtk_msg_view_new (); 65 57 } 66 58 trunk/libtinymail-olpc/tny-olpc-platform-factory.c
r971 r994 20 20 21 21 #include <tny-olpc-platform-factory.h> 22 23 #include <tny-save-strategy.h>24 #include <tny-gtk-save-strategy.h>25 22 26 23 #include <tny-account-store.h> … … 57 54 tny_olpc_platform_factory_new_msg_view (TnyPlatformFactory *self) 58 55 { 59 TnySaveStrategy *save_strategy = tny_gtk_save_strategy_new (); 60 TnyMsgView *retval = tny_gtk_msg_view_new (save_strategy); 61 62 g_object_unref (G_OBJECT (save_strategy)); 63 64 return retval; 56 return tny_gtk_msg_view_new (); 65 57 } 66 58 trunk/libtinymail/Makefile.am
r900 r994 3 3 lib_LTLIBRARIES = libtinymail-1.0.la 4 4 5 libtinymail_1_0_headers = \6 tny-shared.h \7 tny-list.h \8 tny-iterator.h \9 tny-folder.h \10 tny-mime-part.h \11 tny-header.h \12 tny-msg.h \13 tny-device.h \14 tny-account.h \15 tny-store-account.h \16 tny-transport-account.h \17 tny-account-store.h \18 tny-stream.h \19 tny-fs-stream.h \20 tny-simple-list.h \21 tny-folder-store.h \5 libtinymail_1_0_headers = \ 6 tny-shared.h \ 7 tny-list.h \ 8 tny-iterator.h \ 9 tny-folder.h \ 10 tny-mime-part.h \ 11 tny-header.h \ 12 tny-msg.h \ 13 tny-device.h \ 14 tny-account.h \ 15 tny-store-account.h \ 16 tny-transport-account.h \ 17 tny-account-store.h \ 18 tny-stream.h \ 19 tny-fs-stream.h \ 20 tny-simple-list.h \ 21 tny-folder-store.h \ 22 22 tny-folder-store-query.h 23 23 24 libtinymail_1_0_la_SOURCES = \25 $(libtinymail_1_0_headers) \26 tny-list.c \27 tny-iterator.c \28 tny-msg.c \29 tny-header.c \30 tny-mime-part.c \31 tny-folder.c \32 tny-device.c \33 tny-account.c \34 tny-store-account.c \35 tny-transport-account.c \36 tny-account-store.c \37 tny-stream.c \38 tny-fs-stream.c \39 tny-simple-list-priv.h \40 tny-simple-list.c \41 tny-simple-list-iterator-priv.h \42 tny-simple-list-iterator.c \43 tny-folder-store.c \24 libtinymail_1_0_la_SOURCES = \ 25 $(libtinymail_1_0_headers) \ 26 tny-list.c \ 27 tny-iterator.c \ 28 tny-msg.c \ 29 tny-header.c \ 30 tny-mime-part.c \ 31 tny-folder.c \ 32 tny-device.c \ 33 tny-account.c \ 34 tny-store-account.c \ 35 tny-transport-account.c \ 36 tny-account-store.c \ 37 tny-stream.c \ 38 tny-fs-stream.c \ 39 tny-simple-list-priv.h \ 40 tny-simple-list.c \ 41 tny-simple-list-iterator-priv.h \ 42 tny-simple-list-iterator.c \ 43 tny-folder-store.c \ 44 44 tny-folder-store-query.c 45 45 trunk/libtinymailui-gtk/tny-gtk-attachment-mime-part-view.c
r991 r994 51 51 { 52 52 TnyMimePart *part; 53 TnySaveStrategy *save_strategy;54 53 TnyGtkAttachListModel *imodel; 55 54 }; … … 59 58 60 59 61 static void 62 tny_gtk_attachment_mime_part_view_set_save_strategy (TnyMimePartView *self, TnySaveStrategy *strategy) 63 { 64 TnyGtkAttachmentMimePartViewPriv *priv = TNY_GTK_ATTACHMENT_MIME_PART_VIEW_GET_PRIVATE (self); 65 66 if (priv->save_strategy) 67 g_object_unref (G_OBJECT (priv->save_strategy)); 68 69 g_object_ref (G_OBJECT (strategy)); 70 priv->save_strategy = strategy; 71 72 return; 73 } 74 75 76 static void 77 tny_gtk_attachment_mime_part_view_save_as_activated (GtkMenuItem *menuitem, gpointer user_data) 78 { 79 TnyGtkAttachmentMimePartView *self = user_data; 80 TnyGtkAttachmentMimePartViewPriv *priv = TNY_GTK_ATTACHMENT_MIME_PART_VIEW_GET_PRIVATE (self); 81 82 if (!G_LIKELY (priv->save_strategy)) 83 { 84 g_warning (_("No save strategy for this mime part view\n")); 85 return; 86 } 87 88 tny_save_strategy_save (priv->save_strategy, priv->part); 89 90 return; 91 } 92 93 94 static gint 95 tny_gtk_attachment_mime_part_view_popup_handler (GtkWidget *widget, GdkEvent *event) 96 { 97 g_return_val_if_fail (event != NULL, FALSE); 98 99 100 if (G_UNLIKELY (event->type == GDK_BUTTON_PRESS)) 101 { 102 GtkMenu *menu; 103 GdkEventButton *event_button; 104 105 menu = GTK_MENU (widget); 106 g_return_val_if_fail (widget != NULL, FALSE); 107 g_return_val_if_fail (GTK_IS_MENU (widget), FALSE); 108 109 event_button = (GdkEventButton *) event; 110 if (G_LIKELY (event_button->button == 3)) 111 { 112 gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 113 event_button->button, event_button->time); 114 return TRUE; 115 } 116 } 117 118 return FALSE; 60 static TnyMimePart* 61 tny_gtk_attachment_mime_part_view_get_part (TnyMimePartView *self) 62 { 63 TnyGtkAttachmentMimePartViewPriv *priv = TNY_GTK_ATTACHMENT_MIME_PART_VIEW_GET_PRIVATE (self); 64 return (priv->part)?TNY_MIME_PART (g_object_ref (priv->part)):NULL; 119 65 } 120 66 … … 159 105 **/ 160 106 TnyMimePartView* 161 tny_gtk_attachment_mime_part_view_new (Tny SaveStrategy *save_strategy, TnyGtkAttachListModel *imodel)107 tny_gtk_attachment_mime_part_view_new (TnyGtkAttachListModel *imodel) 162 108 { 163 109 TnyGtkAttachmentMimePartView *self = g_object_new (TNY_TYPE_GTK_ATTACHMENT_MIME_PART_VIEW, NULL); 164 165 tny_mime_part_view_set_save_strategy (TNY_MIME_PART_VIEW (self), save_strategy);166 110 167 111 g_object_ref (G_OBJECT (imodel)); … … 176 120 TnyGtkAttachmentMimePartView *self = (TnyGtkAttachmentMimePartView *)instance; 177 121 TnyGtkAttachmentMimePartViewPriv *priv = TNY_GTK_ATTACHMENT_MIME_PART_VIEW_GET_PRIVATE (self); 178 GtkMenu *menu = GTK_MENU (gtk_menu_new ());179 GtkWidget *mitem = gtk_menu_item_new_with_mnemonic ("Save _As");180 122 181 123 priv->imodel = NULL; 182 priv->save_strategy = NULL;183 184 gtk_widget_show (mitem);185 g_signal_connect (G_OBJECT (mitem), "activate",186 G_CALLBACK (tny_gtk_attachment_mime_part_view_save_as_activated), self);187 188 gtk_menu_shell_append (GTK_MENU_SHELL (menu), mitem);189 190 g_signal_connect_swapped (G_OBJECT (self), "button_press_event",191 G_CALLBACK (tny_gtk_attachment_mime_part_view_popup_handler), menu);192 124 193 125 return; … … 208 140 priv->part = NULL; 209 141 210 if (G_LIKELY (priv->save_strategy))211 g_object_unref (G_OBJECT (priv->save_strategy));212 priv->save_strategy = NULL;213 214 142 (*parent_class->finalize) (object); 215 143 … … 222 150 TnyMimePartViewIface *klass = (TnyMimePartViewIface *)g; 223 151 152 klass->get_part_func = tny_gtk_attachment_mime_part_view_get_part; 224 153 klass->set_part_func = tny_gtk_attachment_mime_part_view_set_part; 225 klass->set_save_strategy_func = tny_gtk_attachment_mime_part_view_set_save_strategy;226 154 klass->clear_func = tny_gtk_attachment_mime_part_view_clear; 227 155 trunk/libtinymailui-gtk/tny-gtk-attachment-mime-part-view.h
r991 r994 54 54 55 55 GType tny_gtk_attachment_mime_part_view_get_type (void); 56 TnyMimePartView* tny_gtk_attachment_mime_part_view_new (Tny SaveStrategy *save_strategy, TnyGtkAttachListModel *iview);56 TnyMimePartView* tny_gtk_attachment_mime_part_view_new (TnyGtkAttachListModel *iview); 57 57 58 58 G_END_DECLS trunk/libtinymailui-gtk/tny-gtk-msg-view.c
r992 r994 43 43 #include <tny-gtk-text-mime-part-view.h> 44 44 #include <tny-gtk-attachment-mime-part-view.h> 45 #include <tny-mime-part-saver.h> 45 46 46 47 #ifdef GNOME … … 64 65 GtkIconView *attachview; 65 66 GtkWidget *attachview_sw; 66 TnySaveStrategy *save_strategy;67 67 }; 68 68 … … 85 85 if (tny_mime_part_content_type_is (part, "text/*")) 86 86 { 87 retval = tny_gtk_text_mime_part_view_new ( priv->save_strategy);87 retval = tny_gtk_text_mime_part_view_new (); 88 88 gtk_box_pack_start (GTK_BOX (TNY_GTK_MSG_VIEW (self)->viewers), GTK_WIDGET (retval), TRUE, TRUE, 0); 89 89 gtk_widget_show (GTK_WIDGET (retval)); … … 103 103 model = gtk_icon_view_get_model (priv->attachview); 104 104 105 retval = tny_gtk_attachment_mime_part_view_new (priv->save_strategy, 106 TNY_GTK_ATTACH_LIST_MODEL (model)); 105 retval = tny_gtk_attachment_mime_part_view_new (TNY_GTK_ATTACH_LIST_MODEL (model)); 107 106 } 108 107 … … 150 149 151 150 static void 152 tny_gtk_msg_view_set_save_strategy (TnyMsgView *self, TnySaveStrategy *strategy)153 {154 TNY_GTK_MSG_VIEW_GET_CLASS (self)->set_save_strategy_func (self, strategy);155 }156 157 static void158 tny_gtk_msg_view_set_save_strategy_defimpl (TnyMsgView *self, TnySaveStrategy *strategy)159 {160 TnyGtkMsgViewPriv *priv = TNY_GTK_MSG_VIEW_GET_PRIVATE (self);161 162 if (priv->save_strategy)163 g_object_unref (G_OBJECT (priv->save_strategy));164 165 g_object_ref (G_OBJECT (strategy));166 priv->save_strategy = strategy;167 168 return;169 }170 171 172 static void173 tny_gtk_msg_view_save_as_activated (GtkMenuItem *menuitem, gpointer user_data)174 {175 TnyGtkMsgView *self = user_data;176 TnyGtkMsgViewPriv *priv = TNY_GTK_MSG_VIEW_GET_PRIVATE (self);177 178 if (!G_LIKELY (priv->save_strategy))179 {180 g_warning (_("No save strategy for this message view\n"));181 return;182 }183 184 tny_save_strategy_save (priv->save_strategy, TNY_MIME_PART (self));185 186 return;187 }188 189 190 static gint191 tny_gtk_msg_view_popup_handler (GtkWidget *widget, GdkEvent *event)192 {193 g_return_val_if_fail (event != NULL, FALSE);194 195 196 if (G_UNLIKELY (event->type == GDK_BUTTON_PRESS))197 {198 GtkMenu *menu;199 GdkEventButton *event_button;200 201 menu = GTK_MENU (widget);202 g_return_val_if_fail (widget != NULL, FALSE);203 g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);204 205 event_button = (GdkEventButton *) event;206 if (G_LIKELY (event_button->button == 3))207 {208 gtk_menu_popup (menu, NULL, NULL, NULL, NULL,209 event_button->button, event_button->time);210 return TRUE;211 }212 }213 214 return FALSE;215 }216 217 static void218 151 tny_gtk_msg_view_set_unavailable (TnyMsgView *self) 219 152 { … … 235 168 } 236 169 170 171 static TnyMsg* 172 tny_gtk_msg_view_get_msg (TnyMsgView *self) 173 { 174 return TNY_GTK_MSG_VIEW_GET_CLASS (self)->get_msg_func (self); 175 } 176 177 static TnyMsg* 178 tny_gtk_msg_view_get_msg_defimpl (TnyMsgView *self) 179 { 180 TnyGtkMsgViewPriv *priv = TNY_GTK_MSG_VIEW_GET_PRIVATE (self); 181 182 return (priv->msg)?TNY_MSG (g_object_ref (priv->msg)):NULL; 183 } 184 237 185 static void 238 186 tny_gtk_msg_view_set_msg (TnyMsgView *self, TnyMsg *msg) 239 187 { 240 TNY_GTK_MSG_VIEW_GET_CLASS (self)->set_msg_func (self, msg);188 TNY_GTK_MSG_VIEW_GET_CLASS (self)->set_msg_func (self, msg); 241 189 } 242 190 … … 268 216 tny_gtk_msg_view_clear (TnyMsgView *self) 269 217 { 270 TNY_GTK_MSG_VIEW_GET_CLASS (self)->clear_func (self);218 TNY_GTK_MSG_VIEW_GET_CLASS (self)->clear_func (self); 271 219 } 272 220 … … 293 241 /** 294 242 * tny_gtk_msg_view_new: 295 * @save_strategy: The save strategy to use296 243 * 297 244 * Return value: a new #TnyMsgView instance implemented for Gtk+ 298 245 **/ 299 246 TnyMsgView* 300 tny_gtk_msg_view_new ( TnySaveStrategy *save_strategy)247 tny_gtk_msg_view_new (void) 301 248 { 302 249 TnyGtkMsgView *self = g_object_new (TNY_TYPE_GTK_MSG_VIEW, NULL); 303 250 304 tny_msg_view_set_save_strategy (TNY_MSG_VIEW (self), save_strategy);305 306 251 return TNY_MSG_VIEW (self); 307 252 } … … 313 258 TnyGtkMsgViewPriv *priv = TNY_GTK_MSG_VIEW_GET_PRIVATE (self); 314 259 GtkWidget *vbox = gtk_vbox_new (FALSE, 1); 315 GtkMenu *menu = GTK_MENU (gtk_menu_new ()); 316 GtkWidget *mitem = gtk_menu_item_new_with_mnemonic ("Save _As"); 317 318 priv->save_strategy = NULL; 260 261 priv->msg = NULL; 319 262 320 263 gtk_scrolled_window_set_hadjustment (GTK_SCROLLED_WINDOW (self), NULL); 321 264 gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (self), NULL); 322 323 gtk_widget_show (mitem);324 325 g_signal_connect (G_OBJECT (mitem), "activate",326 G_CALLBACK (tny_gtk_msg_view_save_as_activated), self);327 328 gtk_menu_shell_append (GTK_MENU_SHELL (menu), mitem);329 265 330 266 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (self), … … 333 269 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); 334 270 335 g_signal_connect_swapped (G_OBJECT (self), "button_press_event",336 G_CALLBACK (tny_gtk_msg_view_popup_handler), menu);337 338 271 priv->headerview = tny_gtk_header_view_new (); 339 272 gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (priv->headerview), FALSE, FALSE, 0); … … 359 292 gtk_icon_view_set_selection_mode (priv->attachview, GTK_SELECTION_SINGLE); 360 293 361 g_signal_connect_swapped (G_OBJECT (priv->attachview), "button_press_event",362 G_CALLBACK (tny_gtk_msg_view_popup_handler), menu);363 364 294 gtk_icon_view_set_text_column (priv->attachview, 365 295 TNY_GTK_ATTACH_LIST_MODEL_FILENAME_COLUMN); … … 393 323 g_object_unref (G_OBJECT (priv->msg)); 394 324 395 if (G_LIKELY (priv->save_strategy))396 g_object_unref (G_OBJECT (priv->save_strategy));397 398 325 (*parent_class->finalize) (object); 399 326 … … 402 329 403 330 static void 404 tny_ gtk_msg_view_init (gpointer g, gpointer iface_data)331 tny_msg_view_init (gpointer g, gpointer iface_data) 405 332 { 406 333 TnyMsgViewIface *klass = (TnyMsgViewIface *)g; 407 334 335 klass->get_msg_func = tny_gtk_msg_view_get_msg; 408 336 klass->set_msg_func = tny_gtk_msg_view_set_msg; 409 klass->set_save_strategy_func = tny_gtk_msg_view_set_save_strategy;410 337 klass->set_unavailable_func = tny_gtk_msg_view_set_unavailable; 411 338 klass->clear_func = tny_gtk_msg_view_clear; … … 425 352 object_class->finalize = tny_gtk_msg_view_finalize; 426 353 354 class->get_msg_func = tny_gtk_msg_view_get_msg_defimpl; 427 355 class->set_msg_func = tny_gtk_msg_view_set_msg_defimpl; 428 class->set_save_strategy_func = tny_gtk_msg_view_set_save_strategy_defimpl;429 356 class->set_unavailable_func = tny_gtk_msg_view_set_unavailable_defimpl; 430 357 class->clear_func = tny_gtk_msg_view_clear_defimpl; … … 457 384 }; 458 385 459 static const GInterfaceInfo tny_ gtk_msg_view_info =386 static const GInterfaceInfo tny_msg_view_info = 460 387 { 461 (GInterfaceInitFunc) tny_ gtk_msg_view_init, /* interface_init */388 (GInterfaceInitFunc) tny_msg_view_init, /* interface_init */ 462 389 NULL, /* interface_finalize */ 463 390 NULL /* interface_data */ 464 391 }; 465 392 466 393 type = g_type_register_static (GTK_TYPE_SCROLLED_WINDOW, 467 394 "TnyGtkMsgView", … … 469 396 470 397 g_type_add_interface_static (type, TNY_TYPE_MSG_VIEW, 471 &tny_ gtk_msg_view_info);472 398 &tny_msg_view_info); 399 473 400 } 474 401 trunk/libtinymailui-gtk/tny-gtk-msg-view.h
r984 r994 29 29 #include <tny-stream.h> 30 30 #include <tny-mime-part.h> 31 #include <tny-mime-part-saver.h> 31 32 #include <tny-save-strategy.h> 32 33 … … 54 55 55 56 /* virtual methods (they have a default implementation in TnyGtkMsgView */ 57 TnyMsg* (*get_msg_func) (TnyMsgView *self); 56 58 void (*set_msg_func) (TnyMsgView *self, TnyMsg *msg); 57 void (*set_save_strategy_func) (TnyMsgView *self, TnySaveStrategy *strategy);58 59 void (*set_unavailable_func) (TnyMsgView *self); 59 60 void (*clear_func) (TnyMsgView *self); … … 62 63 63 64 GType tny_gtk_msg_view_get_type (void); 64 TnyMsgView* tny_gtk_msg_view_new ( TnySaveStrategy *save_strategy);65 TnyMsgView* tny_gtk_msg_view_new (void); 65 66 66 67 G_END_DECLS trunk/libtinymailui-gtk/tny-gtk-msg-window.c
r900 r994 37 37 38 38 static void 39 tny_gtk_msg_window_set_ save_strategy (TnyMsgView *self, TnySaveStrategy *strategy)39 tny_gtk_msg_window_set_unavailable (TnyMsgView *self) 40 40 { 41 41 TnyGtkMsgWindowPriv *priv = TNY_GTK_MSG_WINDOW_GET_PRIVATE (self); 42 43 tny_msg_view_set_save_strategy (priv->msg_view, strategy); 44 42 tny_msg_view_set_unavailable (priv->msg_view); 45 43 return; 46 44 } 47 45 48 static void49 tny_gtk_msg_window_ set_unavailable(TnyMsgView *self)46 static TnyMsg* 47 tny_gtk_msg_window_get_msg (TnyMsgView *self) 50 48 { 51 49 TnyGtkMsgWindowPriv *priv = TNY_GTK_MSG_WINDOW_GET_PRIVATE (self); 52 53 tny_msg_view_set_unavailable (priv->msg_view); 54 55 return; 50 return tny_msg_view_get_msg (priv->msg_view); 56 51 } 57 58 52 59 53 static void … … 128 122 TnyMsgViewIface *klass = (TnyMsgViewIface *)g; 129 123 124 klass->get_msg_func = tny_gtk_msg_window_get_msg; 130 125 klass->set_msg_func = tny_gtk_msg_window_set_msg; 131 klass->set_save_strategy_func = tny_gtk_msg_window_set_save_strategy;132 126 klass->set_unavailable_func = tny_gtk_msg_window_set_unavailable; 133 127 trunk/libtinymailui-gtk/tny-gtk-text-mime-part-view.c
r991 r994 51 51 { 52 52 TnyMimePart *part; 53 TnySaveStrategy *save_strategy;54 53 }; 55 54 … … 57 56 (G_TYPE_INSTANCE_GET_PRIVATE ((o), TNY_TYPE_GTK_TEXT_MIME_PART_VIEW, TnyGtkTextMimePartViewPriv)) 58 57 59 60 61 static void 62 tny_gtk_text_mime_part_view_set_save_strategy (TnyMimePartView *self, TnySaveStrategy *strategy) 63 { 64 TnyGtkTextMimePartViewPriv *priv = TNY_GTK_TEXT_MIME_PART_VIEW_GET_PRIVATE (self); 65 66 if (priv->save_strategy) 67 g_object_unref (G_OBJECT (priv->save_strategy)); 68 69 g_object_ref (G_OBJECT (strategy)); 70 priv->save_strategy = strategy; 71 72 return; 73 } 74 75 76 static void 77 tny_gtk_text_mime_part_view_save_as_activated (GtkMenuItem *menuitem, gpointer user_data) 78 { 79 TnyGtkTextMimePartView *self = user_data; 80 TnyGtkTextMimePartViewPriv *priv = TNY_GTK_TEXT_MIME_PART_VIEW_GET_PRIVATE (self); 81 82 if (!G_LIKELY (priv->save_strategy)) 83 { 84 g_warning (_("No save strategy for this mime part view\n")); 85 return; 86 } 87 88 tny_save_strategy_save (priv->save_strategy, priv->part); 89 90 return; 91 } 92 93 94 static gint 95 tny_gtk_text_mime_part_view_popup_handler (GtkWidget *widget, GdkEvent *event) 96 { 97 g_return_val_if_fail (event != NULL, FALSE); 98 99 100 if (G_UNLIKELY (event->type == GDK_BUTTON_PRESS)) 101 { 102 GtkMenu *menu; 103 GdkEventButton *event_button; 104 105 menu = GTK_MENU (widget); 106 g_return_val_if_fail (widget != NULL, FALSE); 107 g_return_val_if_fail (GTK_IS_MENU (widget), FALSE); 108 109 event_button = (GdkEventButton *) event; 110 if (G_LIKELY (event_button->button == 3)) 111 { 112 gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 113 event_button->button, event_button->time); 114 return TRUE; 115 } 116 } 117 118 return FALSE; 58 59 static TnyMimePart* 60 tny_gtk_text_mime_part_view_get_part (TnyMimePartView *self) 61 { 62 TnyGtkTextMimePartViewPriv *priv = TNY_GTK_TEXT_MIME_PART_VIEW_GET_PRIVATE (self); 63 return (priv->part)?TNY_MIME_PART (g_object_ref (priv->part)):NULL; 119 64 } 120 65 … … 166 111 /** 167 112 * tny_gtk_text_mime_part_view_new: 168 * @save_strategy: The save strategy to use169 113 * 170 114 * Return value: a new #TnyMimePartView instance implemented for Gtk+ 171 115 **/ 172 116 TnyMimePartView* 173 tny_gtk_text_mime_part_view_new ( TnySaveStrategy *save_strategy)117 tny_gtk_text_mime_part_view_new (void) 174 118 { 175 119 TnyGtkTextMimePartView *self = g_object_new (TNY_TYPE_GTK_TEXT_MIME_PART_VIEW, NULL); 176 120 177 tny_mime_part_view_set_save_strategy (TNY_MIME_PART_VIEW (self), save_strategy);178 179 121 return TNY_MIME_PART_VIEW (self); 180 122 } … … 185 127 TnyGtkTextMimePartView *self = (TnyGtkTextMimePartView *)instance; 186 128 TnyGtkTextMimePartViewPriv *priv = TNY_GTK_TEXT_MIME_PART_VIEW_GET_PRIVATE (self); 187 GtkMenu *menu = GTK_MENU (gtk_menu_new ());188 GtkWidget *mitem = gtk_menu_item_new_with_mnemonic ("Save _As");189 190 priv->save_strategy = NULL;191 gtk_widget_show (mitem);192 193 g_signal_connect (G_OBJECT (mitem), "activate",194 G_CALLBACK (tny_gtk_text_mime_part_view_save_as_activated), self);195 196 gtk_menu_shell_append (GTK_MENU_SHELL (menu), mitem);197 198 g_signal_connect_swapped (G_OBJECT (self), "button_press_event",199 G_CALLBACK (tny_gtk_text_mime_part_view_popup_handler), menu);200 129 201 130 gtk_text_view_set_editable (GTK_TEXT_VIEW (self), FALSE); … … 212 141 if (G_LIKELY (priv->part)) 213 142 g_object_unref (G_OBJECT (priv->part)); 214 215 if (G_LIKELY (priv->save_strategy))216 g_object_unref (G_OBJECT (priv->save_strategy));217 143 218 144 (*parent_class->finalize) (object); … … 226 152 TnyMimePartViewIface *klass = (TnyMimePartViewIface *)g; 227 153 154 klass->get_part_func = tny_gtk_text_mime_part_view_get_part; 228 155 klass->set_part_func = tny_gtk_text_mime_part_view_set_part; 229 klass->set_save_strategy_func = tny_gtk_text_mime_part_view_set_save_strategy;230 156 klass->clear_func = tny_gtk_text_mime_part_view_clear; 231 157 trunk/libtinymailui-gtk/tny-gtk-text-mime-part-view.h
r984 r994 53 53 54 54 GType tny_gtk_text_mime_part_view_get_type (void); 55 TnyMimePartView* tny_gtk_text_mime_part_view_new ( TnySaveStrategy *save_strategy);55 TnyMimePartView* tny_gtk_text_mime_part_view_new (void); 56 56 57 57 G_END_DECLS trunk/libtinymailui-mozembed/tny-moz-embed-html-mime-part-view.c
r993 r994 52 52 { 53 53 TnyMimePart *part; 54 TnySaveStrategy *save_strategy;55 54 }; 56 55 … … 59 58 60 59 61 static void 62 tny_moz_embed_html_mime_part_view_set_save_strategy (TnyMimePartView *self, TnySaveStrategy *strategy) 60 61 static TnyMimePart* 62 tny_moz_embed_html_mime_part_view_get_part (TnyMimePartView *self) 63 63 { 64 64 TnyMozEmbedHtmlMimePartViewPriv *priv = TNY_MOZ_EMBED_HTML_MIME_PART_VIEW_GET_PRIVATE (self); 65 66 if (priv->save_strategy) 67 g_object_unref (G_OBJECT (priv->save_strategy)); 68 69 g_object_ref (G_OBJECT (strategy)); 70 priv->save_strategy = strategy; 71 72 return; 73 } 74 75 76 static void 77 tny_moz_embed_html_mime_part_view_save_as_activated (GtkMenuItem *menuitem, gpointer user_data) 78 { 79 TnyMozEmbedHtmlMimePartView *self = user_data; 80 TnyMozEmbedHtmlMimePartViewPriv *priv = TNY_MOZ_EMBED_HTML_MIME_PART_VIEW_GET_PRIVATE (self); 81 82 if (!G_LIKELY (priv->save_strategy)) 83 { 84 g_warning (_("No save strategy for this mime part view\n")); 85 return; 86 } 87 88 tny_save_strategy_save (priv->save_strategy, priv->part); 89 90 return; 91 } 92 93 94 static gint 95 tny_moz_embed_html_mime_part_view_popup_handler (GtkWidget *widget, GdkEvent *event) 96 { 97 g_return_val_if_fail (event != NULL, FALSE); 98 99 100 if (G_UNLIKELY (event->type == GDK_BUTTON_PRESS)) 101 { 102 GtkMenu *menu; 103 GdkEventButton *event_button; 104 105 menu = GTK_MENU (widget); 106 g_return_val_if_fail (widget != NULL, FALSE); 107 g_return_val_if_fail (GTK_IS_MENU (widget), FALSE); 108 109 event_button = (GdkEventButton *) event; 110 if (G_LIKELY (event_button->button == 3)) 111 { 112 gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 113 event_button->button, event_button->time); 114 return TRUE; 115 } 116 } 117 118 return FALSE; 119 } 120 121 65 return (priv->part)?TNY_MIME_PART (g_object_ref (priv->part)):NULL; 66 } 67 68 122 69 static gpointer 123 70 remove_html_stread_hack (gpointer data) … … 171 118 /** 172 119 * tny_moz_embed_html_mime_part_view_new: 173 * @save_strategy: The save strategy to use174 120 * 175 121 * Return value: a new #TnyMimePartView instance implemented for Gtk+ 176 122 **/ 177 123 TnyMimePartView* 178 tny_moz_embed_html_mime_part_view_new ( TnySaveStrategy *save_strategy)124 tny_moz_embed_html_mime_part_view_new (void) 179 125 { 180 126 TnyMozEmbedHtmlMimePartView *self = g_object_new (TNY_TYPE_MOZ_EMBED_HTML_MIME_PART_VIEW, NULL); 181 127 182 tny_mime_part_view_set_save_strategy (TNY_MIME_PART_VIEW (self), save_strategy);183 184 128 return TNY_MIME_PART_VIEW (self); 185 129 } … … 188 132 tny_moz_embed_html_mime_part_view_instance_init (GTypeInstance *instance, gpointer g_class) 189 133 { 190 TnyMozEmbedHtmlMimePartView *self = (TnyMozEmbedHtmlMimePartView *)instance;191 TnyMozEmbedHtmlMimePartViewPriv *priv = TNY_MOZ_EMBED_HTML_MIME_PART_VIEW_GET_PRIVATE (self);192 GtkMenu *menu = GTK_MENU (gtk_menu_new ());193 GtkWidget *mitem = gtk_menu_item_new_with_mnemonic ("Save _As");194 195 priv->save_strategy = NULL;196 gtk_widget_show (mitem);197 198 g_signal_connect (G_OBJECT (mitem), "activate",199 G_CALLBACK (tny_moz_embed_html_mime_part_view_save_as_activated), self);200 201 gtk_menu_shell_append (GTK_MENU_SHELL (menu), mitem);202 203 g_signal_connect_swapped (G_OBJECT (self), "button_press_event",204 G_CALLBACK (tny_moz_embed_html_mime_part_view_popup_handler), menu);205 206 134 return; 207 135 } … … &
