Exemplo n.º 1
0
    def _add_activity(self, activity_info):
        if activity_info.get_bundle_id() == 'org.laptop.JournalActivity':
            return

        timestamp = activity_info.get_installation_time()
        version = activity_info.get_activity_version()

        registry = bundleregistry.get_registry()
        favorites = []
        for i in range(desktop.get_number_of_views()):
            favorites.append(
                registry.is_bundle_favorite(activity_info.get_bundle_id(),
                                            version, i))

        tag_list = activity_info.get_tags()
        if tag_list is None or not tag_list:
            title = '<b>%s</b>' % activity_info.get_name()
        else:
            tags = ', '.join(tag_list)
            title = '<b>%s</b>\n' \
                    '<span style="italic" weight="light">%s</span>' % \
                (activity_info.get_name(), tags)

        model_list = [activity_info.get_bundle_id()]
        for i in range(desktop.get_number_of_views()):
            model_list.append(favorites[i])
        model_list.append(activity_info.get_icon())
        model_list.append(title)
        model_list.append(version)
        model_list.append(_('Version %s') % version)
        model_list.append(int(timestamp))
        model_list.append(util.timestamp_to_elapsed_string(timestamp))
        self._model.append(model_list)
Exemplo n.º 2
0
    def _add_activity(self, activity_info):
        if activity_info.get_bundle_id() == "org.laptop.JournalActivity":
            return

        timestamp = activity_info.get_installation_time()
        version = activity_info.get_activity_version()

        registry = bundleregistry.get_registry()
        favorites = []
        for i in range(desktop.get_number_of_views()):
            favorites.append(registry.is_bundle_favorite(activity_info.get_bundle_id(), version, i))

        tag_list = activity_info.get_tags()
        if tag_list is None or not tag_list:
            title = "<b>%s</b>" % activity_info.get_name()
        else:
            tags = ", ".join(tag_list)
            title = "<b>%s</b>\n" '<span style="italic" weight="light">%s</span>' % (activity_info.get_name(), tags)

        model_list = [activity_info.get_bundle_id()]
        for i in range(desktop.get_number_of_views()):
            model_list.append(favorites[i])
        model_list.append(activity_info.get_icon())
        model_list.append(title)
        model_list.append(version)
        model_list.append(_("Version %s") % version)
        model_list.append(int(timestamp))
        model_list.append(util.timestamp_to_elapsed_string(timestamp))
        self._model.append(model_list)
Exemplo n.º 3
0
    def add_separator(self, timestamp):
        '''Add whitespace and timestamp between chat sessions.'''
        time_with_current_year = \
            (time.localtime(time.time())[0], ) + \
            time.strptime(timestamp, '%b %d %H:%M:%S')[1:]

        timestamp_seconds = time.mktime(time_with_current_year)
        if timestamp_seconds > time.time():
            time_with_previous_year = \
                (time.localtime(time.time())[0] - 1, ) + \
                time.strptime(timestamp, '%b %d %H:%M:%S')[1:]
            timestamp_seconds = time.mktime(time_with_previous_year)

        message = TextBox(self,
                          style.COLOR_BUTTON_GREY, style.COLOR_BUTTON_GREY,
                          style.COLOR_WHITE, style.COLOR_BUTTON_GREY, False,
                          None, timestamp_to_elapsed_string(timestamp_seconds))
        self._message_list.append(message)
        box = Gtk.HBox()
        align = Gtk.Alignment.new(
            xalign=0.5, yalign=0.0, xscale=0.0, yscale=0.0)
        box.pack_start(align, True, True, 0)
        align.show()
        align.add(message)
        message.show()
        self._conversation.attach(box, 0, self._row_counter, 1, 1)
        box.show()
        self._row_counter += 1
        self.add_log_timestamp(timestamp)
        self._last_msg_sender = None
Exemplo n.º 4
0
    def _add_activity(self, activity_info):
        if activity_info.get_bundle_id() == 'org.laptop.JournalActivity':
            return

        timestamp = activity_info.get_installation_time()
        version = activity_info.get_activity_version()

        registry = bundleregistry.get_registry()
        favorite = registry.is_bundle_favorite(activity_info.get_bundle_id(),
                                               version)

        tag_list = activity_info.get_tags()
        if tag_list is None or not tag_list:
            title = '<b>%s</b>' % activity_info.get_name()
        else:
            tags = ', '.join(tag_list)
            title = '<b>%s</b>\n' \
                    '<span style="italic" weight="light">%s</span>' % \
                            (activity_info.get_name(), tags)

        self._model.append([activity_info.get_bundle_id(),
                            favorite,
                            activity_info.get_icon(),
                            title,
                            version,
                            _('Version %s') % version,
                            int(timestamp),
                            util.timestamp_to_elapsed_string(timestamp)])
Exemplo n.º 5
0
    def _add_activity(self, activity_info):
        if activity_info.get_bundle_id() == 'org.laptop.JournalActivity':
            return

        timestamp = activity_info.get_installation_time()
        version = activity_info.get_activity_version()

        registry = bundleregistry.get_registry()
        favorite = registry.is_bundle_favorite(activity_info.get_bundle_id(),
                                               version)

        tag_list = activity_info.get_tags()
        if tag_list is None or not tag_list:
            title = '<b>%s</b>' % activity_info.get_name()
        else:
            tags = ', '.join(tag_list)
            title = '<b>%s</b>\n' \
                    '<span style="italic" weight="light">%s</span>' % \
                            (activity_info.get_name(), tags)

        self._model.append([
            activity_info.get_bundle_id(), favorite,
            activity_info.get_icon(), title, version,
            _('Version %s') % version,
            int(timestamp),
            util.timestamp_to_elapsed_string(timestamp)
        ])
