/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
298.2.1 by Daniel Schierbeck
Refactored the GTK window code, creating a single base window class that handles keyboard events.
16
from bzrlib.plugins.gtk.window import Window
365 by Daniel Schierbeck
Fixed locks and made tagging work.
17
from bzrlib.plugins.gtk.tags import AddTagDialog
338 by Daniel Schierbeck
Added Preferences menu item.
18
from bzrlib.plugins.gtk.preferences import PreferencesWindow
352.1.1 by Daniel Schierbeck
Added dropdown menu to Back button.
19
from bzrlib.revision import Revision
361 by Daniel Schierbeck
Added branch settings menu item.
20
from bzrlib.config import BranchConfig
330.2.5 by Daniel Schierbeck
Support persistence of compact view option.
21
from bzrlib.config import GlobalConfig
333 by Daniel Schierbeck
Removed unnecessary imports.
22
from treeview import TreeView
1 by Scott James Remnant
Commit the first version of bzrk.
23
298.2.1 by Daniel Schierbeck
Refactored the GTK window code, creating a single base window class that handles keyboard events.
24
class BranchWindow(Window):
1 by Scott James Remnant
Commit the first version of bzrk.
25
    """Branch window.
26
27
    This object represents and manages a single window containing information
28
    for a particular branch.
29
    """
30
315 by Daniel Schierbeck
Removed BranchWindow.set_branch(), used constructor instead.
31
    def __init__(self, branch, start, maxnum, parent=None):
322 by Jelmer Vernooij
Add docstrings.
32
        """Create a new BranchWindow.
33
34
        :param branch: Branch object for branch to show.
35
        :param start: Revision id of top revision.
36
        :param maxnum: Maximum number of revisions to display, 
37
                       None for no limit.
38
        """
39
298.2.1 by Daniel Schierbeck
Refactored the GTK window code, creating a single base window class that handles keyboard events.
40
        Window.__init__(self, parent=parent)
1 by Scott James Remnant
Commit the first version of bzrk.
41
        self.set_border_width(0)
315 by Daniel Schierbeck
Removed BranchWindow.set_branch(), used constructor instead.
42
330.2.4 by Daniel Schierbeck
Made use of compact view optional.
43
        self.branch      = branch
44
        self.start       = start
45
        self.maxnum      = maxnum
330.2.5 by Daniel Schierbeck
Support persistence of compact view option.
46
        self.config      = GlobalConfig()
47
48
        if self.config.get_user_option('viz-compact-view') == 'yes':
49
            self.compact_view = True
50
        else:
51
            self.compact_view = False
315 by Daniel Schierbeck
Removed BranchWindow.set_branch(), used constructor instead.
52
53
        self.set_title(branch.nick + " - revision history")
1 by Scott James Remnant
Commit the first version of bzrk.
54
55
        # Use three-quarters of the screen by default
56
        screen = self.get_screen()
4 by Scott James Remnant
Use the size of the first monitor rather than the entire screen
57
        monitor = screen.get_monitor_geometry(0)
58
        width = int(monitor.width * 0.75)
59
        height = int(monitor.height * 0.75)
1 by Scott James Remnant
Commit the first version of bzrk.
60
        self.set_default_size(width, height)
61
62
        # FIXME AndyFitz!
63
        icon = self.render_icon(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON)
64
        self.set_icon(icon)
65
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
66
        self.accel_group = gtk.AccelGroup()
67
        self.add_accel_group(self.accel_group)
68
1 by Scott James Remnant
Commit the first version of bzrk.
69
        self.construct()
70
330.2.4 by Daniel Schierbeck
Made use of compact view optional.
71
    def set_revision(self, revision):
72
        self.treeview.set_revision(revision)
73
1 by Scott James Remnant
Commit the first version of bzrk.
74
    def construct(self):
75
        """Construct the window contents."""
331 by Daniel Schierbeck
Added basic menu bar.
76
        vbox = gtk.VBox(spacing=0)
44 by David Allouche
reorganise branch window
77
        self.add(vbox)
78
358 by Daniel Schierbeck
Generalized the hiding/showing code.
79
        top = self.construct_top()
80
331 by Daniel Schierbeck
Added basic menu bar.
81
        vbox.pack_start(self.construct_menubar(), expand=False, fill=True)
