From: Jose Dapena Paz Date: Fri, 22 May 2009 10:36:47 +0000 (+0200) Subject: Fix attachments view in Diablo X-Git-Tag: 3.0.17-rc7~2 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=c6d21e6d0e7415d88785efd017ecf549e1a261ee Fix attachments view in Diablo --- diff --git a/src/maemo/modest-msg-view-window.c b/src/maemo/modest-msg-view-window.c index 98fc8c3..8d21c40 100644 --- a/src/maemo/modest-msg-view-window.c +++ b/src/maemo/modest-msg-view-window.c @@ -2617,7 +2617,8 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, mime_part = (TnyMimePart *) tny_iterator_get_current (iter); g_object_unref (iter); } - g_object_unref (selected_attachments); + if (selected_attachments) + g_object_unref (selected_attachments); if (error) return; @@ -2633,7 +2634,7 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, /* we also check for mime_part == priv->msg, as this means it's a direct attachment * shown as attachment, so it should behave as a file */ window_msg = TNY_MIME_PART (tny_msg_view_get_msg (TNY_MSG_VIEW (priv->msg_view))); - if (!modest_tny_mime_part_is_msg (mime_part)|| + if ((!modest_tny_mime_part_is_msg (mime_part) && tny_mime_part_get_filename (mime_part)) || mime_part == window_msg) { gchar *filepath = NULL; const gchar *att_filename = tny_mime_part_get_filename (mime_part); @@ -2670,6 +2671,42 @@ modest_msg_view_window_view_attachment (ModestMsgViewWindow *window, g_free (filepath); if (show_error_banner) modest_platform_information_banner (NULL, NULL, _("mail_ib_file_operation_failed")); + } else if (!modest_tny_mime_part_is_msg (mime_part)) { + ModestWindowMgr *mgr; + ModestWindow *msg_win = NULL; + TnyMsg *current_msg; + gboolean found; + TnyHeader *header; + + current_msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW (window)); + mgr = modest_runtime_get_window_mgr (); + header = tny_msg_get_header (TNY_MSG (current_msg)); + found = modest_window_mgr_find_registered_message_uid (mgr, + attachment_uid, + &msg_win); + + if (found) { + g_warning ("window for this body is already being created"); + } else { + + /* it's not found, so create a new window for it */ + 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))); + const gchar *mailbox = modest_window_get_active_mailbox (MODEST_WINDOW (window)); + if (!account) + account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr ()); + + msg_win = modest_msg_view_window_new_with_other_body (TNY_MSG (current_msg), TNY_MIME_PART (mime_part), + account, mailbox, attachment_uid); + + modest_window_set_zoom (MODEST_WINDOW (msg_win), + modest_window_get_zoom (MODEST_WINDOW (window))); + if (modest_window_mgr_register_window (mgr, msg_win, MODEST_WINDOW (window))) + gtk_widget_show_all (GTK_WIDGET (msg_win)); + else + gtk_widget_destroy (GTK_WIDGET (msg_win)); + } + g_object_unref (current_msg); } else { /* message attachment */ TnyHeader *header = NULL; diff --git a/src/widgets/modest-attachments-view.c b/src/widgets/modest-attachments-view.c index cb26f1e..a4476b9 100644 --- a/src/widgets/modest-attachments-view.c +++ b/src/widgets/modest-attachments-view.c @@ -60,6 +60,7 @@ struct _ModestAttachmentsViewPrivate GList *selected; GtkWidget *rubber_start; GtkWidget *press_att_view; + GtkWidget *previous_selection; ModestAttachmentsViewStyle style; }; @@ -472,12 +473,16 @@ button_press_event (GtkWidget *widget, if (att_view != NULL) { if (priv->style == MODEST_ATTACHMENTS_VIEW_STYLE_NO_FOCUS) { unselect_all (MODEST_ATTACHMENTS_VIEW (widget)); - } else if ((priv->style == MODEST_ATTACHMENTS_VIEW_STYLE_LINKS) || - (GTK_WIDGET_STATE (att_view) == GTK_STATE_SELECTED && (g_list_length (priv->selected) < 2))) { + } else if (priv->style == MODEST_ATTACHMENTS_VIEW_STYLE_LINKS) { priv->press_att_view = att_view; set_selected (MODEST_ATTACHMENTS_VIEW (widget), MODEST_ATTACHMENT_VIEW (att_view)); gtk_grab_add (widget); } else { + if (g_list_length (priv->selected) == 1) { + priv->previous_selection = GTK_WIDGET (priv->selected->data); + } else { + priv->previous_selection = NULL; + } TnyMimePart *mime_part = tny_mime_part_view_get_part (TNY_MIME_PART_VIEW (att_view)); /* Do not select purged attachments */ @@ -517,7 +522,14 @@ button_release_event (GtkWidget *widget, priv->press_att_view = NULL; } else { - if (att_view != NULL) { + if (priv->style != MODEST_ATTACHMENTS_VIEW_STYLE_NO_FOCUS && + priv->rubber_start == att_view && + priv->previous_selection == att_view) { + TnyMimePart *mime_part; + mime_part = tny_mime_part_view_get_part (TNY_MIME_PART_VIEW (att_view)); + g_signal_emit (G_OBJECT (widget), signals[ACTIVATE_SIGNAL], 0, mime_part); + g_object_unref (mime_part); + } else if (att_view != NULL) { unselect_all (MODEST_ATTACHMENTS_VIEW (widget)); select_range (MODEST_ATTACHMENTS_VIEW (widget), MODEST_ATTACHMENT_VIEW (priv->rubber_start), diff --git a/src/widgets/modest-gtkhtml-msg-view.c b/src/widgets/modest-gtkhtml-msg-view.c index 8ca07e3..8b92f05 100644 --- a/src/widgets/modest-gtkhtml-msg-view.c +++ b/src/widgets/modest-gtkhtml-msg-view.c @@ -1737,11 +1737,15 @@ set_message (ModestGtkhtmlMsgView *self, TnyMsg *msg, TnyMimePart *other_body) children = gtk_container_get_children (GTK_CONTAINER (priv->attachments_box)); label = GTK_LABEL (children->data); gtk_widget_show_all (priv->attachments_box); +#ifdef MODEST_TOOLKIT_HILDON2 if (modest_attachments_view_get_num_attachments (widget) > 1) { text = _("mail_va_attachments"); } else { text = _("mail_va_attachment"); } +#else + text = _("mail_va_attachment"); +#endif gtk_label_set_text (label, text); } else { gtk_widget_hide_all (priv->attachments_box);