/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
1 by Scott James Remnant
Commit the first version of bzrk.
1
# -*- coding: UTF-8 -*-
2
"""Branch window.
3
4
This module contains the code to manage the branch information window,
5
which contains both the revision graph and details panes.
6
"""
7
8
__copyright__ = "Copyright © 2005 Canonical Ltd."
9
__author__    = "Scott James Remnant <scott@ubuntu.com>"
10
11
12
import gtk
13
import gobject
14
import pango
15
450.4.1 by Daniel Schierbeck
Added tag icon to branch history window.
16
from bzrlib.plugins.gtk import icon_path
523.3.2 by Jelmer Vernooij
Share same menu for context menu and main menu.
17
from bzrlib.plugins.gtk.branchview import TreeView, treemodel
365 by Daniel Schierbeck
Fixed locks and made tagging work.
18
from bzrlib.plugins.gtk.tags import AddTagDialog
338 by Daniel Schierbeck
Added Preferences menu item.
19
from bzrlib.plugins.gtk.preferences import PreferencesWindow
523.3.2 by Jelmer Vernooij
Share same menu for context menu and main menu.
20
from bzrlib.plugins.gtk.revisionmenu import RevisionMenu
21
from bzrlib.plugins.gtk.window import Window
511.6.1 by Jelmer Vernooij
Add Branch/Index option if bzr-search is available.
22
23
from bzrlib.config import BranchConfig, GlobalConfig
443 by Szilveszter Farkas (Phanatic)
Trivial fix for #149061 (be able to show the diff for revision 1).
24
from bzrlib.revision import Revision, NULL_REVISION
511.6.1 by Jelmer Vernooij
Add Branch/Index option if bzr-search is available.
25
from bzrlib.trace import mutter
1 by Scott James Remnant
Commit the first version of bzrk.
26
298.2.1 by Daniel Schierbeck
Refactored the GTK window code, creating a single base window class that handles keyboard events.
27
class BranchWindow(Window):
1 by Scott James Remnant
Commit the first version of bzrk.
28
    """Branch window.
29
30
    This object represents and manages a single window containing information
31
    for a particular branch.
32
    """
33
452.4.1 by Jelmer Vernooij
Support displaying multiple tips in viz.
34
    def __init__(self, branch, start_revs, maxnum, parent=None):
322 by Jelmer Vernooij
Add docstrings.
35
        """Create a new BranchWindow.
36
37
        :param branch: Branch object for branch to show.
452.4.1 by Jelmer Vernooij
Support displaying multiple tips in viz.
38
        :param start_revs: Revision ids of top revisions.
322 by Jelmer Vernooij
Add docstrings.
39
        :param maxnum: Maximum number of revisions to display, 
40
                       None for no limit.
41
        """
42
298.2.1 by Daniel Schierbeck
Refactored the GTK window code, creating a single base window class that handles keyboard events.
43
        Window.__init__(self, parent=parent)
1 by Scott James Remnant
Commit the first version of bzrk.
44
        self.set_border_width(0)
315 by Daniel Schierbeck
Removed BranchWindow.set_branch(), used constructor instead.
45
330.2.4 by Daniel Schierbeck
Made use of compact view optional.
46
        self.branch      = branch
452.4.1 by Jelmer Vernooij
Support displaying multiple tips in viz.
47
        self.start_revs  = start_revs
330.2.4 by Daniel Schierbeck
Made use of compact view optional.
48
        self.maxnum      = maxnum
330.2.5 by Daniel Schierbeck
Support persistence of compact view option.
49
        self.config      = GlobalConfig()
50
531.7.9 by Scott Scriven
Made vis remember window and panel sizes.
51
        self._sizes      = {} # window and widget sizes
52
330.2.5 by Daniel Schierbeck
Support persistence of compact view option.
53
        if self.config.get_user_option('viz-compact-view') == 'yes':
54
            self.compact_view = True
55
        else:
56
            self.compact_view = False
315 by Daniel Schierbeck
Removed BranchWindow.set_branch(), used constructor instead.
57
58
        self.set_title(branch.nick + " - revision history")
1 by Scott James Remnant
Commit the first version of bzrk.
59
531.7.9 by Scott Scriven
Made vis remember window and panel sizes.
60
        # user-configured window size
531.7.10 by Scott Scriven
Simplified size-loading code. No longer saves identical config every time vis runs.
61
        size = self._load_size('viz-window-size')
62
        if size:
63
            width, height = size
555.2.1 by Jasper Groenewegen
Modify DiffWidget to include a checkbutton to wrap long lines in the diff view
64
        else:
65
            # Use three-quarters of the screen by default
66
            screen = self.get_screen()
67
            monitor = screen.get_monitor_geometry(0)
68
            width = int(monitor.width * 0.75)
69
            height = int(monitor.height * 0.75)
1 by Scott James Remnant
Commit the first version of bzrk.
70
        self.set_default_size(width, height)
531.7.8 by Scott Scriven
Made viz window shrinkable.
71
        self.set_size_request(width/3, height/3)
531.7.9 by Scott Scriven
Made vis remember window and panel sizes.
72
        self.connect("size-allocate", self._on_size_allocate, 'viz-window-size')
1 by Scott James Remnant
Commit the first version of bzrk.
73
74
        # FIXME AndyFitz!
75
        icon = self.render_icon(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON)
76
        self.set_icon(icon)
77
384 by Daniel Schierbeck
Added accelerator for Next Revision action.
78
        gtk.accel_map_add_entry("<viz>/Go/Next Revision", gtk.keysyms.Up, gtk.gdk.MOD1_MASK)
383 by Daniel Schierbeck
Switched to using symbolic names for keyvals.
79
        gtk.accel_map_add_entry("<viz>/Go/Previous Revision", gtk.keysyms.Down, gtk.gdk.MOD1_MASK)
499.1.1 by Russ Brown
Added Refresh menu option with keyboard shortcut to viz
80
        gtk.accel_map_add_entry("<viz>/View/Refresh", gtk.keysyms.F5, 0)
382 by Daniel Schierbeck
Made accelerator for Previous Revision work.
81
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
82
        self.accel_group = gtk.AccelGroup()
83
        self.add_accel_group(self.accel_group)
