/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: Markus Korn
  • Date: 2009-03-05 16:50:39 UTC
  • mto: (635.2.4 trunk)
  • mto: This revision was merged to the branch mainline in revision 639.
  • Revision ID: thekorn@gmx.de-20090305165039-h6xh48wr9lwe1661
* register BranchSelectionBox() as a gobject type to fix (LP: #294396)

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
        self.maxnum      = maxnum
49
49
        self.config      = GlobalConfig()
50
50
 
 
51
        self._sizes      = {} # window and widget sizes
 
52
 
51
53
        if self.config.get_user_option('viz-compact-view') == 'yes':
52
54
            self.compact_view = True
53
55
        else:
54
56
            self.compact_view = False
55
57
 
56
 
        self.set_title(branch._get_nick(local=True) + " - revision history")
 
58
        self.set_title(branch.nick + " - revision history")
57
59
 
58
60
        # user-configured window size
59
61
        size = self._load_size('viz-window-size')
67
69
            height = int(monitor.height * 0.75)
68
70
        self.set_default_size(width, height)
69
71
        self.set_size_request(width/3, height/3)
70
 
        self._save_size_on_destroy(self, 'viz-window-size')
 
72
        self.connect("size-allocate", self._on_size_allocate, 'viz-window-size')
71
73
 
72
74
        # FIXME AndyFitz!
73
75
        icon = self.render_icon(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON)
102
104
 
103
105
        self.construct()
104
106
 
105
 
    def _save_size_on_destroy(self, widget, config_name):
106
 
        """Creates a hook that saves the size of widget to config option 
107
 
           config_name when the window is destroyed/closed."""
108
 
        def save_size(src):
109
 
            width, height = widget.allocation.width, widget.allocation.height
110
 
            value = '%sx%s' % (width, height)
111
 
            self.config.set_user_option(config_name, value)
112
 
        self.connect("destroy", save_size)
113
 
 
114
107
    def set_revision(self, revid):
115
108
        self.treeview.set_revision_id(revid)
116
109
 
322
315
        else:
323
316
            (width, height) = self.get_size()
324
317
            align.set_size_request(width, int(height / 2.5))
325
 
        self._save_size_on_destroy(align, 'viz-graph-size')
 
318
        align.connect('size-allocate', self._on_size_allocate, 'viz-graph-size')
326
319
        align.show()
327
320
 
328
321
        return align
365
358
        if size:
366
359
            width, height = size
367
360
            self.revisionview.set_size_request(width, height)
368
 
        self._save_size_on_destroy(self.revisionview, 'viz-revisionview-size')
 
361
        self.revisionview.connect('size-allocate', self._on_size_allocate, 'viz-revisionview-size')
369
362
        self.revisionview.show()
370
363
        self.revisionview.set_show_callback(self._show_clicked_cb)
371
364
        self.revisionview.connect('notify::revision', self._go_clicked_cb)
446
439
        parents  = self.treeview.get_parents()
447
440
 
448
441
        if len(parents) == 0:
449
 
            parent_id = NULL_REVISION
 
442
            parent_id = None
450
443
        else:
451
444
            parent_id = parents[0]
452
445
 
604
597
        if size:
605
598
            width, height = [int(num) for num in size.split('x')]
606
599
            # avoid writing config every time we start
 
600
            self._sizes[name] = (width, height)
607
601
            return width, height
608
602
        return None
609
603
 
610
 
    def show_diff(self, revid=None, parentid=NULL_REVISION):
 
604
    def _on_size_allocate(self, widget, allocation, name):
 
605
        """When window has been resized, save the new size."""
 
606
        width, height = 0, 0
 
607
        if name in self._sizes:
 
608
            width, height = self._sizes[name]
 
609
 
 
610
        size_changed = (width != allocation.width) or \
 
611
                (height != allocation.height)
 
612
 
 
613
        if size_changed:
 
614
            width, height = allocation.width, allocation.height
 
615
            self._sizes[name] = (width, height)
 
616
            value = '%sx%s' % (width, height)
 
617
            self.config.set_user_option(name, value)
 
618
 
 
619
    def show_diff(self, revid=None, parentid=None):
611
620
        """Open a new window to show a diff between the given revisions."""
612
621
        from bzrlib.plugins.gtk.diff import DiffWindow
613
622
        window = DiffWindow(parent=self)
614
623
 
 
624
        if parentid is None:
 
625
            parentid = NULL_REVISION
 
626
 
615
627
        rev_tree    = self.branch.repository.revision_tree(revid)
616
628
        parent_tree = self.branch.repository.revision_tree(parentid)
617
629
 
618
 
        description = revid + " - " + self.branch._get_nick(local=True)
 
630
        description = revid + " - " + self.branch.nick
619
631
        window.set_diff(description, rev_tree, parent_tree)
620
632
        window.show()
621
633
 
626
638
 
627
639
        if not revision: # default to selected row
628
640
            revision = self.treeview.get_revision()
629
 
        if revision == NULL_REVISION:
 
641
        if (not revision) or (revision == NULL_REVISION):
630
642
            return
631
643
 
632
644
        if not parents: # default to selected row's parents
633
645
            parents  = self.treeview.get_parents()
634
646
        if len(parents) == 0:
635
 
            parent_id = NULL_REVISION
 
647
            parent_id = None
636
648
        else:
637
649
            parent_id = parents[0]
638
650