Exemplo n.º 6
0
    def add_separator(self, timestamp):
        '''Add whitespace and timestamp between chat sessions.'''
        time_with_current_year = \
            (time.localtime(time.time())[0], ) + \
            time.strptime(timestamp, '%b %d %H:%M:%S')[1:]

        timestamp_seconds = time.mktime(time_with_current_year)
        if timestamp_seconds > time.time():
            time_with_previous_year = \
                (time.localtime(time.time())[0] - 1, ) + \
                time.strptime(timestamp, '%b %d %H:%M:%S')[1:]
            timestamp_seconds = time.mktime(time_with_previous_year)

        message = TextBox(self,
                          style.COLOR_BUTTON_GREY, style.COLOR_BUTTON_GREY,
                          style.COLOR_WHITE, style.COLOR_BUTTON_GREY, False,
                          None, timestamp_to_elapsed_string(timestamp_seconds))
        self._message_list.append(message)
        box = Gtk.HBox()
        align = Gtk.Alignment.new(
            xalign=0.5, yalign=0.0, xscale=0.0, yscale=0.0)
        box.pack_start(align, True, True, 0)
        align.show()
        align.add(message)
        message.show()
        self._conversation.attach(box, 0, self._row_counter, 1, 1)
        box.show()
        self._row_counter += 1
        self.add_log_timestamp(timestamp)
        self._last_msg_sender = None
Exemplo n.º 7
0
Arquivo: misc.py Projeto: erikos/sugar
def get_date(metadata):
    """ Convert from a string in iso format to a more human-like format. """
    if "timestamp" in metadata:
        try:
            timestamp = float(metadata["timestamp"])
        except (TypeError, ValueError):
            logging.warning("Invalid timestamp: %r", metadata["timestamp"])
        else:
            return util.timestamp_to_elapsed_string(timestamp)

    if "mtime" in metadata:
        try:
            ti = time.strptime(metadata["mtime"], "%Y-%m-%dT%H:%M:%S")
        except (TypeError, ValueError):
            logging.warning("Invalid mtime: %r", metadata["mtime"])
        else:
            return util.timestamp_to_elapsed_string(time.mktime(ti))

    return _("No date")
Exemplo n.º 8
0
Arquivo: misc.py Projeto: edudev/sugar
def get_date(metadata):
    """ Convert from a string in iso format to a more human-like format. """
    if 'timestamp' in metadata:
        try:
            timestamp = float(metadata['timestamp'])
        except (TypeError, ValueError):
            logging.warning('Invalid timestamp: %r', metadata['timestamp'])
        else:
            return util.timestamp_to_elapsed_string(timestamp)

    if 'mtime' in metadata:
        try:
            ti = time.strptime(metadata['mtime'], '%Y-%m-%dT%H:%M:%S')
        except (TypeError, ValueError):
            logging.warning('Invalid mtime: %r', metadata['mtime'])
        else:
            return util.timestamp_to_elapsed_string(time.mktime(ti))

    return _('No date')
Exemplo n.º 9
0
def get_date(metadata):
    """ Convert from a string in iso format to a more human-like format. """
    if 'timestamp' in metadata:
        try:
            timestamp = float(metadata['timestamp'])
        except (TypeError, ValueError):
            logging.warning('Invalid timestamp: %r', metadata['timestamp'])
        else:
            return util.timestamp_to_elapsed_string(timestamp)

    if 'mtime' in metadata:
        try:
            ti = time.strptime(metadata['mtime'], '%Y-%m-%dT%H:%M:%S')
        except (TypeError, ValueError):
            logging.warning('Invalid mtime: %r', metadata['mtime'])
        else:
            return util.timestamp_to_elapsed_string(time.mktime(ti))

    return _('No date')
Exemplo n.º 10
0
    def _add_columns(self):

        self.cell_icon = CellRendererActivityIcon(self.tree_view)

        column = Gtk.TreeViewColumn()
        column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        column.props.fixed_width = self.cell_icon.props.width
        column.pack_start(self.cell_icon, True)
        column.add_attribute(self.cell_icon, 'file-name',
                             COLUMN_MIME)
        #column.add_attribute(self.cell_icon, 'xo-color',
        #                     COLUMN_MIME)
        self.tree_view.append_column(column)

        self.cell_title = Gtk.CellRendererText()
        self.cell_title.props.ellipsize = Pango.EllipsizeMode.MIDDLE
        self.cell_title.props.ellipsize_set = True

        self._title_column = Gtk.TreeViewColumn()
        self._title_column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        self._title_column.props.expand = True
        self._title_column.props.clickable = True
        self._title_column.pack_start(self.cell_title, True)
        self._title_column.add_attribute(self.cell_title, 'markup',
                                         COLUMN_TITLE)
        self.tree_view.append_column(self._title_column)

        cell_text = Gtk.CellRendererText()
        cell_text.props.xalign = 1

        # Measure the required width for a date in the form of "10 hours, 10
        # minutes ago"
        timestamp = time.time() - 10 * 60 - 10 * 60 * 60
        date = util.timestamp_to_elapsed_string(timestamp)
        date_width = self._get_width_for_string(date)

        self.sort_column = Gtk.TreeViewColumn()
        self.sort_column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        self.sort_column.props.fixed_width = date_width
        self.sort_column.set_alignment(1)
        self.sort_column.props.resizable = True
        self.sort_column.props.clickable = True
        self.sort_column.pack_start(cell_text, True)
        self.sort_column.add_attribute(cell_text, 'text',
                                       COLUMN_TIMESTAMP)
        self.tree_view.append_column(self.sort_column)