84
388 by Daniel Schierbeck
Switched to using the Previous/Next Revision actions to create tool buttons.
85
        gtk.Action.set_tool_item_type(gtk.MenuToolButton)
86
385 by Daniel Schierbeck
Created a single action for Previous Revision.
87
        self.prev_rev_action = gtk.Action("prev-rev", "_Previous Revision", "Go to the previous revision", gtk.STOCK_GO_DOWN)
88
        self.prev_rev_action.set_accel_path("<viz>/Go/Previous Revision")
89
        self.prev_rev_action.set_accel_group(self.accel_group)
90
        self.prev_rev_action.connect("activate", self._back_clicked_cb)
91
        self.prev_rev_action.connect_accelerator()
92
386 by Daniel Schierbeck
Created a single action for Next Revision.
93
        self.next_rev_action = gtk.Action("next-rev", "_Next Revision", "Go to the next revision", gtk.STOCK_GO_UP)
94
        self.next_rev_action.set_accel_path("<viz>/Go/Next Revision")
95
        self.next_rev_action.set_accel_group(self.accel_group)
96
        self.next_rev_action.connect("activate", self._fwd_clicked_cb)
97
        self.next_rev_action.connect_accelerator()
98
499.1.1 by Russ Brown
Added Refresh menu option with keyboard shortcut to viz
99
        self.refresh_action = gtk.Action("refresh", "_Refresh", "Refresh view", gtk.STOCK_REFRESH)
100
        self.refresh_action.set_accel_path("<viz>/View/Refresh")
101
        self.refresh_action.set_accel_group(self.accel_group)
102
        self.refresh_action.connect("activate", self._refresh_clicked)
103
        self.refresh_action.connect_accelerator()
104
1 by Scott James Remnant
Commit the first version of bzrk.
105
        self.construct()
106
369 by Daniel Schierbeck
Fixed bug with compact view toggling.
107
    def set_revision(self, revid):
108
        self.treeview.set_revision_id(revid)
330.2.4 by Daniel Schierbeck
Made use of compact view optional.
109
1 by Scott James Remnant
Commit the first version of bzrk.
110
    def construct(self):
111
        """Construct the window contents."""
331 by Daniel Schierbeck
Added basic menu bar.
112
        vbox = gtk.VBox(spacing=0)
44 by David Allouche
reorganise branch window
113
        self.add(vbox)
114
375 by Daniel Schierbeck
Fixed crash when toggling compact view.
115
        self.paned = gtk.VPaned()
531.7.9 by Scott Scriven
Made vis remember window and panel sizes.
116
        self.paned.pack1(self.construct_top(), resize=False, shrink=True)
117
        self.paned.pack2(self.construct_bottom(), resize=True, shrink=False)
375 by Daniel Schierbeck
Fixed crash when toggling compact view.
118
        self.paned.show()
358 by Daniel Schierbeck
Generalized the hiding/showing code.
119
531.7.2 by Scott Scriven
Made 'vis' save/load visibility of its toolbar.
120
        nav = self.construct_navigation()
121
        menubar = self.construct_menubar()
122
        vbox.pack_start(menubar, expand=False, fill=True)
123
        vbox.pack_start(nav, expand=False, fill=True)
124
369 by Daniel Schierbeck
Fixed bug with compact view toggling.
125
        vbox.pack_start(self.paned, expand=True, fill=True)
126
        vbox.set_focus_child(self.paned)
44 by David Allouche
reorganise branch window
127
624 by Jelmer Vernooij
Delay registration of signals to prevent problems when signal handlers use not yet constructed widgets.
128
        self.treeview.connect('revision-selected',
129
                self._treeselection_changed_cb)
130
        self.treeview.connect('revision-activated',
131
                self._tree_revision_activated)
132
133
        self.treeview.connect('tag-added', lambda w, t, r: self._update_tags())
44 by David Allouche
reorganise branch window
134
        vbox.show()
555.2.2 by Jasper Groenewegen
Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff
135
    
331 by Daniel Schierbeck
Added basic menu bar.
136
    def construct_menubar(self):
137
        menubar = gtk.MenuBar()
138
139
        file_menu = gtk.Menu()
334 by Daniel Schierbeck
Added icons to menus.
140
        file_menuitem = gtk.MenuItem("_File")
331 by Daniel Schierbeck
Added basic menu bar.
141
        file_menuitem.set_submenu(file_menu)
142
362 by Daniel Schierbeck
Added accel group to File -> Close menu item.
143
        file_menu_close = gtk.ImageMenuItem(gtk.STOCK_CLOSE, self.accel_group)
331 by Daniel Schierbeck
Added basic menu bar.
144
        file_menu_close.connect('activate', lambda x: self.destroy())
145
        
363 by Daniel Schierbeck
Added File -> Quit menu item.
146
        file_menu_quit = gtk.ImageMenuItem(gtk.STOCK_QUIT, self.accel_group)
147
        file_menu_quit.connect('activate', lambda x: gtk.main_quit())
148
        
408 by Daniel Schierbeck
Made the close menu item actually appear when the viz is opened from another window.
149
        if self._parent is not None:
406 by Daniel Schierbeck
Made the viz show the close menu item only if opened from another window.
150
            file_menu.add(file_menu_close)
363 by Daniel Schierbeck
Added File -> Quit menu item.
151
        file_menu.add(file_menu_quit)
331 by Daniel Schierbeck
Added basic menu bar.
152
338 by Daniel Schierbeck
Added Preferences menu item.
153
        edit_menu = gtk.Menu()
154
        edit_menuitem = gtk.MenuItem("_Edit")
155
        edit_menuitem.set_submenu(edit_menu)
156
361 by Daniel Schierbeck
Added branch settings menu item.
157
        edit_menu_branchopts = gtk.MenuItem("Branch Settings")
158
        edit_menu_branchopts.connect('activate', lambda x: PreferencesWindow(self.branch.get_config()).show())
159
407 by Daniel Schierbeck
Renamed Preferences menu item into Global Settings.
160
        edit_menu_globopts = gtk.MenuItem("Global Settings")
161
        edit_menu_globopts.connect('activate', lambda x: PreferencesWindow().show())
338 by Daniel Schierbeck
Added Preferences menu item.
162
361 by Daniel Schierbeck
Added branch settings menu item.
163
        edit_menu.add(edit_menu_branchopts)
