Exemplo n.º 1
0
    def set_metadata(self, metadata):
        if self._metadata == metadata:
            return
        self._metadata = metadata

        self._keep_icon.keep = (str(metadata.get('keep', 0)) == '1')

        self._icon = self._create_icon()
        self._icon_box.clear()
        self._icon_box.append(self._icon)

        self._date.props.text = misc.get_date(metadata)

        title = self._title.props.widget
        title.props.text = metadata.get('title', _('Untitled'))
        title.props.editable = model.is_editable(metadata)

        self._preview_box.clear()
        self._preview_box.append(self._create_preview())

        self._technical_box.clear()
        self._technical_box.append(self._create_technical())

        self._buddy_list.clear()
        self._buddy_list.append(self._create_buddy_list())

        description = self._description.text_view_widget
        description.props.buffer.props.text = metadata.get('description', '')
        description.props.editable = model.is_editable(metadata)

        tags = self._tags.text_view_widget
        tags.props.buffer.props.text = metadata.get('tags', '')
        tags.props.editable = model.is_editable(metadata)
Exemplo n.º 2
0
    def set_metadata(self, metadata):
        if self._metadata == metadata:
            return
        self._metadata = metadata

        self._keep_icon.keep = (str(metadata.get('keep', 0)) == '1')

        self._icon = self._create_icon()
        self._icon_box.clear()
        self._icon_box.append(self._icon)

        self._date.props.text = misc.get_date(metadata)

        title = self._title.props.widget
        title.props.text = metadata.get('title', _('Untitled'))
        title.props.editable = model.is_editable(metadata)

        self._preview_box.clear()
        self._preview_box.append(self._create_preview())

        self._technical_box.clear()
        self._technical_box.append(self._create_technical())

        self._buddy_list.clear()
        self._buddy_list.append(self._create_buddy_list())

        description = self._description.text_view_widget
        description.props.buffer.props.text = metadata.get('description', '')
        description.props.editable = model.is_editable(metadata)

        tags = self._tags.text_view_widget
        tags.props.buffer.props.text = metadata.get('tags', '')
        tags.props.editable = model.is_editable(metadata)
Exemplo n.º 3
0
    def _update_entry(self, needs_update=False):
        if not model.is_editable(self._metadata):
            return

        old_title = self._metadata.get('title', None)
        new_title = self._title.get_text()
        if old_title != new_title:
            label = GLib.markup_escape_text(new_title)
            self._icon.palette.props.primary_text = label
            self._metadata['title'] = new_title
            self._metadata['title_set_by_user'] = '******'
            needs_update = True

        bounds = self._tags.get_buffer().get_bounds()
        old_tags = self._metadata.get('tags', None)
        new_tags = self._tags.get_buffer().get_text(bounds[0], bounds[1],
                                                    include_hidden_chars=False)

        if old_tags != new_tags:
            self._metadata['tags'] = new_tags
            needs_update = True

        bounds = self._description.get_buffer().get_bounds()
        old_description = self._metadata.get('description', None)
        new_description = self._description.get_buffer().get_text(
            bounds[0], bounds[1], include_hidden_chars=False)
        if old_description != new_description:
            self._metadata['description'] = new_description
            needs_update = True

        if needs_update:
            self._write_entry()

        self._update_title_sid = None
Exemplo n.º 4
0
    def __button_release_event_cb(self, tree_view, event):
        try:
            if self._is_dragging:
                return
        finally:
            self._is_dragging = False

        pos = tree_view.get_path_at_pos(int(event.x), int(event.y))
        if pos is None:
            return

        path, column, x_, y_ = pos
        if column != self._title_column:
            return

        row = self.tree_view.get_model()[path]
        metadata = model.get(row[ListModel.COLUMN_UID])
        self.cell_title.props.editable = model.is_editable(metadata)
        if self.cell_title.props.editable:
            self.emit('title-edit-started')

        tree_view.set_cursor_on_cell(path,
                                     column,
                                     self.cell_title,
                                     start_editing=True)