Exemplo n.º 11
0
    def __bookmark_icon_query_tooltip_cb(self, widget, x, y, keyboard_mode,
                                         tip, bookmark):
        tooltip_header = bookmark.get_note_title()
        tooltip_body = bookmark.get_note_body()
        time = timestamp_to_elapsed_string(bookmark.timestamp)
        #TRANS: This goes like Bookmark added by User 5 days ago
        #TRANS: (the elapsed string gets translated automatically)
        tooltip_footer = (_('Bookmark added by %(user)s %(time)s') % {
            'user': bookmark.nick.decode('utf-8'),
            'time': time.decode('utf-8')
        })

        vbox = Gtk.VBox()

        l = Gtk.Label('<big>%s</big>' % tooltip_header)
        l.set_use_markup(True)
        l.set_width_chars(40)
        l.set_line_wrap(True)
        vbox.pack_start(l, False, False, 0)
        l.show()

        l = Gtk.Label('%s' % tooltip_body)
        l.set_use_markup(True)
        l.set_alignment(0, 0)
        l.set_padding(2, 6)
        l.set_width_chars(40)
        l.set_line_wrap(True)
        l.set_justify(Gtk.Justification.FILL)
        vbox.pack_start(l, True, True, 0)
        l.show()

        l = Gtk.Label('<small><i>%s</i></small>' % tooltip_footer)
        l.set_use_markup(True)
        l.set_width_chars(40)
        l.set_line_wrap(True)
        vbox.pack_start(l, False, False, 0)
        l.show()

        tip.set_custom(vbox)

        return True
Exemplo n.º 12
0
    def __bookmark_icon_query_tooltip_cb(self, widget, x, y, keyboard_mode,
                                         tip, bookmark):
        tooltip_header = bookmark.get_note_title()
        tooltip_body = bookmark.get_note_body()
        time = timestamp_to_elapsed_string(bookmark.timestamp)
        #TRANS: This goes like Bookmark added by User 5 days ago
        #TRANS: (the elapsed string gets translated automatically)
        tooltip_footer = (
            _('Bookmark added by %(user)s %(time)s')
            % {'user': bookmark.nick.decode('utf-8'),
               'time': time.decode('utf-8')})

        vbox = Gtk.VBox()

        l = Gtk.Label('<big>%s</big>' % tooltip_header)
        l.set_use_markup(True)
        l.set_width_chars(40)
        l.set_line_wrap(True)
        vbox.pack_start(l, False, False, 0)
        l.show()

        l = Gtk.Label('%s' % tooltip_body)
        l.set_use_markup(True)
        l.set_alignment(0, 0)
        l.set_padding(2, 6)
        l.set_width_chars(40)
        l.set_line_wrap(True)
        l.set_justify(Gtk.Justification.FILL)
        vbox.pack_start(l, True, True, 0)
        l.show()

        l = Gtk.Label('<small><i>%s</i></small>' % tooltip_footer)
        l.set_use_markup(True)
        l.set_width_chars(40)
        l.set_line_wrap(True)
        vbox.pack_start(l, False, False, 0)
        l.show()

        tip.set_custom(vbox)

        return True
