def _create_icon(self): icon = CanvasIcon(file_name=misc.get_icon_name(self._metadata)) icon.connect_after('activate', self.__icon_activate_cb) if misc.is_activity_bundle(self._metadata): xo_color = XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(), style.COLOR_TRANSPARENT.get_svg())) else: xo_color = misc.get_icon_color(self._metadata) icon.props.xo_color = xo_color icon.set_palette(ObjectPalette(self._journalactivity, self._metadata)) return icon
def do_get_value(self, iterator, column): if self.view_is_resizing: return None index = iterator.user_data 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() metadata.update(self._updated_entries.get(metadata['uid'], {})) 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 = json.loads(metadata['buddies']).values() except json.decoder.JSONDecodeError, exception: logging.warning('Cannot decode buddies for %r: %s', metadata['uid'], exception)
def do_get_value(self, iterator, column): if self.view_is_resizing: return None index = iterator.user_data 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() metadata.update(self._updated_entries.get(metadata['uid'], {})) 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 = json.loads(metadata['buddies']).values() except json.decoder.JSONDecodeError as exception: logging.warning('Cannot decode buddies for %r: %s', metadata['uid'], exception) if not isinstance(buddies, list): logging.warning('Content of buddies for %r is not a list: %r', metadata['uid'], buddies) buddies = [] for n_ in xrange(0, 3): if buddies: try: nick, color = buddies.pop(0) except (AttributeError, ValueError) as exception: logging.warning('Malformed buddies for %r: %s', metadata['uid'], exception) else: self._cached_row.append([nick, XoColor(color)]) continue self._cached_row.append(None) return self._cached_row[column]
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)