Exemplo n.º 5
0
    def _update_entry(self, needs_update=False):
        if not model.is_editable(self._metadata):
            return

        old_title = self._metadata.get('title', None)
        new_title = self._title.get_text()
        if old_title != new_title:
            label = GLib.markup_escape_text(new_title)
            self._icon.palette.props.primary_text = label
            self._metadata['title'] = new_title
            self._metadata['title_set_by_user'] = '******'
            needs_update = True

        bounds = self._tags.get_buffer().get_bounds()
        old_tags = self._metadata.get('tags', None)
        new_tags = self._tags.get_buffer().get_text(bounds[0],
                                                    bounds[1],
                                                    include_hidden_chars=False)

        if old_tags != new_tags:
            self._metadata['tags'] = new_tags
            needs_update = True

        bounds = self._description.get_buffer().get_bounds()
        old_description = self._metadata.get('description', None)
        new_description = self._description.get_buffer().get_text(
            bounds[0], bounds[1], include_hidden_chars=False)
        if old_description != new_description:
            self._metadata['description'] = new_description
            needs_update = True

        if needs_update:
            self._write_entry()

        self._update_title_sid = None
Exemplo n.º 6
0
    def _favorite_clicked_cb(self, cell, path):
        row = self._model[path]
        iterator = self._model.get_iter(path)
        metadata = model.get(row[ListModel.COLUMN_UID])
        if not model.is_editable(metadata):
            return
        if metadata.get('keep', 0) == '1':
            metadata['keep'] = '0'
            self._model[iterator][ListModel.COLUMN_FAVORITE] = '0'
        else:
            metadata['keep'] = '1'
            self._model[iterator][ListModel.COLUMN_FAVORITE] = '1'

        cell_rect = self.tree_view.get_cell_area(path, self._fav_column)
        self.tree_view.queue_draw_area(cell_rect.x, cell_rect.y,
                                       cell_rect.width, cell_rect.height)

        # HACK for https://bugs.sugarlabs.org/ticket/4904
        if rect.y == 0:
            GLib.idle_add(
                self.tree_view.queue_draw_area(cell_rect.x, cell_rect.y,
                                               cell_rect.width,
                                               cell_rect.height))

        # HACK for https://bugs.sugarlabs.org/ticket/4944
        # Icon does not update automatically if there is only one journal entry
        if len(self._model.get_all_ids()) == 1:
            self._do_refresh()
Exemplo n.º 7
0
 def _favorite_clicked_cb(self, cell, path):
     row = self._model[path]
     metadata = model.get(row[ListModel.COLUMN_UID])
     if not model.is_editable(metadata):
         return
     if metadata.get('keep', 0) == '1':
         metadata['keep'] = '0'
     else:
         metadata['keep'] = '1'
     model.write(metadata, update_mtime=False)
Exemplo n.º 8
0
 def __favorite_clicked_cb(self, cell, path):
     row = self._model[path]
     metadata = model.get(row[ListModel.COLUMN_UID])
     if not model.is_editable(metadata):
         return
     if metadata.get('keep', 0) == '1':
         metadata['keep'] = '0'
     else:
         metadata['keep'] = '1'
     model.write(metadata, update_mtime=False)
Exemplo n.º 9
0
    def _favorite_clicked_cb(self, cell, path):
        row = self._model[path]
        iterator = self._model.get_iter(path)
        metadata = model.get(row[ListModel.COLUMN_UID])
        if not model.is_editable(metadata):
            return
        if metadata.get("keep", 0) == "1":
            metadata["keep"] = "0"
            self._model[iterator][ListModel.COLUMN_FAVORITE] = "0"
        else:
            metadata["keep"] = "1"
            self._model[iterator][ListModel.COLUMN_FAVORITE] = "1"

        cell_rect = self.tree_view.get_cell_area(path, self._fav_column)
        self.tree_view.queue_draw_area(cell_rect.x, cell_rect.y, cell_rect.width, cell_rect.height)
Exemplo n.º 10
0
    def _favorite_clicked_cb(self, cell, path):
        row = self._model[path]
        iterator = self._model.get_iter(path)
        metadata = model.get(row[ListModel.COLUMN_UID])
        if not model.is_editable(metadata):
            return
        if metadata.get('keep', 0) == '1':
            metadata['keep'] = '0'
            self._model[iterator][ListModel.COLUMN_FAVORITE] = '0'
        else:
            metadata['keep'] = '1'
            self._model[iterator][ListModel.COLUMN_FAVORITE] = '1'

        cell_rect = self.tree_view.get_cell_area(path, self._fav_column)
        self.tree_view.queue_draw_area(cell_rect.x, cell_rect.y,
                                       cell_rect.width, cell_rect.height)
