X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-msg-view-window.c;h=4d1cf231745a95f24f7deac869042ceb03e4986a;hp=1b56900c75ee5c5268ac9e59175a72ee1ac478a4;hb=6fb1323bf79f5fe514da3bbb44130fdfdbd8e46f;hpb=47d7af9f662d805b13894792beef4c0e0aa77a6a diff --git a/src/maemo/modest-msg-view-window.c b/src/maemo/modest-msg-view-window.c index 1b56900..4d1cf23 100644 --- a/src/maemo/modest-msg-view-window.c +++ b/src/maemo/modest-msg-view-window.c @@ -50,10 +50,11 @@ #include "modest-progress-bar-widget.h" #include "modest-defs.h" #include "modest-hildon-includes.h" -#include #include "modest-ui-dimming-manager.h" #include #include +#include +#include #include #define DEFAULT_FOLDER "MyDocs/.documents" @@ -483,7 +484,7 @@ menubar_to_menu (GtkUIManager *ui_manager) } static void -init_window (ModestMsgViewWindow *obj, TnyMsg *msg) +init_window (ModestMsgViewWindow *obj) { GtkWidget *main_vbox; ModestMsgViewWindowPrivate *priv; @@ -494,7 +495,7 @@ init_window (ModestMsgViewWindow *obj, TnyMsg *msg) priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(obj); parent_priv = MODEST_WINDOW_GET_PRIVATE(obj); - priv->msg_view = modest_msg_view_new (msg); + priv->msg_view = GTK_WIDGET (tny_platform_factory_new_msg_view (modest_tny_platform_factory_get_instance ())); modest_msg_view_set_shadow_type (MODEST_MSG_VIEW (priv->msg_view), GTK_SHADOW_NONE); main_vbox = gtk_vbox_new (FALSE, 6); @@ -517,7 +518,11 @@ init_window (ModestMsgViewWindow *obj, TnyMsg *msg) gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->main_scroll), GTK_SHADOW_NONE); modest_maemo_set_thumbable_scrollbar (GTK_SCROLLED_WINDOW(priv->main_scroll), TRUE); +#ifdef MODEST_USE_MOZEMBED + gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (priv->main_scroll), priv->msg_view); +#else gtk_container_add (GTK_CONTAINER (priv->main_scroll), priv->msg_view); +#endif gtk_box_pack_start (GTK_BOX(main_vbox), priv->main_scroll, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER(obj), main_vbox); @@ -687,7 +692,7 @@ select_next_valid_row (GtkTreeModel *model, /* TODO: This should be in _init(), with the parameters as properties. */ static void -modest_msg_view_window_construct (ModestMsgViewWindow *self, TnyMsg *msg, +modest_msg_view_window_construct (ModestMsgViewWindow *self, const gchar *modest_account_name, const gchar *msg_uid) { @@ -701,8 +706,6 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self, TnyMsg *msg, GError *error = NULL; GdkPixbuf *window_icon; - g_return_if_fail (msg); - obj = G_OBJECT (self); priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(obj); parent_priv = MODEST_WINDOW_GET_PRIVATE(obj); @@ -779,7 +782,7 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self, TnyMsg *msg, gtk_ui_manager_get_accel_group (parent_priv->ui_manager)); /* Init window */ - init_window (MODEST_MSG_VIEW_WINDOW(obj), msg); + init_window (MODEST_MSG_VIEW_WINDOW(obj)); restore_settings (MODEST_MSG_VIEW_WINDOW(obj)); /* Set window icon */ @@ -791,7 +794,7 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self, TnyMsg *msg, /* g_signal_connect (G_OBJECT(obj), "delete-event", G_CALLBACK(on_delete_event), obj); */ - g_signal_connect (G_OBJECT(priv->msg_view), "link_clicked", + g_signal_connect (G_OBJECT(priv->msg_view), "activate_link", G_CALLBACK (modest_ui_actions_on_msg_link_clicked), obj); g_signal_connect (G_OBJECT(priv->msg_view), "link_hover", G_CALLBACK (modest_ui_actions_on_msg_link_hover), obj); @@ -837,7 +840,7 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self, TnyMsg *msg, /* Check toolbar dimming rules */ modest_ui_actions_check_toolbar_dimming_rules (MODEST_WINDOW (obj)); modest_window_check_dimming_rules_group (MODEST_WINDOW (obj), "ModestClipboardDimmingRules"); - + } ModestWindow * @@ -856,7 +859,7 @@ modest_msg_view_window_new_with_header_model (TnyMsg *msg, window = g_object_new(MODEST_TYPE_MSG_VIEW_WINDOW, NULL); g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window), NULL); - modest_msg_view_window_construct (window, msg, modest_account_name, msg_uid); + modest_msg_view_window_construct (window, modest_account_name, msg_uid); priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window); @@ -904,6 +907,10 @@ modest_msg_view_window_new_with_header_model (TnyMsg *msg, MODEST_HEADER_VIEW_OBSERVER(window)); } + gtk_widget_show_all (GTK_WIDGET (window)); + + tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg); + modest_msg_view_window_update_priority (window); /* Check toolbar dimming rules */ @@ -922,7 +929,7 @@ modest_msg_view_window_new_for_search_result (TnyMsg *msg, window = g_object_new(MODEST_TYPE_MSG_VIEW_WINDOW, NULL); g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window), NULL); - modest_msg_view_window_construct (window, msg, modest_account_name, msg_uid); + modest_msg_view_window_construct (window, modest_account_name, msg_uid); priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window); @@ -930,6 +937,8 @@ modest_msg_view_window_new_for_search_result (TnyMsg *msg, * so we can disable some UI appropriately: */ priv->is_search_result = TRUE; + tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg); + return MODEST_WINDOW(window); } @@ -939,11 +948,15 @@ modest_msg_view_window_new_for_attachment (TnyMsg *msg, const gchar *msg_uid) { GObject *obj = NULL; + ModestMsgViewWindowPrivate *priv; g_return_val_if_fail (msg, NULL); obj = g_object_new(MODEST_TYPE_MSG_VIEW_WINDOW, NULL); + priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (obj); modest_msg_view_window_construct (MODEST_MSG_VIEW_WINDOW (obj), - msg, modest_account_name, msg_uid); + modest_account_name, msg_uid); + + tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg); return MODEST_WINDOW(obj); } @@ -1157,8 +1170,10 @@ modest_msg_view_window_get_header (ModestMsgViewWindow *self) */ if (priv->header_model == NULL) { msg = modest_msg_view_window_get_message (self); - header = tny_msg_get_header (msg); - g_object_unref (msg); + if (msg) { + header = tny_msg_get_header (msg); + g_object_unref (msg); + } return header; } @@ -1196,7 +1211,7 @@ modest_msg_view_window_get_message (ModestMsgViewWindow *self) msg_view = MODEST_MSG_VIEW (priv->msg_view); - return modest_msg_view_get_message (msg_view); + return tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view)); } const gchar* @@ -1257,7 +1272,7 @@ modest_msg_view_window_find_toolbar_search (GtkWidget *widget, gchar *current_search; ModestMsgViewWindowPrivate *priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (obj); - if (modest_msg_view_get_message_is_empty (MODEST_MSG_VIEW (priv->msg_view))) { + if (modest_mime_part_view_is_empty (MODEST_MIME_PART_VIEW (priv->msg_view))) { hildon_banner_show_information (NULL, NULL, _("mail_ib_nothing_to_find")); return; } @@ -1274,8 +1289,8 @@ modest_msg_view_window_find_toolbar_search (GtkWidget *widget, gboolean result; g_free (priv->last_search); priv->last_search = g_strdup (current_search); - result = modest_msg_view_search (MODEST_MSG_VIEW (priv->msg_view), - priv->last_search); + result = modest_isearch_view_search (MODEST_ISEARCH_VIEW (priv->msg_view), + priv->last_search); if (!result) { hildon_banner_show_information (NULL, NULL, dgettext("hildon-libs", "ckct_ib_find_no_matches")); g_free (priv->last_search); @@ -1284,7 +1299,7 @@ modest_msg_view_window_find_toolbar_search (GtkWidget *widget, modest_msg_view_grab_focus (MODEST_MSG_VIEW (priv->msg_view)); } } else { - if (!modest_msg_view_search_next (MODEST_MSG_VIEW (priv->msg_view))) { + if (!modest_isearch_view_search_next (MODEST_ISEARCH_VIEW (priv->msg_view))) { hildon_banner_show_information (NULL, NULL, dgettext("hildon-libs", "ckct_ib_find_search_complete")); g_free (priv->last_search); priv->last_search = NULL; @@ -1310,7 +1325,7 @@ modest_msg_view_window_set_zoom (ModestWindow *window, priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window); parent_priv = MODEST_WINDOW_GET_PRIVATE (window); - modest_msg_view_set_zoom (MODEST_MSG_VIEW (priv->msg_view), zoom); + modest_zoomable_set_zoom (MODEST_ZOOMABLE (priv->msg_view), zoom); action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ViewMenu/ZoomMenu/Zoom50Menu"); @@ -1326,7 +1341,7 @@ modest_msg_view_window_get_zoom (ModestWindow *window) g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window), 1.0); priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window); - return modest_msg_view_get_zoom (MODEST_MSG_VIEW (priv->msg_view)); + return modest_zoomable_get_zoom (MODEST_ZOOMABLE (priv->msg_view)); } static gboolean @@ -1601,7 +1616,7 @@ message_reader (ModestMsgViewWindow *window, /* New mail operation */ mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT(window), modest_ui_actions_get_msgs_full_error_handler, - NULL); + NULL, NULL); modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op); modest_mail_operation_get_msg (mail_op, header, view_msg_cb, row_reference); @@ -1788,7 +1803,7 @@ view_msg_cb (ModestMailOperation *mail_op, tny_header_set_flags (header, TNY_HEADER_FLAG_SEEN); /* Set new message */ - modest_msg_view_set_message (MODEST_MSG_VIEW (priv->msg_view), msg); + tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg); modest_msg_view_window_update_priority (self); update_window_title (MODEST_MSG_VIEW_WINDOW (self)); modest_msg_view_grab_focus (MODEST_MSG_VIEW (priv->msg_view)); @@ -1818,7 +1833,7 @@ modest_msg_view_window_get_folder_type (ModestMsgViewWindow *window) folder_type = TNY_FOLDER_TYPE_UNKNOWN; - msg = modest_msg_view_get_message (MODEST_MSG_VIEW (priv->msg_view)); + msg = tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view)); if (msg) { TnyFolder *folder; @@ -2161,11 +2176,24 @@ void modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, TnyMimePart *mime_part) { ModestMsgViewWindowPrivate *priv; + const gchar *msg_uid; + gchar *attachment_uid = NULL; + gint attachment_index = 0; + GList *attachments; + g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window)); g_return_if_fail (TNY_IS_MIME_PART (mime_part) || (mime_part == NULL)); - priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window); + msg_uid = modest_msg_view_window_get_message_uid (MODEST_MSG_VIEW_WINDOW (window)); + attachments = modest_msg_view_get_attachments (MODEST_MSG_VIEW (priv->msg_view)); + attachment_index = g_list_index (attachments, mime_part); + g_list_free (attachments); + + if (msg_uid && attachment_index >= 0) { + attachment_uid = g_strdup_printf ("%s/%d", msg_uid, attachment_index); + } + if (mime_part == NULL) { gboolean error = FALSE; GList *selected_attachments = modest_msg_view_get_selected_attachments (MODEST_MSG_VIEW (priv->msg_view)); @@ -2196,8 +2224,7 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, TnyMimePart gchar *filepath = NULL; const gchar *att_filename = tny_mime_part_get_filename (mime_part); TnyFsStream *temp_stream = NULL; - - temp_stream = modest_maemo_utils_create_temp_stream (att_filename, &filepath); + temp_stream = modest_maemo_utils_create_temp_stream (att_filename, attachment_uid, &filepath); if (temp_stream) { const gchar *content_type; @@ -2230,11 +2257,11 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, TnyMimePart g_warning ("window for is already being created"); } else { /* it's not found, so create a new window for it */ - modest_window_mgr_register_header (mgr, header); /* register the uid before building the window */ + modest_window_mgr_register_header (mgr, header, attachment_uid); /* register the uid before building the window */ gchar *account = g_strdup (modest_window_get_active_account (MODEST_WINDOW (window))); if (!account) account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr ()); - msg_win = modest_msg_view_window_new_for_attachment (TNY_MSG (mime_part), account, NULL); + msg_win = modest_msg_view_window_new_for_attachment (TNY_MSG (mime_part), account, attachment_uid); modest_window_set_zoom (MODEST_WINDOW (msg_win), modest_window_get_zoom (MODEST_WINDOW (window))); modest_window_mgr_register_window (mgr, msg_win); @@ -2569,10 +2596,10 @@ modest_msg_view_window_remove_attachments (ModestMsgViewWindow *window, gboolean /* modest_msg_view_remove_attachment (MODEST_MSG_VIEW (priv->msg_view), node->data); */ } - msg = modest_msg_view_get_message (MODEST_MSG_VIEW (priv->msg_view)); - modest_msg_view_set_message (MODEST_MSG_VIEW (priv->msg_view), NULL); + msg = tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view)); + tny_msg_view_clear (TNY_MSG_VIEW (priv->msg_view)); tny_msg_rewrite_cache (msg); - modest_msg_view_set_message (MODEST_MSG_VIEW (priv->msg_view), msg); + tny_msg_view_set_msg (TNY_MSG_VIEW (priv->msg_view), msg); g_list_foreach (mime_parts, (GFunc) g_object_unref, NULL); g_list_free (mime_parts); @@ -2600,7 +2627,7 @@ update_window_title (ModestMsgViewWindow *window) TnyHeader *header = NULL; const gchar *subject = NULL; - msg = modest_msg_view_get_message (MODEST_MSG_VIEW (priv->msg_view)); + msg = tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view)); if (msg != NULL) { header = tny_msg_get_header (msg); subject = tny_header_get_subject (header);