/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

  • Committer: Scott Scriven
  • Date: 2008-07-10 06:10:43 UTC
  • mto: This revision was merged to the branch mainline in revision 549.
  • Revision ID: ubuntu@toykeeper.net-20080710061043-k6ppl18xe81uajq4
Added an option to show/hide the diff panel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
172
172
        view_menu_compact.set_active(self.compact_view)
173
173
        view_menu_compact.connect('activate', self._brokenlines_toggled_cb)
174
174
 
 
175
        view_menu_diffs = gtk.CheckMenuItem("Show Diffs")
 
176
        view_menu_diffs.set_active(True)
 
177
        if self.config.get_user_option('viz-show-diffs') == 'False':
 
178
            view_menu_diffs.set_active(False)
 
179
        view_menu_diffs.connect('toggled', self._diff_visibility_changed)
 
180
 
175
181
        view_menu.add(view_menu_toolbar)
176
182
        view_menu.add(view_menu_compact)
 
183
        view_menu.add(view_menu_diffs)
177
184
        view_menu.add(gtk.SeparatorMenuItem())
178
185
 
179
186
        self.mnu_show_revno_column = gtk.CheckMenuItem("Show Revision _Number Column")
325
332
        self.bottom_hpaned.pack2(self.diff)
326
333
 
327
334
        self.bottom_hpaned.show_all()
 
335
        if self.config.get_user_option('viz-show-diffs') == 'False':
 
336
            self.diff.hide()
 
337
 
328
338
        return self.bottom_hpaned
329
339
 
330
340
    def _tag_selected_cb(self, menuitem, revid):
383
393
            self.revisionview.set_revision(revision)
384
394
            self.revisionview.set_children(children)
385
395
 
386
 
            # update the diff panel
387
 
            if len(parents) == 0:
388
 
                parent_id = None
389
 
            else:
390
 
                parent_id = parents[0]
391
 
 
392
 
            rev_tree    = self.branch.repository.revision_tree(revision.revision_id)
393
 
            parent_tree = self.branch.repository.revision_tree(parent_id)
394
 
            # FIXME: for some reason, an existing DiffWidget refuses to show 
395
 
            # diffs, but a new one works fine
396
 
            self.bottom_hpaned.remove(self.diff)
397
 
            from bzrlib.plugins.gtk.diff import DiffWidget
398
 
            self.diff = DiffWidget()
399
 
            self.bottom_hpaned.pack2(self.diff)
400
 
            # end FIXME; below is fine
401
 
            self.diff.set_diff(rev_tree, parent_tree)
402
 
            self.diff.diff_view.show_diff(None) # show all changes
403
 
            self.diff.show_all()
 
396
            self.update_diff_panel(revision, parents)
404
397
 
405
398
    def _tree_revision_activated(self, widget, path, col):
406
399
        # TODO: more than one parent
478
471
            self.toolbar.hide()
479
472
        self.config.set_user_option('viz-toolbar-visible', col.get_active())
480
473
 
 
474
    def _diff_visibility_changed(self, col):
 
475
        if col.get_active():
 
476
            self.diff.show()
 
477
        else:
 
478
            self.diff.hide()
 
479
        self.config.set_user_option('viz-show-diffs', str(col.get_active()))
 
480
        self.update_diff_panel()
 
481
 
481
482
    def _show_about_cb(self, w):
482
483
        dialog = AboutDialog()
483
484
        dialog.connect('response', lambda d,r: d.destroy())
524
525
        window.show()
525
526
 
526
527
 
 
528
    def update_diff_panel(self, revision=None, parents=None):
 
529
        """Show the current revision in the diff panel."""
 
530
        if self.config.get_user_option('viz-show-diffs') == 'False':
 
531
            return
 
532
 
 
533
        if not revision: # default to selected row
 
534
            revision = self.treeview.get_revision()
 
535
        if (not revision) or (revision == NULL_REVISION):
 
536
            return
 
537
 
 
538
        if not parents: # default to selected row's parents
 
539
            parents  = self.treeview.get_parents()
 
540
        if len(parents) == 0:
 
541
            parent_id = None
 
542
        else:
 
543
            parent_id = parents[0]
 
544
 
 
545
        rev_tree    = self.branch.repository.revision_tree(revision.revision_id)
 
546
        parent_tree = self.branch.repository.revision_tree(parent_id)
 
547
        # FIXME: for some reason, an existing DiffWidget refuses to show 
 
548
        # diffs, but a new one works fine
 
549
        self.bottom_hpaned.remove(self.diff)
 
550
        from bzrlib.plugins.gtk.diff import DiffWidget
 
551
        self.diff = DiffWidget()
 
552
        self.bottom_hpaned.pack2(self.diff)
 
553
        # end FIXME; below is fine
 
554
        self.diff.set_diff(rev_tree, parent_tree)
 
555
        self.diff.diff_view.show_diff(None) # show all changes
 
556
        self.diff.show_all()