Exemplo n.º 11
0
    def _update_entry(self, needs_update=False):
        if not model.is_editable(self._metadata):
            return

        old_title = self._metadata.get('title', None)
        new_title = self._title.get_text()
        if old_title != new_title:
            label = glib.markup_escape_text(new_title)
            self._icon.palette.props.primary_text = label
            self._metadata['title'] = new_title
            self._metadata['title_set_by_user'] = '******'
            needs_update = True

        bounds = self._tags.get_buffer().get_bounds()
        old_tags = self._metadata.get('tags', None)
        new_tags = self._tags.get_buffer().get_text(bounds[0],
                                                    bounds[1],
                                                    include_hidden_chars=False)

        if old_tags != new_tags:
            self._metadata['tags'] = new_tags
            needs_update = True

        bounds = self._description.get_buffer().get_bounds()
        old_description = self._metadata.get('description', None)
        new_description = self._description.get_buffer().get_text(
            bounds[0], bounds[1], include_hidden_chars=False)
        if old_description != new_description:
            self._metadata['description'] = new_description
            needs_update = True

        if needs_update:
            if self._metadata.get('mountpoint', '/') == '/':
                model.write(self._metadata, update_mtime=False)
            else:
                old_file_path = os.path.join(
                    self._metadata['mountpoint'],
                    model.get_file_name(old_title,
                                        self._metadata['mime_type']))
                model.write(self._metadata,
                            file_path=old_file_path,
                            update_mtime=False)

        self._update_title_sid = None
Exemplo n.º 12
0
    def __button_release_event_cb(self, tree_view, event):
        try:
            if self._is_dragging:
                return
        finally:
            self._is_dragging = False

        pos = tree_view.get_path_at_pos(int(event.x), int(event.y))
        if pos is None:
            return

        path, column, x_, y_ = pos
        if column != self._title_column:
            return

        row = self.tree_view.get_model()[path]
        metadata = model.get(row[ListModel.COLUMN_UID])
        self.cell_title.props.editable = model.is_editable(metadata)

        tree_view.set_cursor_on_cell(path, column, start_editing=True)
Exemplo n.º 13
0
    def _update_entry(self, needs_update=False):
        if not model.is_editable(self._metadata):
            return

        old_title = self._metadata.get('title', None)
        new_title = self._title.get_text()
        if old_title != new_title:
            label = glib.markup_escape_text(new_title)
            self._icon.palette.props.primary_text = label
            self._metadata['title'] = new_title
            self._metadata['title_set_by_user'] = '******'
            needs_update = True

        bounds = self._tags.get_buffer().get_bounds()
        old_tags = self._metadata.get('tags', None)
        new_tags = self._tags.get_buffer().get_text(bounds[0], bounds[1],
                                                    include_hidden_chars=False)

        if old_tags != new_tags:
            self._metadata['tags'] = new_tags
            needs_update = True

        bounds = self._description.get_buffer().get_bounds()
        old_description = self._metadata.get('description', None)
        new_description = self._description.get_buffer().get_text(
            bounds[0], bounds[1], include_hidden_chars=False)
        if old_description != new_description:
            self._metadata['description'] = new_description
            needs_update = True

        if needs_update:
            if self._metadata.get('mountpoint', '/') == '/':
                model.write(self._metadata, update_mtime=False)
            else:
                old_file_path = os.path.join(self._metadata['mountpoint'],
                        model.get_file_name(old_title,
                        self._metadata['mime_type']))
                model.write(self._metadata, file_path=old_file_path,
                        update_mtime=False)

        self._update_title_sid = None
Exemplo n.º 14
0
    def _favorite_clicked_cb(self, cell, path):
        row = self._model[path]
        iterator = self._model.get_iter(path)
        metadata = model.get(row[ListModel.COLUMN_UID])
        if not model.is_editable(metadata):
            return
        if metadata.get('keep', 0) == '1':
            metadata['keep'] = '0'
            self._model[iterator][ListModel.COLUMN_FAVORITE] = '0'
        else:
            metadata['keep'] = '1'
            self._model[iterator][ListModel.COLUMN_FAVORITE] = '1'

        cell_rect = self.tree_view.get_cell_area(path, self._fav_column)
        self.tree_view.queue_draw_area(cell_rect.x, cell_rect.y,
                                       cell_rect.width, cell_rect.height)

        # HACK for https://bugs.sugarlabs.org/ticket/4944
        # Icon does not update automatically if there is only one journal entry
        if len(self._model.get_all_ids()) == 1:
            self._do_refresh()