Exemplo n.º 13
0
    def __init__(self, parent):
        Gtk.EventBox.__init__(self)

        self._reflection = parent
        self._collapse = True
        self._collapse_id = None

        self.modify_bg(
            Gtk.StateType.NORMAL, style.COLOR_WHITE.get_gdk_color())
        self._title_color = self._reflection.activity.fg_color.get_html()

        self._grid = Gtk.Grid()
        self.add(self._grid)
        self._grid.show()

        self._grid.set_row_spacing(style.DEFAULT_PADDING)
        self._grid.set_column_spacing(style.DEFAULT_SPACING)
        self._grid.set_column_homogeneous(True)
        self._grid.set_border_width(style.DEFAULT_PADDING)

        row = 0

        self._expand_button = EventIcon(icon_name='expand',
                                        pixel_size=BUTTON_SIZE)
        self._collapse_id = self._expand_button.connect('button-press-event',
                                           self._expand_cb)
        self._expand_button.set_tooltip(_('Expand'))
        self._grid.attach(self._expand_button, 0, row, 1, 1)
        self._expand_button.show()

        self._title_align = Gtk.Alignment.new(
            xalign=0, yalign=0.5, xscale=0, yscale=0)
        self._title = Gtk.TextView()
        self._title.set_size_request(ENTRY_WIDTH, -1)
        self._title.set_wrap_mode(Gtk.WrapMode.WORD)
        self._title_tag = self._title.get_buffer().create_tag(
            'title', foreground=self._title_color, weight=Pango.Weight.BOLD,
            size=12288)
        iter_text = self._title.get_buffer().get_iter_at_offset(0)
        self._title.get_buffer().insert_with_tags(
            iter_text, self._reflection.data['title'], self._title_tag)
        if self._reflection.activity.initiating:
            self._title.connect('focus-out-event', self._title_focus_out_cb)
        else:
            self._title.set_editable(False)
        self._title_align.add(self._title)
        self._title.show()
        self._grid.attach(self._title_align, 1, row, 5, 1)
        self._title_align.show()

        delete_button = EventIcon(icon_name='delete', pixel_size=BUTTON_SIZE)
        delete_button.set_tooltip(_('Delete'))
        delete_button.connect('button-press-event', self.__delete_cb)
        self._grid.attach(delete_button, 6, row, 1, 1)
        delete_button.show()

        ''' Notification that a new comment has been shared. '''
        self.notify_button = EventIcon(icon_name='chat',
                                       pixel_size=BUTTON_SIZE)
        self._grid.attach(self.notify_button, 6, row, 1, 1)
        row += 1

        self._time_align = Gtk.Alignment.new(
            xalign=0, yalign=0.5, xscale=0, yscale=0)
        self._time = Gtk.Label()
        self._time.set_size_request(ENTRY_WIDTH, -1)
        self._time.set_justify(Gtk.Justification.LEFT)
        self._time.set_use_markup(True)
        try:
            time_string = util.timestamp_to_elapsed_string(
                int(self._reflection.data['modification_time']))
        except Exception as e:
            logging.error('Could not convert modification time %s: %s' %
                          (self._reflection.data['modification_time'], e))
            self._reflection.data['modification_time'] = \
                self._reflection.data['creation_time']
            time_string = util.timestamp_to_elapsed_string(
                int(self._reflection.data['modification_time']))
        self._time.set_markup(
            '<span foreground="#808080"><small><b>%s</b></small></span>' %
            time_string)
        self._time_align.add(self._time)
        self._time.show()
        self._grid.attach(self._time_align, 1, row, 5, 1)
        self._time_align.show()
        row += 1

        label = ''
        if 'tags' in self._reflection.data:
            for tag in self._reflection.data['tags']:
                if len(label) > 0:
                    label += ', '
                label += tag
        if self._reflection.activity.initiating and label == '':
            label = _('Add a #tag')
        self._tag_align = Gtk.Alignment.new(
            xalign=0, yalign=0.5, xscale=0, yscale=0)
        self._tag_view = Gtk.TextView()
        self._tag_view.set_size_request(ENTRY_WIDTH, -1)
        self._tag_view.set_wrap_mode(Gtk.WrapMode.WORD)
        self._tag_view.get_buffer().set_text(label)
        if self._reflection.activity.initiating:
            self._tag_view.connect('focus-in-event', self._tag_focus_in_cb,
                                   _('Add a #tag'))
            self._tag_view.connect('focus-out-event', self._tags_focus_out_cb)
        else:
            self._tag_view.set_editable(False)
        self._tag_align.add(self._tag_view)
        self._tag_view.show()
        self._grid.attach(self._tag_align, 1, row, 5, 1)

        if self._reflection.activity.initiating:
            self._new_tag = EventIcon(icon_name='ok',
                                      pixel_size=BUTTON_SIZE)
            self._new_tag.connect('button-press-event',
                                  self._tag_button_cb)
            self._grid.attach(self._new_tag, 6, row, 1, 1)
        row += 1

        self._activities_align = Gtk.Alignment.new(
            xalign=0, yalign=0.5, xscale=0, yscale=0)
        self._make_activities_grid()
        self._grid.attach(self._activities_align, 1, row, 5, 1)
        self._activities_align.show()

        if self._reflection.activity.initiating:
            self._new_activity = EventIcon(icon_name='add-item',
                                           pixel_size=BUTTON_SIZE)
            self._new_activity.set_tooltip(_('Add new activity'))
            self._new_activity.connect('button-press-event',
                                       self._activity_button_cb)
            self._grid.attach(self._new_activity, 6, row, 1, 1)
            self._new_activity.show()
        row += 1

        self._stars_align = Gtk.Alignment.new(
            xalign=0, yalign=0.5, xscale=0, yscale=0)
        grid = Gtk.Grid()
        if 'stars' in self._reflection.data:
            stars = self._reflection.data['stars']
        else:
            stars = 0
        self._star_icons = []
        for i in range(NUMBER_OF_STARS):
            if i < stars:
                icon_name = 'star-filled'
            else:
                icon_name = 'star-empty'
            self._star_icons.append(EventIcon(icon_name=icon_name,
                                              pixel_size=STAR_SIZE))
            if self._reflection.activity.initiating:
                self._star_icons[-1].connect('button-press-event',
                                             self._star_button_cb, i)
            grid.attach(self._star_icons[-1], i, 0, 1, 1)
            self._star_icons[-1].show()
        self._stars_align.add(grid)
        grid.show()
        self._grid.attach(self._stars_align, 1, row, 5, 1)
        row += 1

        self._content_aligns = []
        first_text = True
        first_image = True
        self._content_we_always_show = []
        if 'content' in self._reflection.data:
            for i, item in enumerate(self._reflection.data['content']):
                # Add edit and delete buttons
                align = Gtk.Alignment.new(
                    xalign=0, yalign=0.5, xscale=0, yscale=0)
                obj = None
                if 'text' in item:
                    obj = Gtk.TextView()
                    obj.set_size_request(ENTRY_WIDTH, -1)
                    obj.set_wrap_mode(Gtk.WrapMode.WORD)

                    obj.get_buffer().set_text(item['text'])
                    if self._reflection.activity.initiating:
                        obj.connect('focus-in-event', self._text_focus_in_cb)
                        obj.connect(
                            'focus-out-event', self._text_focus_out_cb, i)
                    else:
                        obj.set_editable(False)
                    if first_text:
                        self._content_we_always_show.append(align)
                        first_text = False
                elif 'image' in item:
                    try:
                        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                            item['image'], PICTURE_WIDTH, PICTURE_HEIGHT)
                        obj = Gtk.Image.new_from_pixbuf(pixbuf)
                        if first_image:
                            self._content_we_always_show.append(align)
                            first_image = False
                    except:
                        logging.error('could not open %s' % item['image'])
                if obj is not None:
                    align.add(obj)
                    obj.show()
                    self._grid.attach(align, 1, row, 5, 1)
                    self._content_aligns.append(align)
                    row += 1

        self._row = row
        if self._reflection.activity.initiating:
            self._new_entry = Gtk.Entry()
            self._new_entry.props.placeholder_text = _('Write a reflection')
            self._new_entry.connect('activate', self._entry_activate_cb)
            self._grid.attach(self._new_entry, 1, row, 5, 1)
            self._content_we_always_show.append(self._new_entry)
            self._new_image = EventIcon(icon_name='add-picture',
                                        pixel_size=BUTTON_SIZE)
            self._new_image.set_tooltip(_('Add new image'))
            self._new_image.connect('button-press-event', self._image_button_cb)
            self._grid.attach(self._new_image, 6, row, 1, 1)
            self._content_we_always_show.append(self._new_image)

        for align in self._content_we_always_show:
            align.show()
        row += 1

        self._comment_row = row
        self._comment_aligns = []
        if 'comments' in self._reflection.data:
            for comment in self._reflection.data['comments']:
                obj = Gtk.TextView()
                obj.set_editable(False)
                obj.set_size_request(ENTRY_WIDTH, -1)
                obj.set_wrap_mode(Gtk.WrapMode.WORD)
                nick_tag = obj.get_buffer().create_tag(
                    'nick', foreground=comment['color'],
                    weight=Pango.Weight.BOLD)
                iter_text = obj.get_buffer().get_iter_at_offset(0)
                obj.get_buffer().insert_with_tags(
                    iter_text, comment['nick'] + ': ', nick_tag)
                iter_text = obj.get_buffer().get_end_iter()
                obj.get_buffer().insert(iter_text, comment['comment'])

                align = Gtk.Alignment.new(
                    xalign=0, yalign=0.5, xscale=0, yscale=0)
                align.add(obj)
                obj.show()
                self._grid.attach(align, 1, self._comment_row, 5, 1)
                self._comment_aligns.append(align)
                self._comment_row += 1
        self._new_comment = Gtk.Entry()
        self._new_comment.props.placeholder_text = _('Make a comment')
        self._new_comment.connect('activate', self._comment_activate_cb)
        self._grid.attach(self._new_comment, 1, self._comment_row, 5, 1)
