Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSascha Silbe <sascha@silbe.org>2009-08-24 17:20:45 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-08-25 17:08:40 (GMT)
commit85b833960ded9148fbb42e773720ba3bcb02145e (patch)
treeac74034f36475b096307b091e78547aeb4f0eea7 /src
parent1f7d0394680aca0eabd9e6451b98bb141cd71c71 (diff)
add technical details to details view in Journal
Diffstat (limited to 'src')
-rw-r--r--src/jarabe/journal/expandedentry.py36
-rw-r--r--src/jarabe/journal/model.py15
2 files changed, 51 insertions, 0 deletions
diff --git a/src/jarabe/journal/expandedentry.py b/src/jarabe/journal/expandedentry.py
index 88c0b41..924f872 100644
--- a/src/jarabe/journal/expandedentry.py
+++ b/src/jarabe/journal/expandedentry.py
@@ -17,6 +17,7 @@
import logging
from gettext import gettext as _
import StringIO
+import time
import hippo
import cairo
@@ -29,6 +30,7 @@ from sugar.graphics.icon import CanvasIcon
from sugar.graphics.xocolor import XoColor
from sugar.graphics.entry import CanvasEntry
from sugar.graphics.canvastextview import CanvasTextView
+from sugar.util import format_size
from jarabe.journal.keepicon import KeepIcon
from jarabe.journal.palettes import ObjectPalette, BuddyPalette
@@ -118,6 +120,9 @@ class ExpandedEntry(hippo.CanvasBox):
self._preview = self._create_preview()
first_column.append(self._preview)
+ technical_box = self._create_technical()
+ first_column.append(technical_box)
+
# Second column
description_box, self._description = self._create_description()
@@ -216,6 +221,37 @@ class ExpandedEntry(hippo.CanvasBox):
box.append(preview_box)
return box
+ def _create_technical(self):
+ vbox = hippo.CanvasBox()
+ vbox.props.spacing = style.DEFAULT_SPACING
+
+ lines = [
+ _('Kind: %s') % (self._metadata.get('mime_type') or _('Unknown'),),
+ _('Date: %s') % (self._format_date(),),
+ _('Size: %s') % (format_size(model.get_file_size(self._metadata['uid'])),),
+ ]
+
+ for line in lines:
+ text = hippo.CanvasText(text=line,
+ font_desc=style.FONT_NORMAL.get_pango_desc())
+ text.props.color = style.COLOR_BUTTON_GREY.get_int()
+
+ if gtk.widget_get_default_direction() == gtk.TEXT_DIR_RTL:
+ text.props.xalign = hippo.ALIGNMENT_END
+ else:
+ text.props.xalign = hippo.ALIGNMENT_START
+
+ vbox.append(text)
+
+ return vbox
+
+ def _format_date(self):
+ if 'timestamp' in self._metadata:
+ timestamp = float(self._metadata['timestamp'])
+ return time.strftime('%x', time.localtime(timestamp))
+ else:
+ return _('No date')
+
def _create_buddy_list(self):
vbox = hippo.CanvasBox()
diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
index 15259bb..02ce26a 100644
--- a/src/jarabe/journal/model.py
+++ b/src/jarabe/journal/model.py
@@ -420,6 +420,21 @@ def get_file(object_id):
else:
return None
+def get_file_size(object_id):
+ """Return the file size for an object
+ """
+ logging.debug('get_file_size %r', object_id)
+ if os.path.exists(object_id):
+ return os.stat(object_id).st_size
+
+ file_path = dbus_helpers.get_filename(object_id)
+ if file_path:
+ size = os.stat(file_path).st_size
+ os.remove(file_path)
+ return size
+
+ return 0
+
def get_unique_values(key):
"""Returns a list with the different values a property has taken
"""