Ticket #1283: sugar-1283.patch

File sugar-1283.patch, 2.5 KB (added by alsroot, 12 years ago)
  • src/jarabe/journal/listview.py

    From 016ebbe292fefea010641542010fcd3be995fca2 Mon Sep 17 00:00:00 2001
    From: Aleksey Lim <alsroot@member.fsf.org>
    Date: Sun, 6 Sep 2009 16:38:50 +0000
    Subject: Journal title editing unexpected behaviour requires two clicks to edit #1283
    
    ---
     src/jarabe/journal/listview.py |   32 +++++++++++++++++++++++++++++++-
     1 files changed, 31 insertions(+), 1 deletions(-)
    
    diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py
    index badeb24..3726ee7 100644
    a b class ListView(BaseListView): 
    474474
    475475    def __init__(self):
    476476        BaseListView.__init__(self)
     477        self._is_dragging = False
     478
     479        self.tree_view.connect('drag-begin', self.__drag_begin_cb)
     480        self.tree_view.connect('button-release-event',
     481                self.__button_release_event_cb)
    477482
    478         self.cell_title.props.editable = True
    479483        self.cell_title.connect('edited', self.__cell_title_edited_cb)
     484        self.cell_title.connect('editing-canceled', self.__editing_canceled_cb)
    480485
    481486        self.cell_icon.connect('clicked', self.__icon_clicked_cb)
    482487        self.cell_icon.connect('detail-clicked', self.__detail_clicked_cb)
    class ListView(BaseListView): 
    490495        column.pack_start(cell_detail)
    491496        self.tree_view.append_column(column)
    492497
     498    def __drag_begin_cb(self, widget, drag_context):
     499        self._is_dragging = True
     500
     501    def __button_release_event_cb(self, tree_view, event):
     502        try:
     503            if self._is_dragging:
     504                return
     505        finally:
     506            self._is_dragging = False
     507
     508        pos = tree_view.get_path_at_pos(int(event.x), int(event.y))
     509        if pos is None:
     510            return
     511
     512        path, column, x_, y_ = pos
     513        if column != self._title_column:
     514            return
     515
     516        self.cell_title.props.editable = True
     517        tree_view.set_cursor_on_cell(path, column, start_editing=True)
     518
    493519    def __detail_cell_clicked_cb(self, cell, path):
    494520        row = self.tree_view.get_model()[path]
    495521        self.emit('detail-clicked', row[ListModel.COLUMN_UID])
    class ListView(BaseListView): 
    507533        metadata = model.get(row[ListModel.COLUMN_UID])
    508534        metadata['title'] = new_text
    509535        model.write(metadata, update_mtime=False)
     536        self.cell_title.props.editable = False
     537
     538    def __editing_canceled_cb(self, cell):
     539        self.cell_title.props.editable = False
    510540
    511541class CellRendererFavorite(CellRendererIcon):
    512542    __gtype_name__ = 'JournalCellRendererFavorite'