Exemplo n.º 14
0
    def _add_columns(self):
        cell_favorite = CellRendererFavorite(self.tree_view)
        cell_favorite.connect('clicked', self.__favorite_clicked_cb)

        column = Gtk.TreeViewColumn()
        column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        column.props.fixed_width = cell_favorite.props.width
        column.pack_start(cell_favorite, True)
        column.set_cell_data_func(cell_favorite, self.__favorite_set_data_cb)
        self.tree_view.append_column(column)

        self.cell_icon = CellRendererActivityIcon(self.tree_view)

        column = Gtk.TreeViewColumn()
        column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        column.props.fixed_width = self.cell_icon.props.width
        column.pack_start(self.cell_icon, True)
        column.add_attribute(self.cell_icon, 'file-name',
                             ListModel.COLUMN_ICON)
        column.add_attribute(self.cell_icon, 'xo-color',
                             ListModel.COLUMN_ICON_COLOR)
        self.tree_view.append_column(column)

        self.cell_title = Gtk.CellRendererText()
        self.cell_title.props.ellipsize = Pango.EllipsizeMode.MIDDLE
        self.cell_title.props.ellipsize_set = True

        self._title_column = Gtk.TreeViewColumn()
        self._title_column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        self._title_column.props.expand = True
        self._title_column.props.clickable = True
        self._title_column.pack_start(self.cell_title, True)
        self._title_column.add_attribute(self.cell_title, 'markup',
                                         ListModel.COLUMN_TITLE)
        self.tree_view.append_column(self._title_column)

        buddies_column = Gtk.TreeViewColumn()
        buddies_column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        self.tree_view.append_column(buddies_column)

        for column_index in [ListModel.COLUMN_BUDDY_1,
                             ListModel.COLUMN_BUDDY_2,
                             ListModel.COLUMN_BUDDY_3]:
            cell_icon = CellRendererBuddy(self.tree_view,
                                          column_index=column_index)
            buddies_column.pack_start(cell_icon, True)
            buddies_column.props.fixed_width += cell_icon.props.width
            buddies_column.add_attribute(cell_icon, 'buddy', column_index)
            buddies_column.set_cell_data_func(cell_icon,
                                              self.__buddies_set_data_cb)

        cell_progress = Gtk.CellRendererProgress()
        cell_progress.props.ypad = style.GRID_CELL_SIZE / 4
        buddies_column.pack_start(cell_progress, True)
        buddies_column.add_attribute(cell_progress, 'value',
                ListModel.COLUMN_PROGRESS)
        buddies_column.set_cell_data_func(cell_progress,
                                          self.__progress_data_cb)

        cell_text = Gtk.CellRendererText()
        cell_text.props.xalign = 1

        # Measure the required width for a date in the form of "10 hours, 10
        # minutes ago"
        timestamp = time.time() - 10 * 60 - 10 * 60 * 60
        date = util.timestamp_to_elapsed_string(timestamp)
        date_width = self._get_width_for_string(date)

        self.sort_column = Gtk.TreeViewColumn()
        self.sort_column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        self.sort_column.props.fixed_width = date_width
        self.sort_column.set_alignment(1)
        self.sort_column.props.resizable = True
        self.sort_column.props.clickable = True
        self.sort_column.pack_start(cell_text, True)
        self.sort_column.add_attribute(cell_text, 'text',
                                       ListModel.COLUMN_TIMESTAMP)
        self.tree_view.append_column(self.sort_column)