407 by Daniel Schierbeck
Renamed Preferences menu item into Global Settings.
164
        edit_menu.add(edit_menu_globopts)
338 by Daniel Schierbeck
Added Preferences menu item.
165
348 by Daniel Schierbeck
Added toggle item for revision number column.
166
        view_menu = gtk.Menu()
167
        view_menuitem = gtk.MenuItem("_View")
168
        view_menuitem.set_submenu(view_menu)
169
499.1.1 by Russ Brown
Added Refresh menu option with keyboard shortcut to viz
170
        view_menu_refresh = self.refresh_action.create_menu_item()
171
        view_menu_refresh.connect('activate', self._refresh_clicked)
172
173
        view_menu.add(view_menu_refresh)
174
        view_menu.add(gtk.SeparatorMenuItem())
175
351 by Daniel Schierbeck
Added option to hide the toolbar.
176
        view_menu_toolbar = gtk.CheckMenuItem("Show Toolbar")
177
        view_menu_toolbar.set_active(True)
531.7.2 by Scott Scriven
Made 'vis' save/load visibility of its toolbar.
178
        if self.config.get_user_option('viz-toolbar-visible') == 'False':
179
            view_menu_toolbar.set_active(False)
180
            self.toolbar.hide()
351 by Daniel Schierbeck
Added option to hide the toolbar.
181
        view_menu_toolbar.connect('toggled', self._toolbar_visibility_changed)
182
370 by Daniel Schierbeck
Moved compact graph toggle to the menubar.
183
        view_menu_compact = gtk.CheckMenuItem("Show Compact Graph")
184
        view_menu_compact.set_active(self.compact_view)
185
        view_menu_compact.connect('activate', self._brokenlines_toggled_cb)
555.2.2 by Jasper Groenewegen
Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff
186
        
531.7.3 by Scott Scriven
Added an option to show/hide the diff panel.
187
        view_menu_diffs = gtk.CheckMenuItem("Show Diffs")
531.7.12 by Scott Scriven
Made diff panel default to off.
188
        view_menu_diffs.set_active(False)
189
        if self.config.get_user_option('viz-show-diffs') == 'True':
190
            view_menu_diffs.set_active(True)
531.7.3 by Scott Scriven
Added an option to show/hide the diff panel.
191
        view_menu_diffs.connect('toggled', self._diff_visibility_changed)
555.2.2 by Jasper Groenewegen
Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff
192
        
531.7.14 by Scott Scriven
Made diff placement configurable (bottom-right, or bottom full-width).
193
        view_menu_wide_diffs = gtk.CheckMenuItem("Wide Diffs")
194
        view_menu_wide_diffs.set_active(False)
195
        if self.config.get_user_option('viz-wide-diffs') == 'True':
196
            view_menu_wide_diffs.set_active(True)
197
        view_menu_wide_diffs.connect('toggled', self._diff_placement_changed)
555.2.2 by Jasper Groenewegen
Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff
198
        
571 by Jasper Groenewegen
Merge addition of word wrap control to gdiff and visualise windows
199
        view_menu_wrap_diffs = gtk.CheckMenuItem("Wrap _Long Lines in Diffs")
555.2.2 by Jasper Groenewegen
Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff
200
        view_menu_wrap_diffs.set_active(False)
201
        if self.config.get_user_option('viz-wrap-diffs') == 'True':
202
            view_menu_wrap_diffs.set_active(True)
203
        view_menu_wrap_diffs.connect('toggled', self._diff_wrap_changed)
204
                
351 by Daniel Schierbeck
Added option to hide the toolbar.
205
        view_menu.add(view_menu_toolbar)
370 by Daniel Schierbeck
Moved compact graph toggle to the menubar.
206
        view_menu.add(view_menu_compact)
555.2.2 by Jasper Groenewegen
Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff
207
        view_menu.add(gtk.SeparatorMenuItem())
531.7.3 by Scott Scriven
Added an option to show/hide the diff panel.
208
        view_menu.add(view_menu_diffs)
531.7.14 by Scott Scriven
Made diff placement configurable (bottom-right, or bottom full-width).
209
        view_menu.add(view_menu_wide_diffs)
555.2.2 by Jasper Groenewegen
Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff
210
        view_menu.add(view_menu_wrap_diffs)
351 by Daniel Schierbeck
Added option to hide the toolbar.
211
        view_menu.add(gtk.SeparatorMenuItem())
358 by Daniel Schierbeck
Generalized the hiding/showing code.
212
452.4.2 by Jelmer Vernooij
Hide revision number column if more than one branch was specified.
213
        self.mnu_show_revno_column = gtk.CheckMenuItem("Show Revision _Number Column")
214
        self.mnu_show_date_column = gtk.CheckMenuItem("Show _Date Column")
215
216
        # Revision numbers are pointless if there are multiple branches
217
        if len(self.start_revs) > 1:
218
            self.mnu_show_revno_column.set_sensitive(False)
219
            self.treeview.set_property('revno-column-visible', False)
220
221
        for (col, name) in [(self.mnu_show_revno_column, "revno"), 
222
                            (self.mnu_show_date_column, "date")]:
358 by Daniel Schierbeck
Generalized the hiding/showing code.
223
            col.set_active(self.treeview.get_property(name + "-column-visible"))
224
            col.connect('toggled', self._col_visibility_changed, name)
225
            view_menu.add(col)
348 by Daniel Schierbeck
Added toggle item for revision number column.
226
331 by Daniel Schierbeck
Added basic menu bar.
227
        go_menu = gtk.Menu()
382 by Daniel Schierbeck
Made accelerator for Previous Revision work.
228
        go_menu.set_accel_group(self.accel_group)
334 by Daniel Schierbeck
Added icons to menus.
229
        go_menuitem = gtk.MenuItem("_Go")
331 by Daniel Schierbeck
Added basic menu bar.
230
        go_menuitem.set_submenu(go_menu)
231
        
390 by Daniel Schierbeck
Made the Previous/Next Revision menu items local variables.
232
        go_menu_next = self.next_rev_action.create_menu_item()
233
        go_menu_prev = self.prev_rev_action.create_menu_item()
