[Xfce4-commits] <postler:master> Remove size and attachment columns

Christian Dywan noreply at xfce.org
Wed May 18 02:54:01 CEST 2011


Updating branch refs/heads/master
         to fdca25e73454cab6d656cc70edbd6fed02f29c4e (commit)
       from 2121ba996121147f0845aa045f0e7a478a8242db (commit)

commit fdca25e73454cab6d656cc70edbd6fed02f29c4e
Author: Christian Dywan <christian at twotoasts.de>
Date:   Tue May 17 22:22:57 2011 +0200

    Remove size and attachment columns

 postler/postler-messages.vala |   64 ++++++++--------------------------------
 1 files changed, 13 insertions(+), 51 deletions(-)

diff --git a/postler/postler-messages.vala b/postler/postler-messages.vala
index 6f03615..4ee1433 100644
--- a/postler/postler-messages.vala
+++ b/postler/postler-messages.vala
@@ -19,7 +19,6 @@ public class Postler.Messages : Gtk.TreeView {
     public Postler.Content content { get; set; }
     public bool hide_read { get; set; }
     public bool rich_rows { get; set; default = true; }
-    public bool show_attachments { get; set; default = false; }
 
     public string? location { get; private set; }
     public AccountInfo account_info { get; private set; }
@@ -34,11 +33,9 @@ public class Postler.Messages : Gtk.TreeView {
     enum Columns {
         FLAGGED,
         STATUS,
-        ATTACHMENT,
         SUBJECT,
         WEIGHT,
         FROM,
-        SIZE,
         LOCATION,
         TIMESTAMP
     }
@@ -191,19 +188,6 @@ public class Postler.Messages : Gtk.TreeView {
         }
     }
 
-    void render_size (Gtk.TreeViewColumn column, Gtk.CellRenderer cell,
-        Gtk.TreeModel model, Gtk.TreeIter iter) {
-        var renderer = cell as Gtk.CellRendererText;
-
-        if (rich_rows)
-            renderer.text = "";
-        else {
-            int64 size;
-            model.get (iter, Columns.SIZE, out size);
-            renderer.text = format_size_for_display (size);
-        }
-    }
-
     void renderer_flag_toggled (Gtk.CellRendererToggle renderer,
                                 string                 path) {
         Gtk.TreeIter sort_iter = Gtk.TreeIter ();
@@ -250,9 +234,9 @@ public class Postler.Messages : Gtk.TreeView {
         drag_data_get.connect (on_drag_data_get);
 
         this.accounts = accounts;
-        store = new Gtk.TreeStore (9, typeof (bool), typeof (string),
-            typeof (string), typeof (string), typeof (int), typeof (string),
-            typeof (int64), typeof (string), typeof (int64));
+        store = new Gtk.TreeStore (7, typeof (bool), typeof (string),
+            typeof (string), typeof (int), typeof (string),
+            typeof (string), typeof (int64));
         sort = new Gtk.TreeModelSort.with_model (store);
         set_model (sort);
         set_search_equal_func (search_inline);
@@ -275,21 +259,15 @@ public class Postler.Messages : Gtk.TreeView {
         var renderer_text = new Gtk.CellRendererText ();
         column.pack_start (renderer_text, true);
         column.set_cell_data_func (renderer_text, render_subject);
-        var renderer_icon = new Gtk.CellRendererPixbuf ();
-        column.pack_start (renderer_icon, false);
-        column.add_attribute (renderer_icon, "stock-id", Columns.ATTACHMENT);
         insert_column (column, -1);
         insert_column_with_data_func (-1, _("From"),
             new Gtk.CellRendererText (), render_from);
         insert_column_with_data_func (-1, _("Date"),
             new Gtk.CellRendererText (), render_date);
-        insert_column_with_data_func (-1, _("Size"),
-            new Gtk.CellRendererText (), render_size);
 
         if (rich_rows) {
             get_column (3).visible = false;
             get_column (4).visible = false;
-            get_column (5).visible = false;
         }
 
         unowned Gtk.BindingSet binding_set = Gtk.BindingSet.by_class (get_class ());
@@ -514,19 +492,11 @@ public class Postler.Messages : Gtk.TreeView {
     private struct Message {
         string location;
         string subject;
-        public string get_subject () {
-            return subject != null ? subject : _("No subject");
-        }
         string status;
         int font_weight;
         bool flagged;
         string from;
-        public string get_from () {
-            return from != null ? from : _("Unknown");
-        }
         int64 timestamp;
-        int64 size;
-        string attachment;
     }
 
     private Message? read_message (File contents, bool folder_new) {
@@ -555,7 +525,7 @@ public class Postler.Messages : Gtk.TreeView {
         message.from = null;
         message.timestamp = 0;
 
-        string content_type = show_attachments ? null : "";
+        string content_type = "";
         try {
             var stream = new DataInputStream (contents.read (null));
             string line;
@@ -623,16 +593,15 @@ public class Postler.Messages : Gtk.TreeView {
                 if (skip)
                     return null;
             }
+            if (message.subject == null)
+                message.subject = _("No subject");
+            if (message.from == null)
+                message.from = _("Unknown");
         } catch (GLib.Error contents_error) {
             GLib.critical (_("Failed to read message \"%s\": %s"),
                 contents.get_path (), contents_error.message);
         }
 
-        message.attachment = null;
-        if (show_attachments
-         && content_type != null
-         && content_type.has_prefix ("multipart/mixed"))
-            message.attachment = STOCK_MAIL_ATTACHMENT;
         return message;
     }
 
@@ -695,8 +664,7 @@ public class Postler.Messages : Gtk.TreeView {
                 FileEnumerator folder_enumerator;
                 try {
                     folder_enumerator = folder_dir.enumerate_children (
-                        FILE_ATTRIBUTE_STANDARD_NAME + "," +
-                        FILE_ATTRIBUTE_STANDARD_SIZE, 0, null);
+                        FILE_ATTRIBUTE_STANDARD_NAME, 0, null);
                     } catch (GLib.Error enumerator_error) {
                         /* Empty accounts can't be enumerated. */
                         continue;
@@ -721,17 +689,14 @@ public class Postler.Messages : Gtk.TreeView {
                     var message = read_message (message_path, folder_new);
                     if (message == null)
                         continue;
-                    message.size = info.get_size ();
 
                     store.insert_with_values (null, null, 0,
                         Columns.FLAGGED, message.flagged,
                         Columns.STATUS, message.status,
-                        Columns.ATTACHMENT, message.attachment,
-                        Columns.SUBJECT, message.get_subject (),
+                        Columns.SUBJECT, message.subject,
                         Columns.WEIGHT, message.font_weight,
-                        Columns.FROM, message.get_from (),
+                        Columns.FROM, message.from,
                         Columns.TIMESTAMP, message.timestamp,
-                        Columns.SIZE, message.size,
                         Columns.LOCATION, message.location);
                 }
             }
@@ -881,17 +846,14 @@ public class Postler.Messages : Gtk.TreeView {
             var message = read_message (file, folder_new);
             if (message == null)
                 break;
-            message.size = 0; /* FIXME: get file size */
             bool scroll = vadjustment.value == 0;
             store.insert_with_values (null, null, 0,
                 Columns.FLAGGED, message.flagged,
                 Columns.STATUS, message.status,
-                Columns.ATTACHMENT, message.attachment,
-                Columns.SUBJECT, message.get_subject (),
+                Columns.SUBJECT, message.subject,
                 Columns.WEIGHT, message.font_weight,
-                Columns.FROM, message.get_from (),
+                Columns.FROM, message.from,
                 Columns.TIMESTAMP, message.timestamp,
-                Columns.SIZE, message.size,
                 Columns.LOCATION, message.location);
             if (scroll)
                 vadjustment.value = 0;



More information about the Xfce4-commits mailing list