* src/widgets/modest-mail-header-view.c:
authorJose Dapena Paz <jdapena@igalia.com>
Wed, 7 Mar 2007 11:32:05 +0000 (11:32 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Wed, 7 Mar 2007 11:32:05 +0000 (11:32 +0000)
        * Added modest_mail_header_view_update_is_sent. It detects
          if the mail is incoming or outcoming using the folder
          information.
* Added src/widgets/modest-attachments-view.[ch]:
        * New GtkTextView based view for attachments. It shows
          attachments as a list of links.
* src/widgets/modest-recpt-view.c:
        * Removed warnings that happened on instantiation of
          ModestRecptView. The problem was that a GtkScrolledWindow
          required to get adjustments in initialisation (even if they
          are NULL).
* src/widgets/modest-msg-view.c:
        * Modified to use the new ModestAttachmentsView widget, and
          removed old attachments_as_html as it's not required now.
* src/widgets/Makefile.am:
        * Included modest-attachments-view.[ch]
* src/Makefile.am:
        * Now gtk directory is gnome.

pmo-trunk-r892

src/Makefile.am
src/modest-platform.h
src/widgets/Makefile.am
src/widgets/modest-attachments-view.c [new file with mode: 0644]
src/widgets/modest-attachments-view.h [new file with mode: 0644]
src/widgets/modest-mail-header-view.c
src/widgets/modest-msg-view.c
src/widgets/modest-recpt-view.c

index 1c341b9..5ead243 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile.am
 # Time-stamp: <2007-03-03 17:20:20 (djcb)>
 SUBDIRS=$(MODEST_PLATFORM) widgets
-DIST_SUBDIRS = widgets gtk maemo
+DIST_SUBDIRS = widgets gnome maemo
 
 INCLUDES=\
        $(MODEST_GSTUFF_CFLAGS)\
index 8e24e4a..e4d4b15 100644 (file)
@@ -69,7 +69,7 @@ TnyDevice*  modest_platform_get_new_device (void);
  *
  * Returns: the icon name
  */
-const gchar*  modest_platform_get_file_icon (const gchar* name, const gchar* mime_type,
-                                            gchar **effective_mime_type);
+gchar*  modest_platform_get_file_icon_name (const gchar* name, const gchar* mime_type,
+                                           gchar **effective_mime_type);
 
 #endif /* __MODEST_PLATFORM_UTILS_H__ */
index 4cf053a..a5ffb26 100644 (file)
@@ -20,6 +20,8 @@ libmodest_widgets_la_SOURCES=          \
        modest-account-view-window.h   \
        modest-account-view.c          \
        modest-account-view.h          \
+       modest-attachments-view.c      \
+       modest-attachments-view.h      \
        modest-combo-box.c             \
        modest-combo-box.h             \
        modest-folder-view.c           \
diff --git a/src/widgets/modest-attachments-view.c b/src/widgets/modest-attachments-view.c
new file mode 100644 (file)
index 0000000..383093e
--- /dev/null
@@ -0,0 +1,294 @@
+/* Copyright (c) 2007, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <config.h>
+
+#include <glib/gi18n-lib.h>
+
+#include <string.h>
+#include <gtk/gtk.h>
+
+#include <tny-list.h>
+#include <tny-simple-list.h>
+
+#include <modest-platform.h>
+#include <modest-runtime.h>
+#include <modest-attachments-view.h>
+
+static GObjectClass *parent_class = NULL;
+
+/* signals */
+enum {
+       ACTIVATE_SIGNAL,
+       LAST_SIGNAL
+};
+
+typedef struct _ModestAttachmentsViewPriv ModestAttachmentsViewPriv;
+
+struct _ModestAttachmentsViewPriv
+{
+       TnyMsg *msg;
+};
+
+#define MODEST_ATTACHMENTS_VIEW_GET_PRIVATE(o) \
+       (G_TYPE_INSTANCE_GET_PRIVATE ((o), MODEST_TYPE_ATTACHMENTS_VIEW, ModestAttachmentsViewPriv))
+
+static guint signals[LAST_SIGNAL] = {0};
+
+
+/**
+ * modest_attachments_view_new:
+ * @msg: a #TnyMsg
+ *
+ * Constructor for attachments view widget.
+ *
+ * Return value: a new #ModestAttachmentsView instance implemented for Gtk+
+ **/
+GtkWidget*
+modest_attachments_view_new (TnyMsg *msg)
+{
+       ModestAttachmentsView *self = g_object_new (MODEST_TYPE_ATTACHMENTS_VIEW, NULL);
+
+       modest_attachments_view_set_message (self, msg);
+
+       return GTK_WIDGET (self);
+}
+
+void
+modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, TnyMsg *msg)
+{
+       ModestAttachmentsViewPriv *priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (attachments_view);
+       TnyList *parts;
+       TnyIterator *iter;
+       gint index = 0;
+       GtkTextBuffer *buffer = NULL;
+       gboolean has_first = FALSE;
+       GtkTextIter text_iter;
+       gint icon_height;
+
+       if (priv->msg) {
+               g_object_unref (priv->msg);
+       }
+       priv->msg = msg;
+
+       buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (attachments_view));
+       gtk_text_buffer_set_text (buffer, "", -1);
+       gtk_text_buffer_get_end_iter (buffer, &text_iter);
+
+       if (priv->msg == NULL) {
+               gtk_widget_hide (GTK_WIDGET (attachments_view));
+               return;
+       }
+
+       parts = TNY_LIST (tny_simple_list_new ());
+       tny_mime_part_get_parts (TNY_MIME_PART (priv->msg), parts);
+       iter = tny_list_create_iterator (parts);
+
+       gtk_icon_size_lookup (GTK_ICON_SIZE_BUTTON, NULL, &icon_height);
+
+       while (!tny_iterator_is_done (iter)) {
+               TnyMimePart *part;
+
+               ++index;
+               part = TNY_MIME_PART (tny_iterator_get_current (iter));
+               if (tny_mime_part_is_attachment (part)) {
+                       const gchar *filename = tny_mime_part_get_filename (part);
+                       gchar *file_icon_name = 
+                               modest_platform_get_file_icon_name (filename, tny_mime_part_get_content_type(part) , NULL);
+                       GdkPixbuf *pixbuf = NULL;
+                       GtkTextTag *tag = NULL;
+
+                       if (has_first) {
+                               gtk_text_buffer_insert (buffer, &text_iter, ", ", -1);
+                               gtk_text_buffer_get_end_iter (buffer, &text_iter);
+                       }
+                       
+                       tag = gtk_text_buffer_create_tag (buffer, NULL,
+                                                         "underline", PANGO_UNDERLINE_SINGLE,
+                                                         "foreground", "blue",
+                                                         NULL);
+                       
+                       g_object_set_data (G_OBJECT (tag), "attachment-index", GINT_TO_POINTER (index));
+                       g_object_set_data (G_OBJECT (tag), "attachment-set", GINT_TO_POINTER (TRUE));
+                       
+                       if (file_icon_name) {
+                               pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), file_icon_name, 
+                                                                  icon_height, GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
+                               if (pixbuf) {
+                                       gtk_text_buffer_insert_pixbuf (buffer, &text_iter, pixbuf);
+                               }
+                       }
+                       gtk_text_buffer_insert_with_tags (buffer, &text_iter, filename, -1, tag, NULL);
+                       gtk_text_buffer_get_end_iter (buffer, &text_iter);
+                       if (file_icon_name)
+                               g_free (file_icon_name);
+                       has_first = TRUE;
+               }
+               g_object_unref (part);
+               tny_iterator_next (iter);
+       }
+
+       if (has_first)
+               gtk_widget_show (GTK_WIDGET (attachments_view));
+       else
+               gtk_widget_hide (GTK_WIDGET (attachments_view));
+
+}
+
+static gboolean
+button_release_event (GtkWidget *widget,
+                     GdkEventButton *event,
+                     gpointer user_data)
+{
+       gint buffer_x, buffer_y;
+       GtkTextIter iter;
+       GSList *tags = NULL;
+       GSList *node = NULL;
+       
+       if ((event->type != GDK_BUTTON_RELEASE) 
+           || (event->button != 1))
+               return FALSE;
+       
+       gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (widget), GTK_TEXT_WINDOW_WIDGET,
+                                              event->x, event->y, &buffer_x, &buffer_y);
+       gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (widget), &iter, buffer_x, buffer_y);
+
+       tags = gtk_text_iter_get_tags (&iter);
+
+       for (node = tags; node != NULL; node = g_slist_next (node)) {
+               GtkTextTag *tag = node->data;
+               gboolean is_attachment = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tag), "attachment-set"));
+
+               if (is_attachment) {
+                       gint attachment_index = 0;
+
+                       attachment_index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tag), "attachment-index"));
+                       g_signal_emit (G_OBJECT (widget), signals[ACTIVATE_SIGNAL], NULL, attachment_index);
+                       break;
+               }
+               
+       }
+       return FALSE;
+}
+
+static void
+modest_attachments_view_instance_init (GTypeInstance *instance, gpointer g_class)
+{
+       ModestAttachmentsViewPriv *priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (instance);
+       GtkTextBuffer *buffer = NULL;
+
+       gtk_text_view_set_editable (GTK_TEXT_VIEW (instance), FALSE);
+       gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (instance), GTK_WRAP_WORD_CHAR);
+       gtk_text_view_set_pixels_above_lines (GTK_TEXT_VIEW (instance), 0);
+       gtk_text_view_set_pixels_below_lines (GTK_TEXT_VIEW (instance), 0);
+       gtk_text_view_set_justification (GTK_TEXT_VIEW (instance), GTK_JUSTIFY_LEFT);
+       gtk_text_view_set_left_margin (GTK_TEXT_VIEW (instance), 0);
+       gtk_text_view_set_right_margin (GTK_TEXT_VIEW (instance), 0);
+       gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (instance), FALSE);
+
+       buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (instance));
+
+       g_signal_connect (G_OBJECT (instance), "button-release-event", G_CALLBACK (button_release_event), NULL);
+
+       priv->msg = NULL;
+
+       return;
+}
+
+static void
+modest_attachments_view_finalize (GObject *object)
+{
+       ModestAttachmentsViewPriv *priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (object);
+
+       if (priv->msg) {
+               g_object_unref (priv->msg);
+               priv->msg = NULL;
+       }
+
+       (*parent_class->finalize) (object);
+
+       return;
+}
+
+static void 
+modest_attachments_view_class_init (ModestAttachmentsViewClass *klass)
+{
+       GObjectClass *object_class;
+       GtkWidgetClass *widget_class;
+
+       parent_class = g_type_class_peek_parent (klass);
+       object_class = (GObjectClass*) klass;
+       widget_class = GTK_WIDGET_CLASS (klass);
+
+       object_class->finalize = modest_attachments_view_finalize;
+
+       klass->activate = NULL;
+
+       g_type_class_add_private (object_class, sizeof (ModestAttachmentsViewPriv));
+
+       signals[ACTIVATE_SIGNAL] =
+               g_signal_new ("activate",
+                             G_TYPE_FROM_CLASS (object_class),
+                             G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+                             G_STRUCT_OFFSET(ModestAttachmentsViewClass, activate),
+                             NULL, NULL,
+                             g_cclosure_marshal_VOID__INT,
+                             G_TYPE_NONE, 1, G_TYPE_INT);
+       
+       return;
+}
+
+GType 
+modest_attachments_view_get_type (void)
+{
+       static GType type = 0;
+
+       if (G_UNLIKELY(type == 0))
+       {
+               static const GTypeInfo info = 
+               {
+                 sizeof (ModestAttachmentsViewClass),
+                 NULL,   /* base_init */
+                 NULL,   /* base_finalize */
+                 (GClassInitFunc) modest_attachments_view_class_init,   /* class_init */
+                 NULL,   /* class_finalize */
+                 NULL,   /* class_data */
+                 sizeof (ModestAttachmentsView),
+                 0,      /* n_preallocs */
+                 modest_attachments_view_instance_init    /* instance_init */
+               };
+
+               type = g_type_register_static (GTK_TYPE_TEXT_VIEW,
+                       "ModestAttachmentsView",
+                       &info, 0);
+
+       }
+
+       return type;
+}
diff --git a/src/widgets/modest-attachments-view.h b/src/widgets/modest-attachments-view.h
new file mode 100644 (file)
index 0000000..fe11722
--- /dev/null
@@ -0,0 +1,69 @@
+/* Copyright (c) 2007, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MODEST_ATTACHMENTS_VIEW_H
+#define MODEST_ATTACHMENTS_VIEW_H
+#include <gtk/gtk.h>
+#include <glib-object.h>
+#include <tny-msg.h>
+
+G_BEGIN_DECLS
+
+#define MODEST_TYPE_ATTACHMENTS_VIEW             (modest_attachments_view_get_type ())
+#define MODEST_ATTACHMENTS_VIEW(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), MODEST_TYPE_ATTACHMENTS_VIEW, ModestAttachmentsView))
+#define MODEST_ATTACHMENTS_VIEW_CLASS(vtable)    (G_TYPE_CHECK_CLASS_CAST ((vtable), MODEST_TYPE_ATTACHMENTS_VIEW, ModestAttachmentsViewClass))
+#define MODEST_IS_ATTACHMENTS_VIEW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MODEST_TYPE_ATTACHMENTS_VIEW))
+#define MODEST_IS_ATTACHMENTS_VIEW_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), MODEST_TYPE_ATTACHMENTS_VIEW))
+#define MODEST_ATTACHMENTS_VIEW_GET_CLASS(inst)  (G_TYPE_INSTANCE_GET_CLASS ((inst), MODEST_TYPE_ATTACHMENTS_VIEW, ModestAttachmentsViewClass))
+
+typedef struct _ModestAttachmentsView ModestAttachmentsView;
+typedef struct _ModestAttachmentsViewClass ModestAttachmentsViewClass;
+
+struct _ModestAttachmentsView
+{
+       GtkTextView parent;
+
+};
+
+struct _ModestAttachmentsViewClass
+{
+       GtkTextViewClass parent_class;
+
+       void (*activate)           (ModestAttachmentsView *attachments_view, gint index);
+};
+
+GType modest_attachments_view_get_type (void);
+
+GtkWidget* modest_attachments_view_new (TnyMsg *msg);
+
+void modest_attachments_view_set_message (ModestAttachmentsView *attachments_view, TnyMsg *msg);
+
+G_END_DECLS
+
+#endif
index 77a3ce3..2ad2f5a 100644 (file)
@@ -35,6 +35,7 @@
 #include <gtk/gtk.h>
 #include <modest-text-utils.h>
 #include <modest-mail-header-view.h>
+#include <modest-tny-folder.h>
 
 static GObjectClass *parent_class = NULL;
 
@@ -139,6 +140,41 @@ modest_mail_header_view_set_header (TnyHeaderView *self, TnyHeader *header)
        return;
 }
 
+static void
+modest_mail_header_view_update_is_sent (TnyHeaderView *self)
+{
+       ModestMailHeaderViewPriv *priv = MODEST_MAIL_HEADER_VIEW_GET_PRIVATE (self);
+       TnyFolder *folder = NULL;
+     
+       priv->is_sent = FALSE;
+
+       if (priv->header == NULL)
+               return;
+       
+       folder = tny_header_get_folder (priv->header);
+
+       if (folder) {
+               TnyFolderType folder_type;
+               folder_type = tny_folder_get_folder_type (folder);
+               if (folder_type == TNY_FOLDER_TYPE_NORMAL || folder_type == TNY_FOLDER_TYPE_UNKNOWN) {
+                       gchar *fname = tny_folder_get_name (folder);
+                       folder_type = modest_tny_folder_guess_folder_type_from_name (fname);
+               }
+
+               switch (folder_type) {
+               case TNY_FOLDER_TYPE_OUTBOX:
+               case TNY_FOLDER_TYPE_SENT:
+               case TNY_FOLDER_TYPE_DRAFTS:
+                       priv->is_sent = TRUE;
+                       break;
+               default:
+                       priv->is_sent = FALSE;
+               }
+
+               g_object_unref (folder);
+       }
+}
+
 static void 
 modest_mail_header_view_set_header_default (TnyHeaderView *self, TnyHeader *header)
 {
@@ -156,9 +192,13 @@ modest_mail_header_view_set_header_default (TnyHeaderView *self, TnyHeader *head
        if (header && G_IS_OBJECT (header))
        {
                const gchar *to, *from, *subject, *bcc, *cc;
+
                g_object_ref (G_OBJECT (header)); 
                priv->header = header;
 
+               modest_mail_header_view_update_is_sent (self);
+
+
                to = tny_header_get_to (header);
                from = tny_header_get_from (header);
                subject = tny_header_get_subject (header);
index 7d1653d..f45b10e 100644 (file)
@@ -43,6 +43,7 @@
 #include "modest-msg-view.h"
 #include "modest-tny-stream-gtkhtml.h"
 #include <modest-mail-header-view.h>
+#include <modest-attachments-view.h>
 
 
 /* 'private'/'protected' functions */
