[geary/wip/765516-gtk-widget-conversation-viewer: 26/174] Add attachment icon back to the message viewer.



commit 89ec695936221dc001e99b4f5b5622ee7eb3c716
Author: Michael James Gratton <mike vee net>
Date:   Fri Apr 15 02:24:52 2016 +1000

    Add attachment icon back to the message viewer.

 .../conversation-viewer/conversation-message.vala  |   54 ++++++++++---------
 ui/conversation-message.ui                         |   13 +++++
 2 files changed, 41 insertions(+), 26 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-message.vala 
b/src/client/conversation-viewer/conversation-message.vala
index 3da90eb..2876c34 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -80,6 +80,8 @@ public class ConversationMessage : Gtk.Box {
     private Gtk.Box date_header;
 
     [GtkChild]
+    private Gtk.Image attachment_icon;
+    [GtkChild]
     private Gtk.Button flag_button;
     [GtkChild]
     private Gtk.MenuButton message_menubutton;
@@ -193,9 +195,9 @@ public class ConversationMessage : Gtk.Box {
         //  get_style_context().add_class("sent");
         // }
 
-        // // Set attachment icon and add the attachments container if there are displayed attachments.
-        // int displayed = displayed_attachments(email);
-        // set_attachment_icon(div_message, displayed > 0);
+        // Set attachment icon and add the attachments container if there are displayed attachments.
+        int displayed = displayed_attachments(email);
+        attachment_icon.set_visible(displayed > 0);
         // if (displayed > 0) {
         //     insert_attachments(div_message, email.attachments);
         // }
@@ -987,32 +989,32 @@ public class ConversationMessage : Gtk.Box {
         // messages in he current convo for this sender
     }
     
-    // private bool should_show_attachment(Geary.Attachment attachment) {
-    //     // if displayed inline, don't include in attachment list
-    //     if (attachment.content_id in inlined_content_ids)
-    //         return false;
+    private int displayed_attachments(Geary.Email email) {
+        int ret = 0;
+        foreach (Geary.Attachment attachment in email.attachments) {
+            if (should_show_attachment(attachment)) {
+                ret++;
+            }
+        }
+        return ret;
+    }
+    
+    private bool should_show_attachment(Geary.Attachment attachment) {
+        // if displayed inline, don't include in attachment list
+        if (attachment.content_id in inlined_content_ids)
+            return false;
         
-    //     switch (attachment.content_disposition.disposition_type) {
-    //         case Geary.Mime.DispositionType.ATTACHMENT:
-    //             return true;
+        switch (attachment.content_disposition.disposition_type) {
+            case Geary.Mime.DispositionType.ATTACHMENT:
+                return true;
             
-    //         case Geary.Mime.DispositionType.INLINE:
-    //             return !is_content_type_supported_inline(attachment.content_type);
+            case Geary.Mime.DispositionType.INLINE:
+                return !is_content_type_supported_inline(attachment.content_type);
             
-    //         default:
-    //             assert_not_reached();
-    //     }
-    // }
-    
-    // private int displayed_attachments(Geary.Email email) {
-    //     int ret = 0;
-    //     foreach (Geary.Attachment attachment in email.attachments) {
-    //         if (should_show_attachment(attachment)) {
-    //             ret++;
-    //         }
-    //     }
-    //     return ret;
-    // }
+            default:
+                assert_not_reached();
+        }
+    }
     
     // private void insert_attachments(WebKit.DOM.HTMLElement email_container,
     //     Gee.List<Geary.Attachment> attachments) {
diff --git a/ui/conversation-message.ui b/ui/conversation-message.ui
index cbfb0d0..3dcf169 100644
--- a/ui/conversation-message.ui
+++ b/ui/conversation-message.ui
@@ -398,6 +398,19 @@
             <property name="spacing">1</property>
             <property name="homogeneous">True</property>
             <child>
+              <object class="GtkImage" id="attachment_icon">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="tooltip_text" translatable="yes">This message has attachments</property>
+                <property name="icon_name">mail-attachment-symbolic</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkButton" id="flag_button">
                 <property name="visible">True</property>
                 <property name="sensitive">False</property>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]