From def49facd34182305e5d8c1ea273c0992aa90af0 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: =?UTF-8?q?Andr=C3=A9s=20Ambrois?= Date: Sun, 23 May 2010 04:44:04 -0300 Subject: [PATCH v2 10/10] Add ctime property to the journal model. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andrés Ambrois --- src/jarabe/journal/listmodel.py | 22 +++++++++++++++++----- src/jarabe/journal/model.py | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/jarabe/journal/listmodel.py b/src/jarabe/journal/listmodel.py index 135dc95..c07d9e1 100644 --- a/src/jarabe/journal/listmodel.py +++ b/src/jarabe/journal/listmodel.py @@ -19,6 +19,7 @@ import logging import simplejson import gobject import gtk +import time from sugar.graphics.xocolor import XoColor from sugar.graphics import style @@ -31,6 +32,8 @@ DS_DBUS_SERVICE = 'org.laptop.sugar.DataStore' DS_DBUS_INTERFACE = 'org.laptop.sugar.DataStore' DS_DBUS_PATH = '/org/laptop/sugar/DataStore' +CTIME_FORMAT = '%Y-%m-%dT%H:%M:%S' + class ListModel(gtk.GenericTreeModel, gtk.TreeDragSource): __gtype_name__ = 'JournalListModel' @@ -49,11 +52,12 @@ class ListModel(gtk.GenericTreeModel, gtk.TreeDragSource): COLUMN_ICON_COLOR = 3 COLUMN_TITLE = 4 COLUMN_TIMESTAMP = 5 - COLUMN_FILESIZE = 6 - COLUMN_PROGRESS = 7 - COLUMN_BUDDY_1 = 8 - COLUMN_BUDDY_2 = 9 - COLUMN_BUDDY_3 = 10 + COLUMN_CTIME = 6 + COLUMN_FILESIZE = 7 + COLUMN_PROGRESS = 8 + COLUMN_BUDDY_1 = 9 + COLUMN_BUDDY_2 = 10 + COLUMN_BUDDY_3 = 11 _COLUMN_TYPES = {COLUMN_UID: str, COLUMN_FAVORITE: bool, @@ -61,6 +65,7 @@ class ListModel(gtk.GenericTreeModel, gtk.TreeDragSource): COLUMN_ICON_COLOR: object, COLUMN_TITLE: str, COLUMN_TIMESTAMP: str, + COLUMN_CTIME: str, COLUMN_FILESIZE: str, COLUMN_PROGRESS: int, COLUMN_BUDDY_1: object, @@ -143,6 +148,13 @@ class ListModel(gtk.GenericTreeModel, gtk.TreeDragSource): timestamp = int(metadata.get('timestamp', 0)) self._cached_row.append(util.timestamp_to_elapsed_string(timestamp)) + ctime = metadata.get('ctime') + if ctime: + ctime = time.mktime(time.strptime(ctime, CTIME_FORMAT)) + else: + ctime = 0 + self._cached_row.append(util.timestamp_to_elapsed_string(ctime)) + size = int(metadata.get('filesize', 0)) self._cached_row.append(util.format_size(size)) diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py index 4fd81ac..ae77e72 100644 --- a/src/jarabe/journal/model.py +++ b/src/jarabe/journal/model.py @@ -37,7 +37,7 @@ DS_DBUS_INTERFACE = 'org.laptop.sugar.DataStore' DS_DBUS_PATH = '/org/laptop/sugar/DataStore' # Properties the journal cares about. -PROPERTIES = ['uid', 'title', 'mtime', 'timestamp', 'filesize', +PROPERTIES = ['uid', 'title', 'mtime', 'timestamp', 'ctime', 'filesize', 'keep', 'buddies', 'icon-color', 'mime_type', 'progress', 'activity', 'mountpoint', 'activity_id', 'bundle_id'] -- 1.7.0.4