@@ -71,6 +72,8 @@ typedef struct _ModestMsgViewPrivate ModestMsgViewPrivate;
 struct _ModestMsgViewPrivate {
        GtkWidget   *gtkhtml;
        GtkWidget   *mail_header_view;
+       GtkWidget   *attachments_view;
+
        TnyMsg      *msg;
 
        gulong  sig1, sig2, sig3;
@@ -165,16 +168,20 @@ modest_msg_view_init (ModestMsgView *obj)
        priv = MODEST_MSG_VIEW_GET_PRIVATE(obj);
 
        priv->msg                     = NULL;
+
        priv->gtkhtml                 = gtk_html_new();
-       priv->mail_header_view        = GTK_WIDGET(modest_mail_header_view_new ());
-       gtk_widget_set_no_show_all (priv->mail_header_view, TRUE);
-       
        gtk_html_set_editable        (GTK_HTML(priv->gtkhtml), FALSE);
        gtk_html_allow_selection     (GTK_HTML(priv->gtkhtml), TRUE);
        gtk_html_set_caret_mode      (GTK_HTML(priv->gtkhtml), FALSE);
        gtk_html_set_blocking        (GTK_HTML(priv->gtkhtml), FALSE);
        gtk_html_set_images_blocking (GTK_HTML(priv->gtkhtml), FALSE);
 
+       priv->mail_header_view        = GTK_WIDGET(modest_mail_header_view_new ());
+       gtk_widget_set_no_show_all (priv->mail_header_view, TRUE);
+
+       priv->attachments_view        = GTK_WIDGET(modest_attachments_view_new (NULL));
+       gtk_widget_set_no_show_all (priv->attachments_view, TRUE);
+       
        priv->sig1 = g_signal_connect (G_OBJECT(priv->gtkhtml), "link_clicked",
                                       G_CALLBACK(on_link_clicked), obj);
        priv->sig2 = g_signal_connect (G_OBJECT(priv->gtkhtml), "url_requested",
@@ -202,6 +209,7 @@ modest_msg_view_finalize (GObject *obj)
         * already dead */
        
        priv->gtkhtml = NULL;
+       priv->attachments_view = NULL;
        
        G_OBJECT_CLASS(parent_class)->finalize (obj);           
 }
@@ -225,6 +233,9 @@ modest_msg_view_new (TnyMsg *msg)
        if (priv->mail_header_view)
                gtk_box_pack_start (GTK_BOX(self), priv->mail_header_view, FALSE, FALSE, 0);
        
+       if (priv->attachments_view)
+               gtk_box_pack_start (GTK_BOX(self), priv->attachments_view, FALSE, FALSE, 0);
+
        if (priv->gtkhtml) {
                scrolled_window = gtk_scrolled_window_new (NULL, NULL);
                gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
@@ -358,68 +369,9 @@ on_url_requested (GtkWidget *widget, const gchar *uri,
        return TRUE;
 }
 
-
-/* render the attachments as hyperlinks in html */
-static gchar*
-attachments_as_html (ModestMsgView *self, TnyMsg *msg)
-{
-       ModestMsgViewPrivate *priv;
-       GString *appendix;
-       TnyList *parts;
-       TnyIterator *iter;
-       gchar *html;
-       int index = 0;
-       
-       if (!msg)
-               return NULL;
-
-       priv  = MODEST_MSG_VIEW_GET_PRIVATE (self);
-
-       parts = TNY_LIST(tny_simple_list_new());
-       tny_mime_part_get_parts (TNY_MIME_PART (msg), parts);
-       iter  = tny_list_create_iterator (parts);
-       
-       appendix= g_string_new ("");
-       
-       while (!tny_iterator_is_done(iter)) {
-               TnyMimePart *part;
-
-               ++index; /* attachment numbers are 1-based */   
-               part = TNY_MIME_PART(tny_iterator_get_current (iter));
-
-               if (tny_mime_part_is_attachment (part)) {
-
-                       const gchar *filename = tny_mime_part_get_filename(part);
-                       if (!filename)
-                               filename = _("attachment");
-
-                       g_string_append_printf (appendix, "<a href=\"%s%d\">%s</a> \n",
-                                               ATT_PREFIX, index, filename);                    
-               }
-               
-               g_object_unref (G_OBJECT(part));
-               tny_iterator_next (iter);
-       }
-       g_object_unref (G_OBJECT(iter));
-       g_object_unref (G_OBJECT(parts));
-       
-       if (appendix->len == 0) 
-               return g_string_free (appendix, TRUE);
-
-       html = g_strdup_printf ("<strong>%s:</strong> %s\n<hr>",
-                               _("Attachments"), appendix->str);                        
-       g_string_free (appendix, TRUE);
-       
-       return html;
-}
-
-
-
-
 static gboolean
 set_html_message (ModestMsgView *self, TnyMimePart *tny_body, TnyMsg *msg)
 {
-       gchar *html_attachments;
        GtkHTMLStream *gtkhtml_stream;
        TnyStream *tny_stream;  
        ModestMsgViewPrivate *priv;
@@ -434,13 +386,6 @@ set_html_message (ModestMsgView *self, TnyMimePart *tny_body, TnyMsg *msg)
        tny_stream     = TNY_STREAM(modest_tny_stream_gtkhtml_new (gtkhtml_stream));
        tny_stream_reset (tny_stream);
 
-       html_attachments = attachments_as_html(self, msg);
-       if (html_attachments) {
-               tny_stream_write (tny_stream, html_attachments, strlen(html_attachments));
-               tny_stream_reset (tny_stream);
-               g_free (html_attachments);
-       }
-
        tny_mime_part_decode_to_stream ((TnyMimePart*)tny_body, tny_stream);
        g_object_unref (G_OBJECT(tny_stream));
        
@@ -459,7 +404,7 @@ set_text_message (ModestMsgView *self, TnyMimePart *tny_body, TnyMsg *msg)
        GtkTextIter begin, end;
        TnyStream* txt_stream, *tny_stream;
        GtkHTMLStream *gtkhtml_stream;
-       gchar *txt, *html_attachments;
+       gchar *txt;
        ModestMsgViewPrivate *priv;
                
        g_return_val_if_fail (self, FALSE);
@@ -475,14 +420,6 @@ set_text_message (ModestMsgView *self, TnyMimePart *tny_body, TnyMsg *msg)
        gtkhtml_stream = gtk_html_begin(GTK_HTML(priv->gtkhtml)); 
        tny_stream =  TNY_STREAM(modest_tny_stream_gtkhtml_new (gtkhtml_stream));
        
-       html_attachments = attachments_as_html(self, msg);
-       if (html_attachments) {
-               tny_stream_write (tny_stream, html_attachments,
-                                       strlen(html_attachments));
-               tny_stream_reset (tny_stream);
-               g_free (html_attachments);
-       }
-
        // FIXME: tinymail
        tny_mime_part_decode_to_stream ((TnyMimePart*)tny_body, txt_stream);
        tny_stream_reset (txt_stream);          
@@ -553,6 +490,8 @@ modest_msg_view_set_message (ModestMsgView *self, TnyMsg *msg)
        header = tny_msg_get_header (msg);
        tny_header_view_set_header (TNY_HEADER_VIEW (priv->mail_header_view), header);
        g_object_unref (header);
+
+       modest_attachments_view_set_message (priv->attachments_view, msg);
        
        body = modest_tny_msg_find_body_part (msg,TRUE);
        if (body) {
index f724876..0f1a3fc 100644 (file)
@@ -217,7 +217,7 @@ text_view_size_request (GtkWidget *widget,
        }
 
        priv->line_height = iter_rectangle.height;
-       
+
 }
 
 static void
@@ -240,6 +240,9 @@ modest_recpt_view_instance_init (GTypeInstance *instance, gpointer g_class)
 {
        ModestRecptViewPriv *priv = MODEST_RECPT_VIEW_GET_PRIVATE (instance);
 
+       gtk_scrolled_window_set_hadjustment (GTK_SCROLLED_WINDOW (instance), NULL);
+       gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (instance), NULL);
+
        priv->text_view = gtk_text_view_new ();
 
        gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->text_view), FALSE);
@@ -250,7 +253,6 @@ modest_recpt_view_instance_init (GTypeInstance *instance, gpointer g_class)
        gtk_text_view_set_left_margin (GTK_TEXT_VIEW (priv->text_view), 0);
        gtk_text_view_set_right_margin (GTK_TEXT_VIEW (priv->text_view), 0);
        gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (priv->text_view), FALSE);
-       gtk_drag_dest_unset (priv->text_view);
 
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (instance), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);