44 by David Allouche
reorganise branch window
82
        vbox.pack_start(self.construct_navigation(), expand=False, fill=True)
280.2.1 by Gary van der Merwe
Add a message to the viz window to indicate that graph is still loading.
83
        vbox.pack_start(self.construct_loading_msg(), expand=False, fill=True)
84
        
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
85
        paned = gtk.VPaned()
358 by Daniel Schierbeck
Generalized the hiding/showing code.
86
        paned.pack1(top, resize=True, shrink=False)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
87
        paned.pack2(self.construct_bottom(), resize=False, shrink=True)
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
88
        paned.show()
44 by David Allouche
reorganise branch window
89
        vbox.pack_start(paned, expand=True, fill=True)
90
        vbox.set_focus_child(paned)
91
92
        vbox.show()
331 by Daniel Schierbeck
Added basic menu bar.
93
94
    def construct_menubar(self):
95
        menubar = gtk.MenuBar()
96
97
        file_menu = gtk.Menu()
334 by Daniel Schierbeck
Added icons to menus.
98
        file_menuitem = gtk.MenuItem("_File")
331 by Daniel Schierbeck
Added basic menu bar.
99
        file_menuitem.set_submenu(file_menu)
100
362 by Daniel Schierbeck
Added accel group to File -> Close menu item.
101
        file_menu_close = gtk.ImageMenuItem(gtk.STOCK_CLOSE, self.accel_group)
331 by Daniel Schierbeck
Added basic menu bar.
102
        file_menu_close.connect('activate', lambda x: self.destroy())
103
        
363 by Daniel Schierbeck
Added File -> Quit menu item.
104
        file_menu_quit = gtk.ImageMenuItem(gtk.STOCK_QUIT, self.accel_group)
105
        file_menu_quit.connect('activate', lambda x: gtk.main_quit())
106
        
331 by Daniel Schierbeck
Added basic menu bar.
107
        file_menu.add(file_menu_close)
363 by Daniel Schierbeck
Added File -> Quit menu item.
108
        file_menu.add(file_menu_quit)
331 by Daniel Schierbeck
Added basic menu bar.
109
338 by Daniel Schierbeck
Added Preferences menu item.
110
        edit_menu = gtk.Menu()
111
        edit_menuitem = gtk.MenuItem("_Edit")
112
        edit_menuitem.set_submenu(edit_menu)
113
340 by Daniel Schierbeck
Added edit->find menu item stub.
114
        edit_menu_find = gtk.ImageMenuItem(gtk.STOCK_FIND)
115
361 by Daniel Schierbeck
Added branch settings menu item.
116
        edit_menu_branchopts = gtk.MenuItem("Branch Settings")
117
        edit_menu_branchopts.connect('activate', lambda x: PreferencesWindow(self.branch.get_config()).show())
118
338 by Daniel Schierbeck
Added Preferences menu item.
119
        edit_menu_prefs = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
361 by Daniel Schierbeck
Added branch settings menu item.
120
        edit_menu_prefs.connect('activate', lambda x: PreferencesWindow().show())
338 by Daniel Schierbeck
Added Preferences menu item.
121
340 by Daniel Schierbeck
Added edit->find menu item stub.
122
        edit_menu.add(edit_menu_find)
361 by Daniel Schierbeck
Added branch settings menu item.
123
        edit_menu.add(edit_menu_branchopts)
338 by Daniel Schierbeck
Added Preferences menu item.
124
        edit_menu.add(edit_menu_prefs)
125
348 by Daniel Schierbeck
Added toggle item for revision number column.
126
        view_menu = gtk.Menu()
127
        view_menuitem = gtk.MenuItem("_View")
128
        view_menuitem.set_submenu(view_menu)
129
351 by Daniel Schierbeck
Added option to hide the toolbar.
130
        view_menu_toolbar = gtk.CheckMenuItem("Show Toolbar")
131
        view_menu_toolbar.set_active(True)
132
        view_menu_toolbar.connect('toggled', self._toolbar_visibility_changed)
133
134
        view_menu.add(view_menu_toolbar)
135
        view_menu.add(gtk.SeparatorMenuItem())
358 by Daniel Schierbeck
Generalized the hiding/showing code.
136
137
        for (label, name) in [("Revision _Number", "revno"), ("_Date", "date")]:
138
            col = gtk.CheckMenuItem("Show " + label + " Column")
139
            col.set_active(self.treeview.get_property(name + "-column-visible"))
140
            col.connect('toggled', self._col_visibility_changed, name)
141
            view_menu.add(col)
348 by Daniel Schierbeck
Added toggle item for revision number column.
142
331 by Daniel Schierbeck
Added basic menu bar.
143
        go_menu = gtk.Menu()
334 by Daniel Schierbeck
Added icons to menus.
144
        go_menuitem = gtk.MenuItem("_Go")
331 by Daniel Schierbeck
Added basic menu bar.
145
        go_menuitem.set_submenu(go_menu)
146
        
354 by Daniel Schierbeck
Replaced forward and backward buttons with up and down.
147
        go_menu_back = gtk.ImageMenuItem(gtk.STOCK_GO_DOWN)
334 by Daniel Schierbeck
Added icons to menus.
148
        go_menu_back.connect("activate", self._back_clicked_cb)
149
354 by Daniel Schierbeck
Replaced forward and backward buttons with up and down.
150
        go_menu_forward = gtk.ImageMenuItem(gtk.STOCK_GO_UP)
334 by Daniel Schierbeck
Added icons to menus.
151
        go_menu_forward.connect("activate", self._fwd_clicked_cb)
331 by Daniel Schierbeck
Added basic menu bar.
152
332 by Daniel Schierbeck
Made tag selection work.
153
        tags_menu = gtk.Menu()
334 by Daniel Schierbeck
Added icons to menus.
154
        go_menu_tags = gtk.MenuItem("_Tags")
155
        go_menu_tags.set_submenu(tags_menu)
332 by Daniel Schierbeck
Made tag selection work.
156
367 by Daniel Schierbeck
Fixed crash when branch didn't support tags.
157
        if self.branch.supports_tags():
158
            for (tag, revid) in self.branch.tags.get_tag_dict().items():
159
                tag_item = gtk.MenuItem(tag)
160
                tag_item.connect('activate', self._tag_selected_cb, revid)
161
                tags_menu.add(tag_item)
332 by Daniel Schierbeck
Made tag selection work.
162
334 by Daniel Schierbeck
Added icons to menus.
163
        go_menu.add(go_menu_back)
164
        go_menu.add(go_menu_forward)
165
        go_menu.add(gtk.SeparatorMenuItem())
166
        go_menu.add(go_menu_tags)
167
335 by Daniel Schierbeck
Added Revision menu.
168
        revision_menu = gtk.Menu()
169
        revision_menuitem = gtk.MenuItem("_Revision")
170
        revision_menuitem.set_submenu(revision_menu)
171
364 by Daniel Schierbeck
Simplified TreeView.show_diff() and made the Revision -> View Changes menu item work.
172
        revision_menu_diff = gtk.MenuItem("View Changes")
173
        revision_menu_diff.connect('activate', 
174
                lambda w: self.treeview.show_diff())
175
365 by Daniel Schierbeck
Fixed locks and made tagging work.
176
        revision_menu_tag = gtk.MenuItem("Tag Revision")
177
        revision_menu_tag.connect('activate', self._tag_revision_cb)
178
179
        revision_menu.add(revision_menu_tag)
364 by Daniel Schierbeck
Simplified TreeView.show_diff() and made the Revision -> View Changes menu item work.
180
        revision_menu.add(revision_menu_diff)
335 by Daniel Schierbeck
Added Revision menu.
181
334 by Daniel Schierbeck
Added icons to menus.
182
        branch_menu = gtk.Menu()
183
        branch_menuitem = gtk.MenuItem("_Branch")
184
        branch_menuitem.set_submenu(branch_menu)
185
336 by Daniel Schierbeck
Changed wording to comply with HIG guidelines.
186
        branch_menu.add(gtk.MenuItem("Pu_ll Revisions"))
187
        branch_menu.add(gtk.MenuItem("Pu_sh Revisions"))
334 by Daniel Schierbeck
Added icons to menus.
188
       
331 by Daniel Schierbeck
Added basic menu bar.
189
        menubar.add(file_menuitem)