Exemplo n.º 15
0
    def _add_columns(self):
        if self._enable_multi_operations:
            cell_select = Gtk.CellRendererToggle()
            cell_select.connect('toggled', self.__cell_select_toggled_cb)
            cell_select.props.activatable = True
            cell_select.props.xpad = style.DEFAULT_PADDING
            cell_select.props.indicator_size = style.zoom(26)

            column = Gtk.TreeViewColumn()
            column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
            column.props.fixed_width = style.GRID_CELL_SIZE
            column.pack_start(cell_select, True)
            column.set_cell_data_func(cell_select, self.__select_set_data_cb)
            self.tree_view.append_column(column)

        cell_favorite = CellRendererFavorite()
        cell_favorite.connect('clicked', self._favorite_clicked_cb)
        cell_favorite.connect_to_scroller(self._scrolling_detector)

        self._fav_column = Gtk.TreeViewColumn()
        self._fav_column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        self._fav_column.props.fixed_width = cell_favorite.props.width
        self._fav_column.pack_start(cell_favorite, True)
        self._fav_column.set_cell_data_func(
            cell_favorite, self.__favorite_set_data_cb)
        self.tree_view.append_column(self._fav_column)

        self.cell_icon = CellRendererActivityIcon()
        self.cell_icon.connect_to_scroller(self._scrolling_detector)

        column = Gtk.TreeViewColumn()
        self.tree_view.icon_activity_column = column
        column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        column.props.fixed_width = self.cell_icon.props.width
        column.pack_start(self.cell_icon, True)
        column.add_attribute(self.cell_icon, 'file-name',
                             ListModel.COLUMN_ICON)
        column.add_attribute(self.cell_icon, 'xo-color',
                             ListModel.COLUMN_ICON_COLOR)
        self.tree_view.append_column(column)
        self.icon_activity_column = column

        self.cell_title = Gtk.CellRendererText()
        self.cell_title.props.ellipsize = style.ELLIPSIZE_MODE_DEFAULT
        self.cell_title.props.ellipsize_set = True

        self._title_column = Gtk.TreeViewColumn()
        self._title_column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        self._title_column.props.expand = True
        self._title_column.props.clickable = True
        self._title_column.pack_start(self.cell_title, True)
        self._title_column.add_attribute(self.cell_title, 'markup',
                                         ListModel.COLUMN_TITLE)
        self.tree_view.append_column(self._title_column)

        for column_index in [ListModel.COLUMN_BUDDY_1,
                             ListModel.COLUMN_BUDDY_2,
                             ListModel.COLUMN_BUDDY_3]:

            buddies_column = Gtk.TreeViewColumn()
            buddies_column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
            self.tree_view.append_column(buddies_column)

            cell_icon = CellRendererBuddy(column_index=column_index)
            buddies_column.pack_start(cell_icon, True)
            buddies_column.props.fixed_width += cell_icon.props.width
            buddies_column.add_attribute(cell_icon, 'buddy', column_index)
            buddies_column.set_cell_data_func(cell_icon,
                                              self.__buddies_set_data_cb)
            self.tree_view.buddies_columns.append(buddies_column)

        cell_progress = Gtk.CellRendererProgress()
        cell_progress.props.ypad = style.GRID_CELL_SIZE / 4
        buddies_column.pack_start(cell_progress, True)
        buddies_column.add_attribute(cell_progress, 'value',
                                     ListModel.COLUMN_PROGRESS)
        buddies_column.set_cell_data_func(cell_progress,
                                          self.__progress_data_cb)

        cell_text = Gtk.CellRendererText()
        cell_text.props.xalign = 1

        # Measure the required width for a date in the form of "10 hours, 10
        # minutes ago"
        timestamp = time.time() - 10 * 60 - 10 * 60 * 60
        date = util.timestamp_to_elapsed_string(timestamp)
        date_width = self._get_width_for_string(date)

        self.sort_column = Gtk.TreeViewColumn()
        self.sort_column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        self.sort_column.props.fixed_width = date_width
        self.sort_column.set_alignment(1)
        self.sort_column.props.resizable = True
        self.sort_column.props.clickable = True
        self.sort_column.pack_start(cell_text, True)
        self.sort_column.add_attribute(cell_text, 'text',
                                       ListModel.COLUMN_TIMESTAMP)
        self.tree_view.append_column(self.sort_column)
Exemplo n.º 16
0
    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]
Exemplo n.º 17
0
    def _add_columns(self):
        if self._enable_multi_operations:
            cell_select = Gtk.CellRendererToggle()
            cell_select.connect('toggled', self.__cell_select_toggled_cb)
            cell_select.props.activatable = True
            cell_select.props.xpad = style.DEFAULT_PADDING
            cell_select.props.indicator_size = style.zoom(26)

            column = Gtk.TreeViewColumn()
            column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
            column.props.fixed_width = style.GRID_CELL_SIZE
            column.pack_start(cell_select, True)
            column.set_cell_data_func(cell_select, self.__select_set_data_cb)
            self.tree_view.append_column(column)

        cell_favorite = CellRendererFavorite()
        cell_favorite.connect('clicked', self._favorite_clicked_cb)

        column = Gtk.TreeViewColumn()
        column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        column.props.fixed_width = cell_favorite.props.width
        column.pack_start(cell_favorite, True)
        column.set_cell_data_func(cell_favorite, self.__favorite_set_data_cb)
        self.tree_view.append_column(column)

        self.cell_icon = CellRendererActivityIcon()

        column = Gtk.TreeViewColumn()
        self.tree_view.icon_activity_column = column
        column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        column.props.fixed_width = self.cell_icon.props.width
        column.pack_start(self.cell_icon, True)
        column.add_attribute(self.cell_icon, 'file-name',
                             ListModel.COLUMN_ICON)
        column.add_attribute(self.cell_icon, 'xo-color',
                             ListModel.COLUMN_ICON_COLOR)
        self.tree_view.append_column(column)
        self.icon_activity_column = column

        self.cell_title = Gtk.CellRendererText()
        self.cell_title.props.ellipsize = style.ELLIPSIZE_MODE_DEFAULT
        self.cell_title.props.ellipsize_set = True

        self._title_column = Gtk.TreeViewColumn()
        self._title_column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        self._title_column.props.expand = True
        self._title_column.props.clickable = True
        self._title_column.pack_start(self.cell_title, True)
        self._title_column.add_attribute(self.cell_title, 'markup',
                                         ListModel.COLUMN_TITLE)
        self.tree_view.append_column(self._title_column)

        for column_index in [
                ListModel.COLUMN_BUDDY_1, ListModel.COLUMN_BUDDY_2,
                ListModel.COLUMN_BUDDY_3
        ]:

            buddies_column = Gtk.TreeViewColumn()
            buddies_column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
            self.tree_view.append_column(buddies_column)

            cell_icon = CellRendererBuddy(column_index=column_index)
            buddies_column.pack_start(cell_icon, True)
            buddies_column.props.fixed_width += cell_icon.props.width
            buddies_column.add_attribute(cell_icon, 'buddy', column_index)
            buddies_column.set_cell_data_func(cell_icon,
                                              self.__buddies_set_data_cb)
            self.tree_view.buddies_columns.append(buddies_column)

        cell_progress = Gtk.CellRendererProgress()
        cell_progress.props.ypad = style.GRID_CELL_SIZE / 4
        buddies_column.pack_start(cell_progress, True)
        buddies_column.add_attribute(cell_progress, 'value',
                                     ListModel.COLUMN_PROGRESS)
        buddies_column.set_cell_data_func(cell_progress,
                                          self.__progress_data_cb)

        cell_text = Gtk.CellRendererText()
        cell_text.props.xalign = 1

        # Measure the required width for a date in the form of "10 hours, 10
        # minutes ago"
        timestamp = time.time() - 10 * 60 - 10 * 60 * 60
        date = util.timestamp_to_elapsed_string(timestamp)
        date_width = self._get_width_for_string(date)

        self.sort_column = Gtk.TreeViewColumn()
        self.sort_column.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        self.sort_column.props.fixed_width = date_width
        self.sort_column.set_alignment(1)
        self.sort_column.props.resizable = True
        self.sort_column.props.clickable = True
        self.sort_column.pack_start(cell_text, True)
        self.sort_column.add_attribute(cell_text, 'text',
                                       ListModel.COLUMN_TIMESTAMP)
        self.tree_view.append_column(self.sort_column)