334 by Daniel Schierbeck
Added icons to menus.
234
450.4.1 by Daniel Schierbeck
Added tag icon to branch history window.
235
        tag_image = gtk.Image()
236
        tag_image.set_from_file(icon_path("tag-16.png"))
237
        self.go_menu_tags = gtk.ImageMenuItem("_Tags")
238
        self.go_menu_tags.set_image(tag_image)
587 by Jelmer Vernooij
Avoid determining tags until tags widget has been added.
239
        self.treeview.connect('refreshed', lambda w: self._update_tags())
399 by Daniel Schierbeck
Made tags menu insensitive when there are no tags to display.
240
390 by Daniel Schierbeck
Made the Previous/Next Revision menu items local variables.
241
        go_menu.add(go_menu_next)
242
        go_menu.add(go_menu_prev)
334 by Daniel Schierbeck
Added icons to menus.
243
        go_menu.add(gtk.SeparatorMenuItem())
423.7.5 by Daniel Schierbeck
Made the revision history window update the Go->Tags menu when a tag is added.
244
        go_menu.add(self.go_menu_tags)
334 by Daniel Schierbeck
Added icons to menus.
245
523.3.2 by Jelmer Vernooij
Share same menu for context menu and main menu.
246
        self.revision_menu = RevisionMenu(self.branch.repository, [], self.branch, parent=self)
335 by Daniel Schierbeck
Added Revision menu.
247
        revision_menuitem = gtk.MenuItem("_Revision")
523.3.2 by Jelmer Vernooij
Share same menu for context menu and main menu.
248
        revision_menuitem.set_submenu(self.revision_menu)
335 by Daniel Schierbeck
Added Revision menu.
249
334 by Daniel Schierbeck
Added icons to menus.
250
        branch_menu = gtk.Menu()
251
        branch_menuitem = gtk.MenuItem("_Branch")
252
        branch_menuitem.set_submenu(branch_menu)
253
336 by Daniel Schierbeck
Changed wording to comply with HIG guidelines.
254
        branch_menu.add(gtk.MenuItem("Pu_ll Revisions"))
255
        branch_menu.add(gtk.MenuItem("Pu_sh Revisions"))
371.1.1 by Daniel Schierbeck
Added About dialog to the viz.
256
511.6.1 by Jelmer Vernooij
Add Branch/Index option if bzr-search is available.
257
        try:
258
            from bzrlib.plugins import search
259
        except ImportError:
260
            mutter("Didn't find search plugin")
261
        else:
526 by Jelmer Vernooij
Switch to found revision when clicking ok in search window.
262
            branch_menu.add(gtk.SeparatorMenuItem())
263
511.6.1 by Jelmer Vernooij
Add Branch/Index option if bzr-search is available.
264
            branch_index_menuitem = gtk.MenuItem("_Index")
265
            branch_index_menuitem.connect('activate', self._branch_index_cb)
266
            branch_menu.add(branch_index_menuitem)
267
524 by Jelmer Vernooij
Add search dialog.
268
            branch_search_menuitem = gtk.MenuItem("_Search")
269
            branch_search_menuitem.connect('activate', self._branch_search_cb)
270
            branch_menu.add(branch_search_menuitem)
271
423.9.1 by Daniel Schierbeck
Added Help->About menu item to the viz.
272
        help_menu = gtk.Menu()
273
        help_menuitem = gtk.MenuItem("_Help")
274
        help_menuitem.set_submenu(help_menu)
275
276
        help_about_menuitem = gtk.ImageMenuItem(gtk.STOCK_ABOUT, self.accel_group)
277
        help_about_menuitem.connect('activate', self._about_dialog_cb)
278
279
        help_menu.add(help_about_menuitem)
280
331 by Daniel Schierbeck
Added basic menu bar.
281
        menubar.add(file_menuitem)
338 by Daniel Schierbeck
Added Preferences menu item.
282
        menubar.add(edit_menuitem)
348 by Daniel Schierbeck
Added toggle item for revision number column.
283
        menubar.add(view_menuitem)
331 by Daniel Schierbeck
Added basic menu bar.
284
        menubar.add(go_menuitem)
335 by Daniel Schierbeck
Added Revision menu.
285
        menubar.add(revision_menuitem)
331 by Daniel Schierbeck
Added basic menu bar.
286
        menubar.add(branch_menuitem)
423.9.1 by Daniel Schierbeck
Added Help->About menu item to the viz.
287
        menubar.add(help_menuitem)
331 by Daniel Schierbeck
Added basic menu bar.
288
        menubar.show_all()
289
290
        return menubar
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
291
292
    def construct_top(self):
293
        """Construct the top-half of the window."""
329 by Jelmer Vernooij
Make broken_line_length setting from higher up.
294
        # FIXME: Make broken_line_length configurable
330.2.5 by Daniel Schierbeck
Support persistence of compact view option.
295
452.4.1 by Jelmer Vernooij
Support displaying multiple tips in viz.
296
        self.treeview = TreeView(self.branch, self.start_revs, self.maxnum, self.compact_view)
315 by Daniel Schierbeck
Removed BranchWindow.set_branch(), used constructor instead.
297
373 by Daniel Schierbeck
Made column display options persisted.
298
        for col in ["revno", "date"]:
299
            option = self.config.get_user_option(col + '-column-visible')
300
            if option is not None:
301
                self.treeview.set_property(col + '-column-visible', option == 'True')
464.1.1 by Adrian Wilkins
Fixed column visibility properties not loading
302
            else:
303
                self.treeview.set_property(col + '-column-visible', False)
373 by Daniel Schierbeck
Made column display options persisted.
304
1 by Scott James Remnant
Commit the first version of bzrk.
305
        self.treeview.show()
306
375 by Daniel Schierbeck
Fixed crash when toggling compact view.
307
        align = gtk.Alignment(0.0, 0.0, 1.0, 1.0)
308
        align.set_padding(5, 0, 0, 0)
309
        align.add(self.treeview)
531.7.9 by Scott Scriven
Made vis remember window and panel sizes.
310
        # user-configured size
531.7.10 by Scott Scriven
Simplified size-loading code. No longer saves identical config every time vis runs.
311
        size = self._load_size('viz-graph-size')
312
        if size:
313
            width, height = size