338 by Daniel Schierbeck
Added Preferences menu item.
190
        menubar.add(edit_menuitem)
348 by Daniel Schierbeck
Added toggle item for revision number column.
191
        menubar.add(view_menuitem)
331 by Daniel Schierbeck
Added basic menu bar.
192
        menubar.add(go_menuitem)
335 by Daniel Schierbeck
Added Revision menu.
193
        menubar.add(revision_menuitem)
331 by Daniel Schierbeck
Added basic menu bar.
194
        menubar.add(branch_menuitem)
195
        menubar.show_all()
196
197
        return menubar
280.2.1 by Gary van der Merwe
Add a message to the viz window to indicate that graph is still loading.
198
    
199
    def construct_loading_msg(self):
200
        image_loading = gtk.image_new_from_stock(gtk.STOCK_REFRESH,
201
                                                 gtk.ICON_SIZE_BUTTON)
202
        image_loading.show()
203
        
204
        label_loading = gtk.Label(_("Please wait, loading ancestral graph..."))
368 by Daniel Schierbeck
Merged with mainline.
205
        label_loading.set_alignment(0.0, 0.5)
280.2.1 by Gary van der Merwe
Add a message to the viz window to indicate that graph is still loading.
206
        label_loading.show()
207
        
208
        self.loading_msg_box = gtk.HBox()
209
        self.loading_msg_box.set_spacing(5)
210
        self.loading_msg_box.set_border_width(5)        
211
        self.loading_msg_box.pack_start(image_loading, False, False)
212
        self.loading_msg_box.pack_start(label_loading, True, True)
213
        self.loading_msg_box.show()
214
        
215
        return self.loading_msg_box
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
216
217
    def construct_top(self):
218
        """Construct the top-half of the window."""
329 by Jelmer Vernooij
Make broken_line_length setting from higher up.
219
        # FIXME: Make broken_line_length configurable
330.2.5 by Daniel Schierbeck
Support persistence of compact view option.
220
        if self.compact_view:
221
            brokenlines = 32
222
        else:
223
            brokenlines = None
224
225
        self.treeview = TreeView(self.branch, self.start, self.maxnum, brokenlines)
315 by Daniel Schierbeck
Removed BranchWindow.set_branch(), used constructor instead.
226
310 by Daniel Schierbeck
Moved to using custom signal for handling revision selections.
227
        self.treeview.connect("revision-selected",
303 by Daniel Schierbeck
Made basic signaling work.
228
                self._treeselection_changed_cb)
229
307 by Daniel Schierbeck
Made load notification work again.
230
        self.treeview.connect('revisions-loaded', 
231
                lambda x: self.loading_msg_box.hide())
232
1 by Scott James Remnant
Commit the first version of bzrk.
233
        self.treeview.show()
234
303 by Daniel Schierbeck
Made basic signaling work.
235
        return self.treeview
44 by David Allouche
reorganise branch window
236
237
    def construct_navigation(self):
238
        """Construct the navigation buttons."""
325 by Daniel Schierbeck
Switched to using a real toolbar for the viz navigation.
239
        self.toolbar = gtk.Toolbar()
240
        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
241
354 by Daniel Schierbeck
Replaced forward and backward buttons with up and down.
242
        self.back_button = gtk.MenuToolButton(stock_id=gtk.STOCK_GO_DOWN)
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
243
        self.back_button.add_accelerator("clicked", self.accel_group, ord('['),
244
                                         0, 0)
245
        self.back_button.connect("clicked", self._back_clicked_cb)
325 by Daniel Schierbeck
Switched to using a real toolbar for the viz navigation.
246
        self.toolbar.insert(self.back_button, -1)
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
247
354 by Daniel Schierbeck
Replaced forward and backward buttons with up and down.
248
        self.fwd_button = gtk.MenuToolButton(stock_id=gtk.STOCK_GO_UP)
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
249
        self.fwd_button.add_accelerator("clicked", self.accel_group, ord(']'),
250
                                        0, 0)
251
        self.fwd_button.connect("clicked", self._fwd_clicked_cb)
325 by Daniel Schierbeck
Switched to using a real toolbar for the viz navigation.
252
        self.toolbar.insert(self.fwd_button, -1)
330.2.4 by Daniel Schierbeck
Made use of compact view optional.
253
254
        self.toolbar.insert(gtk.SeparatorToolItem(), -1)
