48
48
self.maxnum = maxnum
49
49
self.config = GlobalConfig()
51
self._sizes = {} # window and widget sizes
51
53
if self.config.get_user_option('viz-compact-view') == 'yes':
52
54
self.compact_view = True
54
56
self.compact_view = False
56
self.set_title(branch._get_nick(local=True) + " - revision history")
58
self.set_title(branch.nick + " - revision history")
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')
73
75
icon = self.render_icon(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON)
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."""
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)
114
107
def set_revision(self, revid):
115
108
self.treeview.set_revision_id(revid)
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')
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)
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
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."""
607
if name in self._sizes:
608
width, height = self._sizes[name]
610
size_changed = (width != allocation.width) or \
611
(height != allocation.height)
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)
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)
625
parentid = NULL_REVISION
615
627
rev_tree = self.branch.repository.revision_tree(revid)
616
628
parent_tree = self.branch.repository.revision_tree(parentid)
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)
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):
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
637
649
parent_id = parents[0]