/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-11 17:25:46 UTC
  • mto: This revision was merged to the branch mainline in revision 549.
  • Revision ID: ubuntu@toykeeper.net-20080711172546-vvrbsrf6kiuu1nkv
Simplified size-loading code.  No longer saves identical config every time vis runs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
        width = int(monitor.width * 0.75)
64
64
        height = int(monitor.height * 0.75)
65
65
        # user-configured window size
66
 
        size = self.config.get_user_option('viz-window-size')
67
 
        if size: # string, "1234x567"
68
 
            width, height = [int(num) for num in size.split('x')]
 
66
        size = self._load_size('viz-window-size')
 
67
        if size:
 
68
            width, height = size
69
69
        self.set_default_size(width, height)
70
70
        self.set_size_request(width/3, height/3)
71
71
        self.connect("size-allocate", self._on_size_allocate, 'viz-window-size')
296
296
        align.set_padding(5, 0, 0, 0)
297
297
        align.add(self.treeview)
298
298
        # user-configured size
299
 
        size = self.config.get_user_option('viz-graph-size')
300
 
        if size: # string, "1234x567"
301
 
            width, height = [int(num) for num in size.split('x')]
 
299
        size = self._load_size('viz-graph-size')
 
300
        if size:
 
301
            width, height = size
302
302
            align.set_size_request(width, height)
303
303
        else:
304
304
            (width, height) = self.get_size()
339
339
        self.revisionview = RevisionView(branch=self.branch)
340
340
        self.revisionview.set_size_request(width/3, int(height / 2.5))
341
341
        # user-configured size
342
 
        size = self.config.get_user_option('viz-revisionview-size')
343
 
        if size: # string, "1234x567"
344
 
            width, height = [int(num) for num in size.split('x')]
 
342
        size = self._load_size('viz-revisionview-size')
 
343
        if size:
 
344
            width, height = size
345
345
            self.revisionview.set_size_request(width, height)
346
346
        self.revisionview.connect('size-allocate', self._on_size_allocate, 'viz-revisionview-size')
347
347
        self.revisionview.show()
537
537
 
538
538
        self.go_menu_tags.show_all()
539
539
 
 
540
    def _load_size(self, name):
 
541
        """Read and parse 'name' from self.config.
 
542
        The value is a string, formatted as WIDTHxHEIGHT
 
543
        Returns None, or (width, height)
 
544
        """
 
545
        size = self.config.get_user_option(name)
 
546
        if size:
 
547
            width, height = [int(num) for num in size.split('x')]
 
548
            # avoid writing config every time we start
 
549
            self._sizes[name] = (width, height)
 
550
            return width, height
 
551
        return None
 
552
 
540
553
    def _on_size_allocate(self, widget, allocation, name):
541
554
        """When window has been resized, save the new size."""
542
555
        width, height = 0, 0