531.7.9 by Scott Scriven
Made vis remember window and panel sizes.
314
            align.set_size_request(width, height)
315
        else:
316
            (width, height) = self.get_size()
317
            align.set_size_request(width, int(height / 2.5))
318
        align.connect('size-allocate', self._on_size_allocate, 'viz-graph-size')
375 by Daniel Schierbeck
Fixed crash when toggling compact view.
319
        align.show()
320
321
        return align
44 by David Allouche
reorganise branch window
322
323
    def construct_navigation(self):
324
        """Construct the navigation buttons."""
325 by Daniel Schierbeck
Switched to using a real toolbar for the viz navigation.
325
        self.toolbar = gtk.Toolbar()
326
        self.toolbar.set_style(gtk.TOOLBAR_BOTH_HORIZ)
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
327
388 by Daniel Schierbeck
Switched to using the Previous/Next Revision actions to create tool buttons.
328
        self.prev_button = self.prev_rev_action.create_tool_item()
376 by Daniel Schierbeck
Changed 'back' into 'prev' and 'fwd' into 'next'.
329
        self.toolbar.insert(self.prev_button, -1)
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
330
388 by Daniel Schierbeck
Switched to using the Previous/Next Revision actions to create tool buttons.
331
        self.next_button = self.next_rev_action.create_tool_item()
376 by Daniel Schierbeck
Changed 'back' into 'prev' and 'fwd' into 'next'.
332
        self.toolbar.insert(self.next_button, -1)
330.2.4 by Daniel Schierbeck
Made use of compact view optional.
333
401.1.2 by Daniel Schierbeck
Allowed the treeview to be refreshed.
334
        self.toolbar.insert(gtk.SeparatorToolItem(), -1)
335
336
        refresh_button = gtk.ToolButton(gtk.STOCK_REFRESH)
404 by Daniel Schierbeck
Made the refresh use proper locking.
337
        refresh_button.connect('clicked', self._refresh_clicked)
401.1.2 by Daniel Schierbeck
Allowed the treeview to be refreshed.
338
        self.toolbar.insert(refresh_button, -1)
339
330.2.4 by Daniel Schierbeck
Made use of compact view optional.
340
        self.toolbar.show_all()
325 by Daniel Schierbeck
Switched to using a real toolbar for the viz navigation.
341
342
        return self.toolbar
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
343
344
    def construct_bottom(self):
345
        """Construct the bottom half of the window."""
531.7.14 by Scott Scriven
Made diff placement configurable (bottom-right, or bottom full-width).
346
        if self.config.get_user_option('viz-wide-diffs') == 'True':
347
            self.diff_paned = gtk.VPaned()
348
        else:
349
            self.diff_paned = gtk.HPaned()
531.7.1 by Scott Scriven
Added a diff panel to otherwise-blank area in 'bzr vis'.
350
        (width, height) = self.get_size()
531.7.14 by Scott Scriven
Made diff placement configurable (bottom-right, or bottom full-width).
351
        self.diff_paned.set_size_request(20, 20) # shrinkable
531.7.1 by Scott Scriven
Added a diff panel to otherwise-blank area in 'bzr vis'.
352
330.3.1 by Daniel Schierbeck
Renamed logview 'revisionview'.
353
        from bzrlib.plugins.gtk.revisionview import RevisionView
412.1.2 by Daniel Schierbeck
Moved retrieval of tags into the revisionview itself.
354
        self.revisionview = RevisionView(branch=self.branch)
531.7.1 by Scott Scriven
Added a diff panel to otherwise-blank area in 'bzr vis'.
355
        self.revisionview.set_size_request(width/3, int(height / 2.5))
531.7.9 by Scott Scriven
Made vis remember window and panel sizes.
356
        # user-configured size
531.7.10 by Scott Scriven
Simplified size-loading code. No longer saves identical config every time vis runs.
357
        size = self._load_size('viz-revisionview-size')
358
        if size:
359
            width, height = size
531.7.9 by Scott Scriven
Made vis remember window and panel sizes.
360
            self.revisionview.set_size_request(width, height)
361
        self.revisionview.connect('size-allocate', self._on_size_allocate, 'viz-revisionview-size')
330.3.1 by Daniel Schierbeck
Renamed logview 'revisionview'.
362
        self.revisionview.show()
363
        self.revisionview.set_show_callback(self._show_clicked_cb)
412.1.9 by Daniel Schierbeck
Removed the use of RevisionView.set_go_callback().
364
        self.revisionview.connect('notify::revision', self._go_clicked_cb)
423.7.4 by Daniel Schierbeck
Made revisionview and branchview update when a tag is added.
365
        self.treeview.connect('tag-added', lambda w, t, r: self.revisionview.update_tags())
531.7.14 by Scott Scriven
Made diff placement configurable (bottom-right, or bottom full-width).
366
        self.diff_paned.pack1(self.revisionview)
531.7.1 by Scott Scriven
Added a diff panel to otherwise-blank area in 'bzr vis'.
367
368
        from bzrlib.plugins.gtk.diff import DiffWidget
369
        self.diff = DiffWidget()
531.7.14 by Scott Scriven
Made diff placement configurable (bottom-right, or bottom full-width).
370
        self.diff_paned.pack2(self.diff)
531.7.1 by Scott Scriven
Added a diff panel to otherwise-blank area in 'bzr vis'.
371
531.7.14 by Scott Scriven
Made diff placement configurable (bottom-right, or bottom full-width).
372
        self.diff_paned.show_all()
531.7.12 by Scott Scriven
Made diff panel default to off.
373
        if self.config.get_user_option('viz-show-diffs') != 'True':
531.7.3 by Scott Scriven
Added an option to show/hide the diff panel.
374
            self.diff.hide()
375
531.7.14 by Scott Scriven
Made diff placement configurable (bottom-right, or bottom full-width).
376
        return self.diff_paned
332 by Daniel Schierbeck
Made tag selection work.
377
378
    def _tag_selected_cb(self, menuitem, revid):
356 by Daniel Schierbeck
Made revision a property on TreeView.
379
        self.treeview.set_revision_id(revid)
341 by Daniel Schierbeck
Merged with trunk.
380
280.1.2 by Daniel Schierbeck
Switched to handle the 'changed' signal from the treeview's treeselection instead of the 'cursor-changed' signal from the treeview itself, allowing more flexibility (particularly the ability to handle programmatic selections)
381
    def _treeselection_changed_cb(self, selection, *args):