255
256
        brokenlines_button = gtk.ToggleToolButton()
257
        brokenlines_button.set_label("Compact View")
330.2.5 by Daniel Schierbeck
Support persistence of compact view option.
258
        brokenlines_button.set_active(self.compact_view)
330.2.4 by Daniel Schierbeck
Made use of compact view optional.
259
        brokenlines_button.set_is_important(True)
260
        brokenlines_button.connect('toggled', self._brokenlines_toggled_cb)
261
        self.toolbar.insert(brokenlines_button, -1)
262
263
        self.toolbar.show_all()
325 by Daniel Schierbeck
Switched to using a real toolbar for the viz navigation.
264
265
        return self.toolbar
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
266
267
    def construct_bottom(self):
268
        """Construct the bottom half of the window."""
330.3.1 by Daniel Schierbeck
Renamed logview 'revisionview'.
269
        from bzrlib.plugins.gtk.revisionview import RevisionView
270
        self.revisionview = RevisionView(None, tags=[], show_children=True, branch=self.branch)
44 by David Allouche
reorganise branch window
271
        (width, height) = self.get_size()
330.3.1 by Daniel Schierbeck
Renamed logview 'revisionview'.
272
        self.revisionview.set_size_request(width, int(height / 2.5))
273
        self.revisionview.show()
274
        self.revisionview.set_show_callback(self._show_clicked_cb)
275
        self.revisionview.set_go_callback(self._go_clicked_cb)
276
        return self.revisionview
332 by Daniel Schierbeck
Made tag selection work.
277
278
    def _tag_selected_cb(self, menuitem, revid):
356 by Daniel Schierbeck
Made revision a property on TreeView.
279
        self.treeview.set_revision_id(revid)
341 by Daniel Schierbeck
Merged with trunk.
280
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)
281
    def _treeselection_changed_cb(self, selection, *args):
303 by Daniel Schierbeck
Made basic signaling work.
282
        """callback for when the treeview changes."""
283
        revision = self.treeview.get_revision()
284
        parents  = self.treeview.get_parents()
285
        children = self.treeview.get_children()
286
287
        if revision is not None:
352.1.1 by Daniel Schierbeck
Added dropdown menu to Back button.
288
            back_menu = gtk.Menu()
289
            if len(parents) > 0:
290
                self.back_button.set_sensitive(True)
291
                for parent_id in parents:
292
                    parent = self.branch.repository.get_revision(parent_id)
355 by Daniel Schierbeck
Appended branch nick to parent and child popup menus.
293
                    try:
294
                        str = ' (' + parent.properties['branch-nick'] + ')'
295
                    except KeyError:
296
                        str = ""
297
298
                    item = gtk.MenuItem(parent.message.split("\n")[0] + str)
352.1.1 by Daniel Schierbeck
Added dropdown menu to Back button.
299
                    item.connect('activate', self._set_revision_cb, parent_id)
300
                    back_menu.add(item)
301
                back_menu.show_all()
302
            else:
303
                self.back_button.set_sensitive(False)
304
                back_menu.hide()
305
306
            self.back_button.set_menu(back_menu)
307
352.1.2 by Daniel Schierbeck
Added dropdown menu to Forward button.
308
            fwd_menu = gtk.Menu()
309
            if len(children) > 0:
310
                self.fwd_button.set_sensitive(True)
311
                for child_id in children:
312
                    child = self.branch.repository.get_revision(child_id)
355 by Daniel Schierbeck
Appended branch nick to parent and child popup menus.
313
                    try:
314
                        str = ' (' + child.properties['branch-nick'] + ')'
315
                    except KeyError:
316
                        str = ""
317
318
                    item = gtk.MenuItem(child.message.split("\n")[0] + str)
352.1.2 by Daniel Schierbeck
Added dropdown menu to Forward button.
319
                    item.connect('activate', self._set_revision_cb, child_id)
320
                    fwd_menu.add(item)
321
                fwd_menu.show_all()
322
            else:
323
                self.fwd_button.set_sensitive(False)
324
                fwd_menu.hide()
325
326
            self.fwd_button.set_menu(fwd_menu)
327
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)
328
            tags = []
329
            if self.branch.supports_tags():
