Ticket #4206: 0001-View-Source-Expand-rows-on-tap-click-SL-4206.patch

File 0001-View-Source-Expand-rows-on-tap-click-SL-4206.patch, 1.9 KB (added by manuq, 10 years ago)

Patch, stolen from #4197

  • src/jarabe/view/viewsource.py

    From a0b8860b830ca8959e9a3adc128dbe92bc436bad Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
    Date: Tue, 27 Nov 2012 09:55:50 -0300
    Subject: [PATCH shell] View Source: Expand rows on tap/click - SL #4206
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
    
    Change the normal behaviour of tap/click on rows, so they are expanded
    pressing on the whole row, not just on the arrow button.  This is
    helpful for touch interaction.
    
    Signed-off-by: Manuel Quiñones <manuq@laptop.org>
    ---
     src/jarabe/view/viewsource.py | 14 ++++++++++++++
     1 file changed, 14 insertions(+)
    
    diff --git a/src/jarabe/view/viewsource.py b/src/jarabe/view/viewsource.py
    index 1578a8f..d23038b 100644
    a b class FileViewer(Gtk.ScrolledWindow): 
    469469        self._initial_filename = initial_filename
    470470
    471471        self._tree_view = Gtk.TreeView()
     472        self._tree_view.connect('cursor-changed', self.__cursor_changed_cb)
    472473        self.add(self._tree_view)
    473474        self._tree_view.show()
    474475
    class FileViewer(Gtk.ScrolledWindow): 
    518519            file_path = model.get_value(tree_iter, 1)
    519520        self.emit('file-selected', file_path)
    520521
     522    def __cursor_changed_cb(self, treeview):
     523        selection = treeview.get_selection()
     524        store, iter_ = selection.get_selected()
     525        if iter_ is None:
     526            # Nothing selected. This happens at startup
     527            return
     528        if store.iter_has_child(iter_):
     529            path = store.get_path(iter_)
     530            if treeview.row_expanded(path):
     531                treeview.collapse_row(path)
     532            else:
     533                treeview.expand_row(path, False)
     534
    521535
    522536class SourceDisplay(Gtk.ScrolledWindow):
    523537    __gtype_name__ = 'SugarSourceDisplay'