303 by Daniel Schierbeck
Made basic signaling work.
382
        """callback for when the treeview changes."""
383
        revision = self.treeview.get_revision()
384
        parents  = self.treeview.get_parents()
385
        children = self.treeview.get_children()
386
523.3.2 by Jelmer Vernooij
Share same menu for context menu and main menu.
387
        self.revision_menu.set_revision_ids([revision.revision_id])
388
464.2.1 by Adrian Wilkins
Detect the reserved null: revision in appropriate places.
389
        if revision and revision != NULL_REVISION:
376 by Daniel Schierbeck
Changed 'back' into 'prev' and 'fwd' into 'next'.
390
            prev_menu = gtk.Menu()
352.1.1 by Daniel Schierbeck
Added dropdown menu to Back button.
391
            if len(parents) > 0:
385 by Daniel Schierbeck
Created a single action for Previous Revision.
392
                self.prev_rev_action.set_sensitive(True)
352.1.1 by Daniel Schierbeck
Added dropdown menu to Back button.
393
                for parent_id in parents:
464.2.1 by Adrian Wilkins
Detect the reserved null: revision in appropriate places.
394
                    if parent_id and parent_id != NULL_REVISION:
395
                        parent = self.branch.repository.get_revision(parent_id)
396
                        try:
397
                            str = ' (' + parent.properties['branch-nick'] + ')'
398
                        except KeyError:
399
                            str = ""
355 by Daniel Schierbeck
Appended branch nick to parent and child popup menus.
400
464.2.1 by Adrian Wilkins
Detect the reserved null: revision in appropriate places.
401
                        item = gtk.MenuItem(parent.message.split("\n")[0] + str)
402
                        item.connect('activate', self._set_revision_cb, parent_id)
403
                        prev_menu.add(item)
376 by Daniel Schierbeck
Changed 'back' into 'prev' and 'fwd' into 'next'.
404
                prev_menu.show_all()
352.1.1 by Daniel Schierbeck
Added dropdown menu to Back button.
405
            else:
385 by Daniel Schierbeck
Created a single action for Previous Revision.
406
                self.prev_rev_action.set_sensitive(False)
376 by Daniel Schierbeck
Changed 'back' into 'prev' and 'fwd' into 'next'.
407
                prev_menu.hide()
408
409
            self.prev_button.set_menu(prev_menu)
410
411
            next_menu = gtk.Menu()
352.1.2 by Daniel Schierbeck
Added dropdown menu to Forward button.
412
            if len(children) > 0:
386 by Daniel Schierbeck
Created a single action for Next Revision.
413
                self.next_rev_action.set_sensitive(True)
352.1.2 by Daniel Schierbeck
Added dropdown menu to Forward button.
414
                for child_id in children:
415
                    child = self.branch.repository.get_revision(child_id)
355 by Daniel Schierbeck
Appended branch nick to parent and child popup menus.
416
                    try:
417
                        str = ' (' + child.properties['branch-nick'] + ')'
418
                    except KeyError:
419
                        str = ""
420
421
                    item = gtk.MenuItem(child.message.split("\n")[0] + str)
352.1.2 by Daniel Schierbeck
Added dropdown menu to Forward button.
422
                    item.connect('activate', self._set_revision_cb, child_id)
376 by Daniel Schierbeck
Changed 'back' into 'prev' and 'fwd' into 'next'.
423
                    next_menu.add(item)
424
                next_menu.show_all()
352.1.2 by Daniel Schierbeck
Added dropdown menu to Forward button.
425
            else:
386 by Daniel Schierbeck
Created a single action for Next Revision.
426
                self.next_rev_action.set_sensitive(False)
376 by Daniel Schierbeck
Changed 'back' into 'prev' and 'fwd' into 'next'.
427
                next_menu.hide()
352.1.2 by Daniel Schierbeck
Added dropdown menu to Forward button.
428
376 by Daniel Schierbeck
Changed 'back' into 'prev' and 'fwd' into 'next'.
429
            self.next_button.set_menu(next_menu)
352.1.2 by Daniel Schierbeck
Added dropdown menu to Forward button.
430
412.1.13 by Daniel Schierbeck
Re-added support for displaying the children of a revision.
431
            self.revisionview.set_revision(revision)
432
            self.revisionview.set_children(children)
531.7.3 by Scott Scriven
Added an option to show/hide the diff panel.
433
            self.update_diff_panel(revision, parents)
531.7.1 by Scott Scriven
Added a diff panel to otherwise-blank area in 'bzr vis'.
434
423.1.17 by Gary van der Merwe
Reuse the viz treeview in the revision browser.
435
    def _tree_revision_activated(self, widget, path, col):
436
        # TODO: more than one parent
437
        """Callback for when a treeview row gets activated."""
438
        revision = self.treeview.get_revision()
439
        parents  = self.treeview.get_parents()
440
441
        if len(parents) == 0:
627 by Jelmer Vernooij
Use NULL_REVISION rather than None.
442
            parent_id = NULL_REVISION
423.1.17 by Gary van der Merwe
Reuse the viz treeview in the revision browser.
443
        else:
444
            parent_id = parents[0]
445
446
        self.show_diff(revision.revision_id, parent_id)
447
        self.treeview.grab_focus()
463.3.1 by Javier Derderian
Fixed menu entry 'View Changes'. Bug #215350
448
        
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
449
    def _back_clicked_cb(self, *args):
450
        """Callback for when the back button is clicked."""
304 by Daniel Schierbeck
Made forward/back buttons work again.
451
        self.treeview.back()
452
        
5 by Scott James Remnant
Reverse the meaning of the Back and Forward buttons so Back actually
453
    def _fwd_clicked_cb(self, *args):
454
        """Callback for when the forward button is clicked."""
304 by Daniel Schierbeck
Made forward/back buttons work again.
455
        self.treeview.forward()
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
456
412.1.9 by Daniel Schierbeck
Removed the use of RevisionView.set_go_callback().
457
    def _go_clicked_cb(self, w, p):
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
458
        """Callback for when the go button for a parent is clicked."""
