Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrés Ambrois <andresambrois@gmail.com>2010-05-23 06:50:01 (GMT)
committer Andrés Ambrois <andresambrois@gmail.com>2010-08-24 20:30:10 (GMT)
commit6099b087c80d7fb80856d4e157f8743ce74ec922 (patch)
tree66fd37cc9016354ae5a62c24f9a2a80c28571a62
parent48c2eeaf5d3007f0970a0f31745efe22063c4465 (diff)
Add a filesize column to the journal list model
This will make it easy to display the current sorting column by associating a cell renderer with it.
-rw-r--r--src/jarabe/journal/listmodel.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/jarabe/journal/listmodel.py b/src/jarabe/journal/listmodel.py
index 07f8544..79ed27d 100644
--- a/src/jarabe/journal/listmodel.py
+++ b/src/jarabe/journal/listmodel.py
@@ -19,6 +19,8 @@ import logging
import simplejson
import gobject
import gtk
+import time
+from gettext import gettext as _
from sugar.graphics.xocolor import XoColor
from sugar.graphics import style
@@ -48,18 +50,20 @@ class ListModel(gtk.GenericTreeModel, gtk.TreeDragSource):
COLUMN_ICON = 2
COLUMN_ICON_COLOR = 3
COLUMN_TITLE = 4
- COLUMN_DATE = 5
- COLUMN_PROGRESS = 6
- COLUMN_BUDDY_1 = 7
- COLUMN_BUDDY_2 = 8
- COLUMN_BUDDY_3 = 9
+ COLUMN_TIMESTAMP = 5
+ COLUMN_FILESIZE = 6
+ COLUMN_PROGRESS = 7
+ COLUMN_BUDDY_1 = 8
+ COLUMN_BUDDY_2 = 9
+ COLUMN_BUDDY_3 = 10
_COLUMN_TYPES = {COLUMN_UID: str,
COLUMN_FAVORITE: bool,
COLUMN_ICON: str,
COLUMN_ICON_COLOR: object,
COLUMN_TITLE: str,
- COLUMN_DATE: str,
+ COLUMN_TIMESTAMP: str,
+ COLUMN_FILESIZE: str,
COLUMN_PROGRESS: int,
COLUMN_BUDDY_1: object,
COLUMN_BUDDY_3: object,
@@ -141,6 +145,20 @@ class ListModel(gtk.GenericTreeModel, gtk.TreeDragSource):
timestamp = int(metadata.get('timestamp', 0))
self._cached_row.append(util.timestamp_to_elapsed_string(timestamp))
+ creation_time = metadata.get('creation_time')
+ if creation_time is not None:
+ self._cached_row.append(
+ util.timestamp_to_elapsed_string(creation_time))
+ else:
+ self._cached_row.append(_('Unknown'))
+
+ try:
+ size = int(metadata.get('filesize'))
+ except (TypeError, ValueError):
+ self._cached_row.append(_('Unknown'))
+ else:
+ self._cached_row.append(util.format_size(size))
+
self._cached_row.append(int(metadata.get('progress', 100)))
if metadata.get('buddies', ''):