Exemplo n.º 18
0
    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)
Exemplo n.º 19
0
    def __init__(self, parent):
        Gtk.EventBox.__init__(self)

        self._reflection = parent
        self._collapse = True
        self._collapse_id = None

        self.modify_bg(Gtk.StateType.NORMAL, style.COLOR_WHITE.get_gdk_color())
        self._title_color = self._reflection.activity.fg_color.get_html()

        self._grid = Gtk.Grid()
        self.add(self._grid)
        self._grid.show()

        self._grid.set_row_spacing(style.DEFAULT_PADDING)
        self._grid.set_column_spacing(style.DEFAULT_SPACING)
        self._grid.set_column_homogeneous(True)
        self._grid.set_border_width(style.DEFAULT_PADDING)

        row = 0

        self._expand_button = EventIcon(icon_name='expand',
                                        pixel_size=BUTTON_SIZE)
        self._collapse_id = self._expand_button.connect(
            'button-press-event', self._expand_cb)
        self._expand_button.set_tooltip(_('Expand'))
        self._grid.attach(self._expand_button, 0, row, 1, 1)
        self._expand_button.show()

        self._title_align = Gtk.Alignment.new(xalign=0,
                                              yalign=0.5,
                                              xscale=0,
                                              yscale=0)
        self._title = Gtk.TextView()
        self._title.set_size_request(ENTRY_WIDTH, -1)
        self._title.set_wrap_mode(Gtk.WrapMode.WORD)
        self._title_tag = self._title.get_buffer().create_tag(
            'title',
            foreground=self._title_color,
            weight=Pango.Weight.BOLD,
            size=12288)
        iter_text = self._title.get_buffer().get_iter_at_offset(0)
        self._title.get_buffer().insert_with_tags(
            iter_text, self._reflection.data['title'], self._title_tag)
        if self._reflection.activity.initiating:
            self._title.connect('focus-out-event', self._title_focus_out_cb)
        else:
            self._title.set_editable(False)
        self._title_align.add(self._title)
        self._title.show()
        self._grid.attach(self._title_align, 1, row, 5, 1)
        self._title_align.show()

        delete_button = EventIcon(icon_name='delete', pixel_size=BUTTON_SIZE)
        delete_button.set_tooltip(_('Delete'))
        delete_button.connect('button-press-event', self.__delete_cb)
        self._grid.attach(delete_button, 6, row, 1, 1)
        delete_button.show()
        ''' Notification that a new comment has been shared. '''
        self.notify_button = EventIcon(icon_name='chat',
                                       pixel_size=BUTTON_SIZE)
        self._grid.attach(self.notify_button, 6, row, 1, 1)
        row += 1

        self._time_align = Gtk.Alignment.new(xalign=0,
                                             yalign=0.5,
                                             xscale=0,
                                             yscale=0)
        self._time = Gtk.Label()
        self._time.set_size_request(ENTRY_WIDTH, -1)
        self._time.set_justify(Gtk.Justification.LEFT)
        self._time.set_use_markup(True)
        try:
            time_string = util.timestamp_to_elapsed_string(
                int(self._reflection.data['modification_time']))
        except Exception as e:
            logging.error('Could not convert modification time %s: %s' %
                          (self._reflection.data['modification_time'], e))
            self._reflection.data['modification_time'] = \
                self._reflection.data['creation_time']
            time_string = util.timestamp_to_elapsed_string(
                int(self._reflection.data['modification_time']))
        self._time.set_markup(
            '<span foreground="#808080"><small><b>%s</b></small></span>' %
            time_string)
        self._time_align.add(self._time)
        self._time.show()
        self._grid.attach(self._time_align, 1, row, 5, 1)
        self._time_align.show()
        row += 1

        label = ''
        if 'tags' in self._reflection.data:
            for tag in self._reflection.data['tags']:
                if len(label) > 0:
                    label += ', '
                label += tag
        if self._reflection.activity.initiating and label == '':
            label = _('Add a #tag')
        self._tag_align = Gtk.Alignment.new(xalign=0,
                                            yalign=0.5,
                                            xscale=0,
                                            yscale=0)
        self._tag_view = Gtk.TextView()
        self._tag_view.set_size_request(ENTRY_WIDTH, -1)
        self._tag_view.set_wrap_mode(Gtk.WrapMode.WORD)
        self._tag_view.get_buffer().set_text(label)
        if self._reflection.activity.initiating:
            self._tag_view.connect('focus-in-event', self._tag_focus_in_cb,
                                   _('Add a #tag'))
            self._tag_view.connect('focus-out-event', self._tags_focus_out_cb)
        else:
            self._tag_view.set_editable(False)
        self._tag_align.add(self._tag_view)
        self._tag_view.show()
        self._grid.attach(self._tag_align, 1, row, 5, 1)

        if self._reflection.activity.initiating:
            self._new_tag = EventIcon(icon_name='ok', pixel_size=BUTTON_SIZE)
            self._new_tag.connect('button-press-event', self._tag_button_cb)
            self._grid.attach(self._new_tag, 6, row, 1, 1)
        row += 1

        self._activities_align = Gtk.Alignment.new(xalign=0,
                                                   yalign=0.5,
                                                   xscale=0,
                                                   yscale=0)
        self._make_activities_grid()
        self._grid.attach(self._activities_align, 1, row, 5, 1)
        self._activities_align.show()

        if self._reflection.activity.initiating:
            self._new_activity = EventIcon(icon_name='add-item',
                                           pixel_size=BUTTON_SIZE)
            self._new_activity.set_tooltip(_('Add new activity'))
            self._new_activity.connect('button-press-event',
                                       self._activity_button_cb)
            self._grid.attach(self._new_activity, 6, row, 1, 1)
            self._new_activity.show()
        row += 1

        self._stars_align = Gtk.Alignment.new(xalign=0,
                                              yalign=0.5,
                                              xscale=0,
                                              yscale=0)
        grid = Gtk.Grid()
        if 'stars' in self._reflection.data:
            stars = self._reflection.data['stars']
        else:
            stars = 0
        self._star_icons = []
        for i in range(NUMBER_OF_STARS):
            if i < stars:
                icon_name = 'star-filled'
            else:
                icon_name = 'star-empty'
            self._star_icons.append(
                EventIcon(icon_name=icon_name, pixel_size=STAR_SIZE))
            if self._reflection.activity.initiating:
                self._star_icons[-1].connect('button-press-event',
                                             self._star_button_cb, i)
            grid.attach(self._star_icons[-1], i, 0, 1, 1)
            self._star_icons[-1].show()
        self._stars_align.add(grid)
        grid.show()
        self._grid.attach(self._stars_align, 1, row, 5, 1)
        row += 1

        self._content_aligns = []
        first_text = True
        first_image = True
        self._content_we_always_show = []
        if 'content' in self._reflection.data:
            for i, item in enumerate(self._reflection.data['content']):
                # Add edit and delete buttons
                align = Gtk.Alignment.new(xalign=0,
                                          yalign=0.5,
                                          xscale=0,
                                          yscale=0)
                obj = None
                if 'text' in item:
                    obj = Gtk.TextView()
                    obj.set_size_request(ENTRY_WIDTH, -1)
                    obj.set_wrap_mode(Gtk.WrapMode.WORD)

                    obj.get_buffer().set_text(item['text'])
                    if self._reflection.activity.initiating:
                        obj.connect('focus-in-event', self._text_focus_in_cb)
                        obj.connect('focus-out-event', self._text_focus_out_cb,
                                    i)
                    else:
                        obj.set_editable(False)
                    if first_text:
                        self._content_we_always_show.append(align)
                        first_text = False
                elif 'image' in item:
                    try:
                        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                            item['image'], PICTURE_WIDTH, PICTURE_HEIGHT)
                        obj = Gtk.Image.new_from_pixbuf(pixbuf)
                        if first_image:
                            self._content_we_always_show.append(align)
                            first_image = False
                    except BaseException:
                        logging.error('could not open %s' % item['image'])
                if obj is not None:
                    align.add(obj)
                    obj.show()
                    self._grid.attach(align, 1, row, 5, 1)
                    self._content_aligns.append(align)
                    row += 1

        self._row = row
        if self._reflection.activity.initiating:
            self._new_entry = Gtk.Entry()
            self._new_entry.props.placeholder_text = _('Write a reflection')
            self._new_entry.connect('activate', self._entry_activate_cb)
            self._grid.attach(self._new_entry, 1, row, 5, 1)
            self._content_we_always_show.append(self._new_entry)
            self._new_image = EventIcon(icon_name='add-picture',
                                        pixel_size=BUTTON_SIZE)
            self._new_image.set_tooltip(_('Add new image'))
            self._new_image.connect('button-press-event',
                                    self._image_button_cb)
            self._grid.attach(self._new_image, 6, row, 1, 1)
            self._content_we_always_show.append(self._new_image)

        for align in self._content_we_always_show:
            align.show()
        row += 1

        self._comment_row = row
        self._comment_aligns = []
        if 'comments' in self._reflection.data:
            for comment in self._reflection.data['comments']:
                obj = Gtk.TextView()
                obj.set_editable(False)
                obj.set_size_request(ENTRY_WIDTH, -1)
                obj.set_wrap_mode(Gtk.WrapMode.WORD)
                nick_tag = obj.get_buffer().create_tag(
                    'nick',
                    foreground=comment['color'],
                    weight=Pango.Weight.BOLD)
                iter_text = obj.get_buffer().get_iter_at_offset(0)
                obj.get_buffer().insert_with_tags(iter_text,
                                                  comment['nick'] + ': ',
                                                  nick_tag)
                iter_text = obj.get_buffer().get_end_iter()
                obj.get_buffer().insert(iter_text, comment['comment'])

                align = Gtk.Alignment.new(xalign=0,
                                          yalign=0.5,
                                          xscale=0,
                                          yscale=0)
                align.add(obj)
                obj.show()
                self._grid.attach(align, 1, self._comment_row, 5, 1)
                self._comment_aligns.append(align)
                self._comment_row += 1
        self._new_comment = Gtk.Entry()
        self._new_comment.props.placeholder_text = _('Make a comment')
        self._new_comment.connect('activate', self._comment_activate_cb)
        self._grid.attach(self._new_comment, 1, self._comment_row, 5, 1)