412.1.9 by Daniel Schierbeck
Removed the use of RevisionView.set_go_callback().
459
        if self.revisionview.get_revision() is not None:
460
            self.treeview.set_revision(self.revisionview.get_revision())
152 by Jelmer Vernooij
Cleanup some more code.
461
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
462
    def _show_clicked_cb(self, revid, parentid):
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
463
        """Callback for when the show button for a parent is clicked."""
423.1.17 by Gary van der Merwe
Reuse the viz treeview in the revision browser.
464
        self.show_diff(revid, parentid)
13 by Scott James Remnant
Keep the focus on the treeview
465
        self.treeview.grab_focus()
46 by Wouter van Heyst
show diff on row activation, LP# 44591
466
352.1.1 by Daniel Schierbeck
Added dropdown menu to Back button.
467
    def _set_revision_cb(self, w, revision_id):
356 by Daniel Schierbeck
Made revision a property on TreeView.
468
        self.treeview.set_revision_id(revision_id)
352.1.1 by Daniel Schierbeck
Added dropdown menu to Back button.
469
330.2.4 by Daniel Schierbeck
Made use of compact view optional.
470
    def _brokenlines_toggled_cb(self, button):
330.2.5 by Daniel Schierbeck
Support persistence of compact view option.
471
        self.compact_view = button.get_active()
472
473
        if self.compact_view:
474
            option = 'yes'
330.2.4 by Daniel Schierbeck
Made use of compact view optional.
475
        else:
330.2.5 by Daniel Schierbeck
Support persistence of compact view option.
476
            option = 'no'
477
478
        self.config.set_user_option('viz-compact-view', option)
401.1.3 by Daniel Schierbeck
Made the compact view toggling cleaner.
479
        self.treeview.set_property('compact', self.compact_view)
480
        self.treeview.refresh()
368 by Daniel Schierbeck
Merged with mainline.
481
511.6.1 by Jelmer Vernooij
Add Branch/Index option if bzr-search is available.
482
    def _branch_index_cb(self, w):
483
        from bzrlib.plugins.search import index as _mod_index
484
        _mod_index.index_url(self.branch.base)
485
524 by Jelmer Vernooij
Add search dialog.
486
    def _branch_search_cb(self, w):
533.11.1 by Jelmer Vernooij
Ask user whether to index if there is no index present yet.
487
        from bzrlib.plugins.search import index as _mod_index
524 by Jelmer Vernooij
Add search dialog.
488
        from bzrlib.plugins.gtk.search import SearchDialog
533.11.1 by Jelmer Vernooij
Ask user whether to index if there is no index present yet.
489
        from bzrlib.plugins.search import errors as search_errors
490
491
        try:
492
            index = _mod_index.open_index_url(self.branch.base)
493
        except search_errors.NoSearchIndex:
494
            dialog = gtk.MessageDialog(self, type=gtk.MESSAGE_QUESTION, 
495
                buttons=gtk.BUTTONS_OK_CANCEL, 
496
                message_format="This branch has not been indexed yet. "
497
                               "Index now?")
498
            if dialog.run() == gtk.RESPONSE_OK:
553 by Jelmer Vernooij
Merge asking the user whether to create an index.
499
                dialog.destroy()
533.11.1 by Jelmer Vernooij
Ask user whether to index if there is no index present yet.
500
                index = _mod_index.index_url(self.branch.base)
501
            else:
553 by Jelmer Vernooij
Merge asking the user whether to create an index.
502
                dialog.destroy()
533.11.1 by Jelmer Vernooij
Ask user whether to index if there is no index present yet.
503
                return
504
505
        dialog = SearchDialog(index)
526 by Jelmer Vernooij
Switch to found revision when clicking ok in search window.
506
        
507
        if dialog.run() == gtk.RESPONSE_OK:
508
            self.set_revision(dialog.get_revision())
509
510
        dialog.destroy()
524 by Jelmer Vernooij
Add search dialog.
511
423.9.1 by Daniel Schierbeck
Added Help->About menu item to the viz.
512
    def _about_dialog_cb(self, w):
513
        from bzrlib.plugins.gtk.about import AboutDialog
514
515
        AboutDialog().run()
516
348 by Daniel Schierbeck
Added toggle item for revision number column.
517
    def _col_visibility_changed(self, col, property):
373 by Daniel Schierbeck
Made column display options persisted.
518
        self.config.set_user_option(property + '-column-visible', col.get_active())
348 by Daniel Schierbeck
Added toggle item for revision number column.
519
        self.treeview.set_property(property + '-column-visible', col.get_active())
351 by Daniel Schierbeck
Added option to hide the toolbar.
520
521
    def _toolbar_visibility_changed(self, col):
522
        if col.get_active():
531.7.2 by Scott Scriven
Made 'vis' save/load visibility of its toolbar.
523
            self.toolbar.show()
351 by Daniel Schierbeck
Added option to hide the toolbar.
524
        else:
525
            self.toolbar.hide()
531.7.2 by Scott Scriven
Made 'vis' save/load visibility of its toolbar.
526
        self.config.set_user_option('viz-toolbar-visible', col.get_active())
371.1.1 by Daniel Schierbeck
Added About dialog to the viz.
527
531.7.14 by Scott Scriven
Made diff placement configurable (bottom-right, or bottom full-width).
528
    def _make_diff_nonzero_size(self):
529
        """make sure the diff isn't zero-width or zero-height"""
530
        alloc = self.diff.get_allocation()
531
        if (alloc.width < 10) or (alloc.height < 10):
532
            width, height = self.get_size()
533
            self.revisionview.set_size_request(width/3, int(height / 2.5))
534
531.7.3 by Scott Scriven
Added an option to show/hide the diff panel.
535
    def _diff_visibility_changed(self, col):
531.7.14 by Scott Scriven
Made diff placement configurable (bottom-right, or bottom full-width).
536
        """Hide or show the diff panel."""
531.7.3 by Scott Scriven
Added an option to show/hide the diff panel.
537
        if col.get_active():
538
            self.diff.show()
531.7.14 by Scott Scriven
Made diff placement configurable (bottom-right, or bottom full-width).
539
            self._make_diff_nonzero_size()
531.7.3 by Scott Scriven
Added an option to show/hide the diff panel.
540
        else:
541
            self.diff.hide()
