/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to viz/branchwin.py

Reuse the viz treeview in the revision browser.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
from bzrlib.plugins.gtk.window import Window
17
17
from bzrlib.plugins.gtk.tags import AddTagDialog
18
18
from bzrlib.plugins.gtk.preferences import PreferencesWindow
19
 
from bzrlib.plugins.gtk.branchview import TreeView
 
19
from bzrlib.plugins.gtk.branchview import TreeView, treemodel
20
20
from bzrlib.revision import Revision
21
21
from bzrlib.config import BranchConfig
22
22
from bzrlib.config import GlobalConfig
226
226
 
227
227
        self.treeview.connect('revision-selected',
228
228
                self._treeselection_changed_cb)
 
229
        self.treeview.connect('revision-activated',
 
230
                self._tree_revision_activated)
229
231
 
230
232
        self.treeview.connect('tag-added', lambda w, t, r: self._update_tags())
231
233
 
328
330
 
329
331
            self.revisionview.set_revision(revision)
330
332
            self.revisionview.set_children(children)
 
333
    
 
334
    def _tree_revision_activated(self, widget, path, col):
 
335
        # TODO: more than one parent
 
336
        """Callback for when a treeview row gets activated."""
 
337
        revision = self.treeview.get_revision()
 
338
        parents  = self.treeview.get_parents()
 
339
 
 
340
        if len(parents) == 0:
 
341
            parent_id = None
 
342
        else:
 
343
            parent_id = parents[0]
 
344
 
 
345
        self.show_diff(revision.revision_id, parent_id)
 
346
        self.treeview.grab_focus()
 
347
    
331
348
 
332
349
    def _back_clicked_cb(self, *args):
333
350
        """Callback for when the back button is clicked."""
344
361
 
345
362
    def _show_clicked_cb(self, revid, parentid):
346
363
        """Callback for when the show button for a parent is clicked."""
347
 
        self.treeview.show_diff(revid, parentid)
 
364
        self.show_diff(revid, parentid)
348
365
        self.treeview.grab_focus()
349
366
 
350
367
    def _set_revision_cb(self, w, revision_id):
420
437
 
421
438
        self.go_menu_tags.show_all()
422
439
 
 
440
    def show_diff(self, revid=None, parentid=None):
 
441
        """Open a new window to show a diff between the given revisions."""
 
442
        from bzrlib.plugins.gtk.diff import DiffWindow
 
443
        window = DiffWindow(parent=self)
 
444
 
 
445
        if parentid is None:
 
446
            parentid = NULL_REVISION
 
447
 
 
448
        rev_tree    = self.branch.repository.revision_tree(revid)
 
449
        parent_tree = self.branch.repository.revision_tree(parentid)
 
450
 
 
451
        description = revid + " - " + self.branch.nick
 
452
        window.set_diff(description, rev_tree, parent_tree)
 
453
        window.show()
 
454
 
423
455