/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: Vincent Ladeuil
  • Date: 2009-05-07 09:54:50 UTC
  • Revision ID: v.ladeuil+lp@free.fr-20090507095450-idnyqdk8t15sete7
Reproduce bug #373157 root cause.

* tests/test_annotate_config.py: 
Reproduce bug #373157.

* tests/__init__.py:
(load_tests): Add test_annotate_config.

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:
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)
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
 
 
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
 
610
619
    def show_diff(self, revid=None, parentid=NULL_REVISION):
611
620
        """Open a new window to show a diff between the given revisions."""
612
621
        from bzrlib.plugins.gtk.diff import DiffWindow