Fixed some problems with synchronization between the attachments in
authorJose Dapena Paz <jdapena@igalia.com>
Thu, 7 Jun 2007 10:39:55 +0000 (10:39 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Thu, 7 Jun 2007 10:39:55 +0000 (10:39 +0000)
the attachments view of the editor, and the internal attachments list
the editor contains (fixes NB#57756):
* src/widgets/modest-attachments-view.[ch]:
        * Added the method modest_attachments_view_get_attachments, that
          obtains the mime parts of all the attachments shown.
* src/maemo/modest-msg-edit-window.c:
        * Now, set_msg updates the list of attachments from the
          attachments view.
        * Fixed the code to hide and show the attachments caption.

pmo-trunk-r2095

src/maemo/modest-msg-edit-window.c
src/widgets/modest-attachments-view.c
src/widgets/modest-attachments-view.h

index d156647..f770f7a 100644 (file)
@@ -597,8 +597,13 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg)
        
        /* Add attachments to the view */
        modest_attachments_view_set_message (MODEST_ATTACHMENTS_VIEW (priv->attachments_view), msg);
-       if (priv->attachments == NULL)
-               gtk_widget_hide_all (priv->attachments_caption);
+       priv->attachments = modest_attachments_view_get_attachments (MODEST_ATTACHMENTS_VIEW (priv->attachments_view));
+       if (priv->attachments == NULL) {
+               gtk_widget_hide (priv->attachments_caption);
+       } else {
+               gtk_widget_set_no_show_all (priv->attachments_caption, FALSE);
+               gtk_widget_show_all (priv->attachments_caption);
+       }
 
        gtk_text_buffer_get_start_iter (priv->text_buffer, &iter);
        gtk_text_buffer_place_cursor (priv->text_buffer, &iter);
@@ -1594,6 +1599,8 @@ modest_msg_edit_window_remove_attachments (ModestMsgEditWindow *window,
 
                        modest_attachments_view_remove_attachment (MODEST_ATTACHMENTS_VIEW (priv->attachments_view),
                                                                   mime_part);
+                       if (priv->attachments == NULL)
+                               gtk_widget_hide (priv->attachments_caption);
                        att_id = tny_mime_part_get_content_id (mime_part);
                        if (att_id != NULL)
                                text_buffer_delete_images_by_id (gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->msg_body)),
index e03795a..76706a8 100644 (file)
@@ -655,6 +655,27 @@ modest_attachments_view_get_selection (ModestAttachmentsView *atts_view)
        return selection;
 }
 
+GList *
+modest_attachments_view_get_attachments (ModestAttachmentsView *atts_view)
+{
+       ModestAttachmentsViewPrivate *priv;
+       GList *children, *node, *att_list = NULL;
+
+       g_return_val_if_fail (MODEST_IS_ATTACHMENTS_VIEW (atts_view), NULL);
+       priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (atts_view);
+
+       children = gtk_container_get_children (GTK_CONTAINER (priv->box));
+       for (node = children; node != NULL; node = g_list_next (node)) {
+               GtkWidget *att_view = GTK_WIDGET (node->data);
+               TnyMimePart *mime_part = tny_mime_part_view_get_part (TNY_MIME_PART_VIEW (att_view));
+               att_list = g_list_prepend (att_list, mime_part);
+       }
+       g_list_free (children);
+       att_list = g_list_reverse (att_list);
+       return att_list;
+
+}
+
 void
 modest_attachments_view_select_all (ModestAttachmentsView *atts_view)
 {
index 527e531..90f59e2 100644 (file)
@@ -70,6 +70,7 @@ void modest_attachments_view_set_message (ModestAttachmentsView *attachments_vie
 void modest_attachments_view_add_attachment (ModestAttachmentsView *attachments_view, TnyMimePart *part);
 void modest_attachments_view_remove_attachment (ModestAttachmentsView *attachments_view, TnyMimePart *part);
 void modest_attachments_view_remove_attachment_by_id (ModestAttachmentsView *attachments_view, const gchar *att_id);
+GList *modest_attachments_view_get_attachments (ModestAttachmentsView *attachments_view);
 GList *modest_attachments_view_get_selection (ModestAttachmentsView *attachments_view);
 void modest_attachments_view_select_all (ModestAttachmentsView *attachments_view);