Ticket #1215: 0001-add-technical-details-to-details-view-in-Journal.patch

File 0001-add-technical-details-to-details-view-in-Journal.patch, 3.4 KB (added by sascha_silbe, 13 years ago)

add technical details to details view in Journal (sugar-datastore change obsolete now)

  • src/jarabe/journal/expandedentry.py

    From 50197627605391e120ba174f0ca62975cf2c9d32 Mon Sep 17 00:00:00 2001
    From: Sascha Silbe <sascha@silbe.org>
    Date: Mon, 24 Aug 2009 19:20:45 +0200
    Subject: [PATCH] add technical details to details view in Journal
    
    ---
     src/jarabe/journal/expandedentry.py |   36 +++++++++++++++++++++++++++++++++++
     src/jarabe/journal/model.py         |   15 ++++++++++++++
     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 b  
    1717import logging
    1818from gettext import gettext as _
    1919import StringIO
     20import time
    2021
    2122import hippo
    2223import cairo
    from sugar.graphics.icon import CanvasIcon 
    2930from sugar.graphics.xocolor import XoColor
    3031from sugar.graphics.entry import CanvasEntry
    3132from sugar.graphics.canvastextview import CanvasTextView
     33from sugar.util import format_size
    3234
    3335from jarabe.journal.keepicon import KeepIcon
    3436from jarabe.journal.palettes import ObjectPalette, BuddyPalette
    class ExpandedEntry(hippo.CanvasBox): 
    118120        self._preview = self._create_preview()
    119121        first_column.append(self._preview)
    120122
     123        technical_box = self._create_technical()
     124        first_column.append(technical_box)
     125
    121126        # Second column
    122127
    123128        description_box, self._description = self._create_description()
    class ExpandedEntry(hippo.CanvasBox): 
    216221        box.append(preview_box)
    217222        return box
    218223
     224    def _create_technical(self):
     225        vbox = hippo.CanvasBox()
     226        vbox.props.spacing = style.DEFAULT_SPACING
     227
     228        lines = [
     229            _('Kind: %s') % (self._metadata.get('mime_type') or _('Unknown'),),
     230            _('Date: %s') % (self._format_date(),),
     231            _('Size: %s') % (format_size(model.get_file_size(self._metadata['uid'])),),
     232        ]
     233
     234        for line in lines:
     235            text = hippo.CanvasText(text=line,
     236                font_desc=style.FONT_NORMAL.get_pango_desc())
     237            text.props.color = style.COLOR_BUTTON_GREY.get_int()
     238
     239            if gtk.widget_get_default_direction() == gtk.TEXT_DIR_RTL:
     240                text.props.xalign = hippo.ALIGNMENT_END
     241            else:
     242                text.props.xalign = hippo.ALIGNMENT_START
     243
     244            vbox.append(text)
     245
     246        return vbox
     247
     248    def _format_date(self):
     249        if 'timestamp' in self._metadata:
     250            timestamp = float(self._metadata['timestamp'])
     251            return time.strftime('%x', time.localtime(timestamp))
     252        else:
     253            return _('No date')
     254
    219255    def _create_buddy_list(self):
    220256
    221257        vbox = hippo.CanvasBox()
  • src/jarabe/journal/model.py

    diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
    index 506c8ac..5668dc5 100644
    a b def get_file(object_id): 
    394394        else:
    395395            return None
    396396
     397def get_file_size(object_id):
     398    """Return the file size for an object
     399    """
     400    logging.debug('get_file_size %r', object_id)
     401    if os.path.exists(object_id):
     402        return os.stat(object_id).st_size
     403
     404    file_path = dbus_helpers.get_filename(object_id)
     405    if file_path:
     406        size = os.stat(file_path).st_size
     407        os.remove(file_path)
     408        return size
     409
     410    return 0
     411
    397412def get_unique_values(key):
    398413    """Returns a list with the different values a property has taken
    399414    """