/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: Jelmer Vernooij
  • Date: 2009-05-25 15:57:23 UTC
  • mfrom: (625.1.9 gtk)
  • Revision ID: jelmer@samba.org-20090525155723-e00yy9t9drnmmiye
Merge saving of widget sizes only on exit.

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
 
 
53
51
        if self.config.get_user_option('viz-compact-view') == 'yes':
54
52
            self.compact_view = True
55
53
        else:
69
67
            height = int(monitor.height * 0.75)
70
68
        self.set_default_size(width, height)
71
69
        self.set_size_request(width/3, height/3)
72
 
        self.connect("size-allocate", self._on_size_allocate, 'viz-window-size')
 
70
        self._save_size_on_destroy(self, 'viz-window-size')
73
71
 
74
72
        # FIXME AndyFitz!
75
73
        icon = self.render_icon(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON)
104
102
 
105
103
        self.construct()
106
104
 
 
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
 
107
114
    def set_revision(self, revid):
108
115
        self.treeview.set_revision_id(revid)
109
116
 
315
322
        else:
316
323
            (width, height) = self.get_size()
317
324
            align.set_size_request(width, int(height / 2.5))
318
 
        align.connect('size-allocate', self._on_size_allocate, 'viz-graph-size')
 
325
        self._save_size_on_destroy(align, 'viz-graph-size')
319
326
        align.show()
320
327
 
321
328
        return align
358
365
        if size:
359
366
            width, height = size
360
367
            self.revisionview.set_size_request(width, height)
361
 
        self.revisionview.connect('size-allocate', self._on_size_allocate, 'viz-revisionview-size')
 
368
        self._save_size_on_destroy(self.revisionview, 'viz-revisionview-size')
362
369
        self.revisionview.show()
363
370
        self.revisionview.set_show_callback(self._show_clicked_cb)
364
371
        self.revisionview.connect('notify::revision', self._go_clicked_cb)
597
604
        if size:
598
605
            width, height = [int(num) for num in size.split('x')]
599
606
            # avoid writing config every time we start
600
 
            self._sizes[name] = (width, height)
601
607
            return width, height
602
608
        return None
603
609
 
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
610
    def show_diff(self, revid=None, parentid=NULL_REVISION):
620
611
        """Open a new window to show a diff between the given revisions."""
621
612
        from bzrlib.plugins.gtk.diff import DiffWindow