330
                tagdict = self.branch.tags.get_reverse_tag_dict()
331
                if tagdict.has_key(revision.revision_id):
332
                    tags = tagdict[revision.revision_id]
330.3.1 by Daniel Schierbeck
Renamed logview 'revisionview'.
333
            self.revisionview.set_revision(revision, tags, children)
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
334
3 by Scott James Remnant
Split the display in two with a pane, we'll use the bottom half to show
335
    def _back_clicked_cb(self, *args):
336
        """Callback for when the back button is clicked."""
304 by Daniel Schierbeck
Made forward/back buttons work again.
337
        self.treeview.back()
338
        
5 by Scott James Remnant
Reverse the meaning of the Back and Forward buttons so Back actually
339
    def _fwd_clicked_cb(self, *args):
340
        """Callback for when the forward button is clicked."""
304 by Daniel Schierbeck
Made forward/back buttons work again.
341
        self.treeview.forward()
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
342
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
343
    def _go_clicked_cb(self, revid):
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
344
        """Callback for when the go button for a parent is clicked."""
356 by Daniel Schierbeck
Made revision a property on TreeView.
345
        self.treeview.set_revision_id(revid)
152 by Jelmer Vernooij
Cleanup some more code.
346
147 by Jelmer Vernooij
Remove a bunch of duplicate functionality.
347
    def _show_clicked_cb(self, revid, parentid):
7 by Scott James Remnant
Put some information about the highlighted revision in the bottom pane,
348
        """Callback for when the show button for a parent is clicked."""
364 by Daniel Schierbeck
Simplified TreeView.show_diff() and made the Revision -> View Changes menu item work.
349
        self.treeview.show_diff(revid, parentid)
13 by Scott James Remnant
Keep the focus on the treeview
350
        self.treeview.grab_focus()
46 by Wouter van Heyst
show diff on row activation, LP# 44591
351
352.1.1 by Daniel Schierbeck
Added dropdown menu to Back button.
352
    def _set_revision_cb(self, w, revision_id):
356 by Daniel Schierbeck
Made revision a property on TreeView.
353
        self.treeview.set_revision_id(revision_id)
352.1.1 by Daniel Schierbeck
Added dropdown menu to Back button.
354
330.2.4 by Daniel Schierbeck
Made use of compact view optional.
355
    def _brokenlines_toggled_cb(self, button):
330.2.5 by Daniel Schierbeck
Support persistence of compact view option.
356
        self.compact_view = button.get_active()
357
358
        if self.compact_view:
359
            option = 'yes'
330.2.4 by Daniel Schierbeck
Made use of compact view optional.
360
        else:
330.2.5 by Daniel Schierbeck
Support persistence of compact view option.
361
            option = 'no'
362
363
        self.config.set_user_option('viz-compact-view', option)
330.2.4 by Daniel Schierbeck
Made use of compact view optional.
364
365
        revision = self.treeview.get_revision()
366
367
        self.treeview.destroy()
368
        self.paned.pack1(self.construct_top(), resize=True, shrink=False)
369
370
        gobject.idle_add(self.set_revision, revision.revision_id)
368 by Daniel Schierbeck
Merged with mainline.
371
365 by Daniel Schierbeck
Fixed locks and made tagging work.
372
    def _tag_revision_cb(self, w):
373
        dialog = AddTagDialog(self.branch.repository, self.treeview.get_revision().revision_id, self.branch)
374
        response = dialog.run()
375
        if response != gtk.RESPONSE_NONE:
376
            dialog.hide()
377
        
378
            if response == gtk.RESPONSE_OK:
379
                try:
380
                    self.branch.lock_write()
381
                    self.branch.tags.set_tag(dialog.tagname, dialog._revid)
382
                finally:
383
                    self.branch.unlock()
384
            
385
            dialog.destroy()
386
348 by Daniel Schierbeck
Added toggle item for revision number column.
387
    def _col_visibility_changed(self, col, property):
388
        self.treeview.set_property(property + '-column-visible', col.get_active())
351 by Daniel Schierbeck
Added option to hide the toolbar.
389
390
    def _toolbar_visibility_changed(self, col):
391
        if col.get_active():
392
            self.toolbar.show() 
393
        else:
394
            self.toolbar.hide()