コード例 #1
0
ファイル: expandedentry.py プロジェクト: nemesiscodex/jarabe
    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(
                int(
                    self._metadata.get(
                        'filesize', 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
コード例 #2
0
ファイル: listmodel.py プロジェクト: nemesiscodex/jarabe
    def on_get_value(self, index, column):
        if self.view_is_resizing:
            return None

        if index == self._last_requested_index:
            return self._cached_row[column]

        if index >= self._result_set.length:
            return None

        self._result_set.seek(index)
        metadata = self._result_set.read()

        self._last_requested_index = index
        self._cached_row = []
        self._cached_row.append(metadata['uid'])
        self._cached_row.append(metadata.get('keep', '0') == '1')
        self._cached_row.append(misc.get_icon_name(metadata))

        if misc.is_activity_bundle(metadata):
            xo_color = XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(),
                                          style.COLOR_TRANSPARENT.get_svg()))
        else:
            xo_color = misc.get_icon_color(metadata)
        self._cached_row.append(xo_color)

        title = gobject.markup_escape_text(metadata.get(
            'title', _('Untitled')))
        self._cached_row.append('<b>%s</b>' % (title, ))

        try:
            timestamp = float(metadata.get('timestamp', 0))
        except (TypeError, ValueError):
            timestamp_content = _('Unknown')
        else:
            timestamp_content = util.timestamp_to_elapsed_string(timestamp)
        self._cached_row.append(timestamp_content)

        try:
            creation_time = float(metadata.get('creation_time'))
        except (TypeError, ValueError):
            self._cached_row.append(_('Unknown'))
        else:
            self._cached_row.append(
                util.timestamp_to_elapsed_string(float(creation_time)))

        try:
            size = int(metadata.get('filesize'))
        except (TypeError, ValueError):
            size = None
        self._cached_row.append(util.format_size(size))

        try:
            progress = int(float(metadata.get('progress', 100)))
        except (TypeError, ValueError):
            progress = 100
        self._cached_row.append(progress)

        buddies = []
        if metadata.get('buddies'):
            try:
                buddies = simplejson.loads(metadata['buddies']).values()
            except simplejson.decoder.JSONDecodeError, exception:
                logging.warning('Cannot decode buddies for %r: %s',
                                metadata['uid'], exception)