542
        self.config.set_user_option('viz-show-diffs', str(col.get_active()))
543
        self.update_diff_panel()
544
531.7.14 by Scott Scriven
Made diff placement configurable (bottom-right, or bottom full-width).
545
    def _diff_placement_changed(self, col):
546
        """Toggle the diff panel's position."""
547
        self.config.set_user_option('viz-wide-diffs', str(col.get_active()))
548
549
        old = self.paned.get_child2()
550
        self.paned.remove(old)
551
        self.paned.pack2(self.construct_bottom(), resize=True, shrink=False)
552
        self._make_diff_nonzero_size()
553
554
        self.treeview.emit('revision-selected')
555.2.2 by Jasper Groenewegen
Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff
555
    
556
    def _diff_wrap_changed(self, widget):
557
        """Toggle word wrap in the diff widget."""
558
        self.config.set_user_option('viz-wrap-diffs', widget.get_active())
559
        self.diff._on_wraplines_toggled(widget)
560
    
371.1.1 by Daniel Schierbeck
Added About dialog to the viz.
561
    def _show_about_cb(self, w):
562
        dialog = AboutDialog()
563
        dialog.connect('response', lambda d,r: d.destroy())
564
        dialog.run()
404 by Daniel Schierbeck
Made the refresh use proper locking.
565
566
    def _refresh_clicked(self, w):
423.1.13 by Gary van der Merwe
Move viz loading msg from branchwin to treeview.
567
        self.treeview.refresh()
423.7.5 by Daniel Schierbeck
Made the revision history window update the Go->Tags menu when a tag is added.
568
569
    def _update_tags(self):
570
        menu = gtk.Menu()
571
572
        if self.branch.supports_tags():
573
            tags = self.branch.tags.get_tag_dict().items()
576.5.1 by Jelmer Vernooij
Disable the ability to click on tags that are not available in the current view.
574
            tags.sort(reverse=True)
423.7.5 by Daniel Schierbeck
Made the revision history window update the Go->Tags menu when a tag is added.
575
            for tag, revid in tags:
450.4.1 by Daniel Schierbeck
Added tag icon to branch history window.
576
                tag_image = gtk.Image()
577
                tag_image.set_from_file(icon_path('tag-16.png'))
578
                tag_item = gtk.ImageMenuItem(tag.replace('_', '__'))
579
                tag_item.set_image(tag_image)
423.7.5 by Daniel Schierbeck
Made the revision history window update the Go->Tags menu when a tag is added.
580
                tag_item.connect('activate', self._tag_selected_cb, revid)
576.5.1 by Jelmer Vernooij
Disable the ability to click on tags that are not available in the current view.
581
                tag_item.set_sensitive(self.treeview.has_revision_id(revid))
423.7.5 by Daniel Schierbeck
Made the revision history window update the Go->Tags menu when a tag is added.
582
                menu.add(tag_item)
583
            self.go_menu_tags.set_submenu(menu)
584
585
            self.go_menu_tags.set_sensitive(len(tags) != 0)
586
        else:
587
            self.go_menu_tags.set_sensitive(False)
588
589
        self.go_menu_tags.show_all()
590
531.7.10 by Scott Scriven
Simplified size-loading code. No longer saves identical config every time vis runs.
591
    def _load_size(self, name):
592
        """Read and parse 'name' from self.config.
593
        The value is a string, formatted as WIDTHxHEIGHT
594
        Returns None, or (width, height)
595
        """
596
        size = self.config.get_user_option(name)
597
        if size:
598
            width, height = [int(num) for num in size.split('x')]
599
            # avoid writing config every time we start
600
            self._sizes[name] = (width, height)
601
            return width, height
602
        return None
603
531.7.9 by Scott Scriven
Made vis remember window and panel sizes.
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
627 by Jelmer Vernooij
Use NULL_REVISION rather than None.
619
    def show_diff(self, revid=None, parentid=NULL_REVISION):
423.1.17 by Gary van der Merwe
Reuse the viz treeview in the revision browser.
620
        """Open a new window to show a diff between the given revisions."""
621
        from bzrlib.plugins.gtk.diff import DiffWindow
622
        window = DiffWindow(parent=self)
623
624
        rev_tree    = self.branch.repository.revision_tree(revid)
625
        parent_tree = self.branch.repository.revision_tree(parentid)
626
627
        description = revid + " - " + self.branch.nick
628
        window.set_diff(description, rev_tree, parent_tree)
629
        window.show()
630
531.7.3 by Scott Scriven
Added an option to show/hide the diff panel.
631
    def update_diff_panel(self, revision=None, parents=None):
632
        """Show the current revision in the diff panel."""
531.7.12 by Scott Scriven
Made diff panel default to off.
633
        if self.config.get_user_option('viz-show-diffs') != 'True':
531.7.3 by Scott Scriven
Added an option to show/hide the diff panel.
634
            return
635
636
        if not revision: # default to selected row
637
            revision = self.treeview.get_revision()
627 by Jelmer Vernooij
Use NULL_REVISION rather than None.
638
        if revision == NULL_REVISION:
531.7.3 by Scott Scriven
Added an option to show/hide the diff panel.
639
            return
640
641
        if not parents: # default to selected row's parents
642
            parents  = self.treeview.get_parents()
643
        if len(parents) == 0:
627 by Jelmer Vernooij
Use NULL_REVISION rather than None.
644
            parent_id = NULL_REVISION
531.7.3 by Scott Scriven
Added an option to show/hide the diff panel.
645
        else:
646
            parent_id = parents[0]
647
648
        rev_tree    = self.branch.repository.revision_tree(revision.revision_id)
649
        parent_tree = self.branch.repository.revision_tree(parent_id)
531.7.5 by Scott Scriven
Fixed DiffWidget so more than one call to set_diff() will work.
650
531.7.3 by Scott Scriven
Added an option to show/hide the diff panel.
651
        self.diff.set_diff(rev_tree, parent_tree)
555.2.2 by Jasper Groenewegen
Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff
652
        if self.config.get_user_option('viz-wrap-diffs') == 'True':
653
            self.diff._on_wraplines_toggled(wrap=True)
531.7.3 by Scott Scriven
Added an option to show/hide the diff panel.
654
        self.diff.show_all()