/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: 2008-06-28 16:59:50 UTC
  • mto: This revision was merged to the branch mainline in revision 516.
  • Revision ID: jelmer@samba.org-20080628165950-18kv7bdykgf1f1jf
Fix import in olive.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
import pango
15
15
 
16
16
from bzrlib.plugins.gtk.window import Window
 
17
from bzrlib.plugins.gtk import icon_path
17
18
from bzrlib.plugins.gtk.tags import AddTagDialog
18
19
from bzrlib.plugins.gtk.preferences import PreferencesWindow
19
 
from bzrlib.revision import Revision
 
20
from bzrlib.plugins.gtk.branchview import TreeView, treemodel
 
21
from bzrlib.revision import Revision, NULL_REVISION
20
22
from bzrlib.config import BranchConfig
21
23
from bzrlib.config import GlobalConfig
22
 
from treeview import TreeView
23
24
 
24
25
class BranchWindow(Window):
25
26
    """Branch window.
28
29
    for a particular branch.
29
30
    """
30
31
 
31
 
    def __init__(self, branch, start, maxnum, parent=None):
 
32
    def __init__(self, branch, start_revs, maxnum, parent=None):
32
33
        """Create a new BranchWindow.
33
34
 
34
35
        :param branch: Branch object for branch to show.
35
 
        :param start: Revision id of top revision.
 
36
        :param start_revs: Revision ids of top revisions.
36
37
        :param maxnum: Maximum number of revisions to display, 
37
38
                       None for no limit.
38
39
        """
41
42
        self.set_border_width(0)
42
43
 
43
44
        self.branch      = branch
44
 
        self.start       = start
 
45
        self.start_revs  = start_revs
45
46
        self.maxnum      = maxnum
46
47
        self.config      = GlobalConfig()
47
48
 
63
64
        icon = self.render_icon(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON)
64
65
        self.set_icon(icon)
65
66
 
 
67
        gtk.accel_map_add_entry("<viz>/Go/Next Revision", gtk.keysyms.Up, gtk.gdk.MOD1_MASK)
 
68
        gtk.accel_map_add_entry("<viz>/Go/Previous Revision", gtk.keysyms.Down, gtk.gdk.MOD1_MASK)
 
69
        gtk.accel_map_add_entry("<viz>/View/Refresh", gtk.keysyms.F5, 0)
 
70
 
66
71
        self.accel_group = gtk.AccelGroup()
67
72
        self.add_accel_group(self.accel_group)
68
73
 
 
74
        gtk.Action.set_tool_item_type(gtk.MenuToolButton)
 
75
 
 
76
        self.prev_rev_action = gtk.Action("prev-rev", "_Previous Revision", "Go to the previous revision", gtk.STOCK_GO_DOWN)
 
77
        self.prev_rev_action.set_accel_path("<viz>/Go/Previous Revision")
 
78
        self.prev_rev_action.set_accel_group(self.accel_group)
 
79
        self.prev_rev_action.connect("activate", self._back_clicked_cb)
 
80
        self.prev_rev_action.connect_accelerator()
 
81
 
 
82
        self.next_rev_action = gtk.Action("next-rev", "_Next Revision", "Go to the next revision", gtk.STOCK_GO_UP)
 
83
        self.next_rev_action.set_accel_path("<viz>/Go/Next Revision")
 
84
        self.next_rev_action.set_accel_group(self.accel_group)
 
85
        self.next_rev_action.connect("activate", self._fwd_clicked_cb)
 
86
        self.next_rev_action.connect_accelerator()
 
87
 
 
88
        self.refresh_action = gtk.Action("refresh", "_Refresh", "Refresh view", gtk.STOCK_REFRESH)
 
89
        self.refresh_action.set_accel_path("<viz>/View/Refresh")
 
90
        self.refresh_action.set_accel_group(self.accel_group)
 
91
        self.refresh_action.connect("activate", self._refresh_clicked)
 
92
        self.refresh_action.connect_accelerator()
 
93
 
69
94
        self.construct()
70
95
 
71
 
    def set_revision(self, revision):
72
 
        self.treeview.set_revision(revision)
 
96
    def set_revision(self, revid):
 
97
        self.treeview.set_revision_id(revid)
73
98
 
74
99
    def construct(self):
75
100
        """Construct the window contents."""
76
101
        vbox = gtk.VBox(spacing=0)
77
102
        self.add(vbox)
78
103
 
79
 
        top = self.construct_top()
 
104
        self.paned = gtk.VPaned()
 
105
        self.paned.pack1(self.construct_top(), resize=True, shrink=False)
 
106
        self.paned.pack2(self.construct_bottom(), resize=False, shrink=True)
 
107
        self.paned.show()
80
108
 
81
109
        vbox.pack_start(self.construct_menubar(), expand=False, fill=True)
82
110
        vbox.pack_start(self.construct_navigation(), expand=False, fill=True)
83
 
        vbox.pack_start(self.construct_loading_msg(), expand=False, fill=True)
84
111
        
85
 
        paned = gtk.VPaned()
86
 
        paned.pack1(top, resize=True, shrink=False)
87
 
        paned.pack2(self.construct_bottom(), resize=False, shrink=True)
88
 
        paned.show()
89
 
        vbox.pack_start(paned, expand=True, fill=True)
90
 
        vbox.set_focus_child(paned)
 
112
        vbox.pack_start(self.paned, expand=True, fill=True)
 
113
        vbox.set_focus_child(self.paned)
91
114
 
92
115
        vbox.show()
93
116
 
104
127
        file_menu_quit = gtk.ImageMenuItem(gtk.STOCK_QUIT, self.accel_group)
105
128
        file_menu_quit.connect('activate', lambda x: gtk.main_quit())
106
129
        
107
 
        file_menu.add(file_menu_close)
 
130
        if self._parent is not None:
 
131
            file_menu.add(file_menu_close)
108
132
        file_menu.add(file_menu_quit)
109
133
 
110
134
        edit_menu = gtk.Menu()
116
140
        edit_menu_branchopts = gtk.MenuItem("Branch Settings")
117
141
        edit_menu_branchopts.connect('activate', lambda x: PreferencesWindow(self.branch.get_config()).show())
118
142
 
119
 
        edit_menu_prefs = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
120
 
        edit_menu_prefs.connect('activate', lambda x: PreferencesWindow().show())
 
143
        edit_menu_globopts = gtk.MenuItem("Global Settings")
 
144
        edit_menu_globopts.connect('activate', lambda x: PreferencesWindow().show())
121
145
 
122
146
        edit_menu.add(edit_menu_find)
123
147
        edit_menu.add(edit_menu_branchopts)
124
 
        edit_menu.add(edit_menu_prefs)
 
148
        edit_menu.add(edit_menu_globopts)
125
149
 
126
150
        view_menu = gtk.Menu()
127
151
        view_menuitem = gtk.MenuItem("_View")
128
152
        view_menuitem.set_submenu(view_menu)
129
153
 
 
154
        view_menu_refresh = self.refresh_action.create_menu_item()
 
155
        view_menu_refresh.connect('activate', self._refresh_clicked)
 
156
 
 
157
        view_menu.add(view_menu_refresh)
 
158
        view_menu.add(gtk.SeparatorMenuItem())
 
159
 
130
160
        view_menu_toolbar = gtk.CheckMenuItem("Show Toolbar")
131
161
        view_menu_toolbar.set_active(True)
132
162
        view_menu_toolbar.connect('toggled', self._toolbar_visibility_changed)
133
163
 
 
164
        view_menu_compact = gtk.CheckMenuItem("Show Compact Graph")
 
165
        view_menu_compact.set_active(self.compact_view)
 
166
        view_menu_compact.connect('activate', self._brokenlines_toggled_cb)
 
167
 
134
168
        view_menu.add(view_menu_toolbar)
 
169
        view_menu.add(view_menu_compact)
135
170
        view_menu.add(gtk.SeparatorMenuItem())
136
171
 
137
 
        for (label, name) in [("Revision _Number", "revno"), ("_Date", "date")]:
138
 
            col = gtk.CheckMenuItem("Show " + label + " Column")
 
172
        self.mnu_show_revno_column = gtk.CheckMenuItem("Show Revision _Number Column")
 
173
        self.mnu_show_date_column = gtk.CheckMenuItem("Show _Date Column")
 
174
 
 
175
        # Revision numbers are pointless if there are multiple branches
 
176
        if len(self.start_revs) > 1:
 
177
            self.mnu_show_revno_column.set_sensitive(False)
 
178
            self.treeview.set_property('revno-column-visible', False)
 
179
 
 
180
        for (col, name) in [(self.mnu_show_revno_column, "revno"), 
 
181
                            (self.mnu_show_date_column, "date")]:
139
182
            col.set_active(self.treeview.get_property(name + "-column-visible"))
140
183
            col.connect('toggled', self._col_visibility_changed, name)
141
184
            view_menu.add(col)
142
185
 
143
186
        go_menu = gtk.Menu()
 
187
        go_menu.set_accel_group(self.accel_group)
144
188
        go_menuitem = gtk.MenuItem("_Go")
145
189
        go_menuitem.set_submenu(go_menu)
146
190
        
147
 
        go_menu_back = gtk.ImageMenuItem(gtk.STOCK_GO_DOWN)
148
 
        go_menu_back.connect("activate", self._back_clicked_cb)
149
 
 
150
 
        go_menu_forward = gtk.ImageMenuItem(gtk.STOCK_GO_UP)
151
 
        go_menu_forward.connect("activate", self._fwd_clicked_cb)
152
 
 
153
 
        tags_menu = gtk.Menu()
154
 
        go_menu_tags = gtk.MenuItem("_Tags")
155
 
        go_menu_tags.set_submenu(tags_menu)
156
 
 
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)
162
 
 
163
 
        go_menu.add(go_menu_back)
164
 
        go_menu.add(go_menu_forward)
 
191
        go_menu_next = self.next_rev_action.create_menu_item()
 
192
        go_menu_prev = self.prev_rev_action.create_menu_item()
 
193
 
 
194
        tag_image = gtk.Image()
 
195
        tag_image.set_from_file(icon_path("tag-16.png"))
 
196
        self.go_menu_tags = gtk.ImageMenuItem("_Tags")
 
197
        self.go_menu_tags.set_image(tag_image)
 
198
        self._update_tags()
 
199
 
 
200
        go_menu.add(go_menu_next)
 
201
        go_menu.add(go_menu_prev)
165
202
        go_menu.add(gtk.SeparatorMenuItem())
166
 
        go_menu.add(go_menu_tags)
 
203
        go_menu.add(self.go_menu_tags)
167
204
 
168
205
        revision_menu = gtk.Menu()
169
206
        revision_menuitem = gtk.MenuItem("_Revision")
171
208
 
172
209
        revision_menu_diff = gtk.MenuItem("View Changes")
173
210
        revision_menu_diff.connect('activate', 
174
 
                lambda w: self.treeview.show_diff())
 
211
                self._menu_diff_cb)
 
212
        
 
213
        revision_menu_compare = gtk.MenuItem("Compare with...")
 
214
        revision_menu_compare.connect('activate',
 
215
                self._compare_with_cb)
175
216
 
176
217
        revision_menu_tag = gtk.MenuItem("Tag Revision")
177
218
        revision_menu_tag.connect('activate', self._tag_revision_cb)
178
219
 
179
220
        revision_menu.add(revision_menu_tag)
180
221
        revision_menu.add(revision_menu_diff)
 
222
        revision_menu.add(revision_menu_compare)
181
223
 
182
224
        branch_menu = gtk.Menu()
183
225
        branch_menuitem = gtk.MenuItem("_Branch")
185
227
 
186
228
        branch_menu.add(gtk.MenuItem("Pu_ll Revisions"))
187
229
        branch_menu.add(gtk.MenuItem("Pu_sh Revisions"))
188
 
       
 
230
 
 
231
        help_menu = gtk.Menu()
 
232
        help_menuitem = gtk.MenuItem("_Help")
 
233
        help_menuitem.set_submenu(help_menu)
 
234
 
 
235
        help_about_menuitem = gtk.ImageMenuItem(gtk.STOCK_ABOUT, self.accel_group)
 
236
        help_about_menuitem.connect('activate', self._about_dialog_cb)
 
237
 
 
238
        help_menu.add(help_about_menuitem)
 
239
 
189
240
        menubar.add(file_menuitem)
190
241
        menubar.add(edit_menuitem)
191
242
        menubar.add(view_menuitem)
192
243
        menubar.add(go_menuitem)
193
244
        menubar.add(revision_menuitem)
194
245
        menubar.add(branch_menuitem)
 
246
        menubar.add(help_menuitem)
195
247
        menubar.show_all()
196
248
 
197
249
        return menubar
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..."))
205
 
        label_loading.set_alignment(0.0, 0.5)
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
216
250
 
217
251
    def construct_top(self):
218
252
        """Construct the top-half of the window."""
219
253
        # FIXME: Make broken_line_length configurable
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)
226
 
 
227
 
        self.treeview.connect("revision-selected",
 
254
 
 
255
        self.treeview = TreeView(self.branch, self.start_revs, self.maxnum, self.compact_view)
 
256
 
 
257
        self.treeview.connect('revision-selected',
228
258
                self._treeselection_changed_cb)
229
 
 
230
 
        self.treeview.connect('revisions-loaded', 
231
 
                lambda x: self.loading_msg_box.hide())
 
259
        self.treeview.connect('revision-activated',
 
260
                self._tree_revision_activated)
 
261
 
 
262
        self.treeview.connect('tag-added', lambda w, t, r: self._update_tags())
 
263
 
 
264
        for col in ["revno", "date"]:
 
265
            option = self.config.get_user_option(col + '-column-visible')
 
266
            if option is not None:
 
267
                self.treeview.set_property(col + '-column-visible', option == 'True')
 
268
            else:
 
269
                self.treeview.set_property(col + '-column-visible', False)
232
270
 
233
271
        self.treeview.show()
234
272
 
235
 
        return self.treeview
 
273
        align = gtk.Alignment(0.0, 0.0, 1.0, 1.0)
 
274
        align.set_padding(5, 0, 0, 0)
 
275
        align.add(self.treeview)
 
276
        align.show()
 
277
 
 
278
        return align
236
279
 
237
280
    def construct_navigation(self):
238
281
        """Construct the navigation buttons."""
239
282
        self.toolbar = gtk.Toolbar()
240
283
        self.toolbar.set_style(gtk.TOOLBAR_BOTH_HORIZ)
241
284
 
242
 
        self.back_button = gtk.MenuToolButton(stock_id=gtk.STOCK_GO_DOWN)
243
 
        self.back_button.add_accelerator("clicked", self.accel_group, ord('['),
244
 
                                         0, 0)
245
 
        self.back_button.connect("clicked", self._back_clicked_cb)
246
 
        self.toolbar.insert(self.back_button, -1)
 
285
        self.prev_button = self.prev_rev_action.create_tool_item()
 
286
        self.toolbar.insert(self.prev_button, -1)
247
287
 
248
 
        self.fwd_button = gtk.MenuToolButton(stock_id=gtk.STOCK_GO_UP)
249
 
        self.fwd_button.add_accelerator("clicked", self.accel_group, ord(']'),
250
 
                                        0, 0)
251
 
        self.fwd_button.connect("clicked", self._fwd_clicked_cb)
252
 
        self.toolbar.insert(self.fwd_button, -1)
 
288
        self.next_button = self.next_rev_action.create_tool_item()
 
289
        self.toolbar.insert(self.next_button, -1)
253
290
 
254
291
        self.toolbar.insert(gtk.SeparatorToolItem(), -1)
255
292
 
256
 
        brokenlines_button = gtk.ToggleToolButton()
257
 
        brokenlines_button.set_label("Compact View")
258
 
        brokenlines_button.set_active(self.compact_view)
259
 
        brokenlines_button.set_is_important(True)
260
 
        brokenlines_button.connect('toggled', self._brokenlines_toggled_cb)
261
 
        self.toolbar.insert(brokenlines_button, -1)
 
293
        refresh_button = gtk.ToolButton(gtk.STOCK_REFRESH)
 
294
        refresh_button.connect('clicked', self._refresh_clicked)
 
295
        self.toolbar.insert(refresh_button, -1)
262
296
 
263
297
        self.toolbar.show_all()
264
298
 
267
301
    def construct_bottom(self):
268
302
        """Construct the bottom half of the window."""
269
303
        from bzrlib.plugins.gtk.revisionview import RevisionView
270
 
        self.revisionview = RevisionView(None, tags=[], show_children=True, branch=self.branch)
 
304
        self.revisionview = RevisionView(branch=self.branch)
271
305
        (width, height) = self.get_size()
272
306
        self.revisionview.set_size_request(width, int(height / 2.5))
273
307
        self.revisionview.show()
274
308
        self.revisionview.set_show_callback(self._show_clicked_cb)
275
 
        self.revisionview.set_go_callback(self._go_clicked_cb)
 
309
        self.revisionview.connect('notify::revision', self._go_clicked_cb)
 
310
        self.treeview.connect('tag-added', lambda w, t, r: self.revisionview.update_tags())
276
311
        return self.revisionview
277
312
 
278
313
    def _tag_selected_cb(self, menuitem, revid):
284
319
        parents  = self.treeview.get_parents()
285
320
        children = self.treeview.get_children()
286
321
 
287
 
        if revision is not None:
288
 
            back_menu = gtk.Menu()
 
322
        if revision and revision != NULL_REVISION:
 
323
            prev_menu = gtk.Menu()
289
324
            if len(parents) > 0:
290
 
                self.back_button.set_sensitive(True)
 
325
                self.prev_rev_action.set_sensitive(True)
291
326
                for parent_id in parents:
292
 
                    parent = self.branch.repository.get_revision(parent_id)
293
 
                    try:
294
 
                        str = ' (' + parent.properties['branch-nick'] + ')'
295
 
                    except KeyError:
296
 
                        str = ""
 
327
                    if parent_id and parent_id != NULL_REVISION:
 
328
                        parent = self.branch.repository.get_revision(parent_id)
 
329
                        try:
 
330
                            str = ' (' + parent.properties['branch-nick'] + ')'
 
331
                        except KeyError:
 
332
                            str = ""
297
333
 
298
 
                    item = gtk.MenuItem(parent.message.split("\n")[0] + str)
299
 
                    item.connect('activate', self._set_revision_cb, parent_id)
300
 
                    back_menu.add(item)
301
 
                back_menu.show_all()
 
334
                        item = gtk.MenuItem(parent.message.split("\n")[0] + str)
 
335
                        item.connect('activate', self._set_revision_cb, parent_id)
 
336
                        prev_menu.add(item)
 
337
                prev_menu.show_all()
302
338
            else:
303
 
                self.back_button.set_sensitive(False)
304
 
                back_menu.hide()
305
 
 
306
 
            self.back_button.set_menu(back_menu)
307
 
 
308
 
            fwd_menu = gtk.Menu()
 
339
                self.prev_rev_action.set_sensitive(False)
 
340
                prev_menu.hide()
 
341
 
 
342
            self.prev_button.set_menu(prev_menu)
 
343
 
 
344
            next_menu = gtk.Menu()
309
345
            if len(children) > 0:
310
 
                self.fwd_button.set_sensitive(True)
 
346
                self.next_rev_action.set_sensitive(True)
311
347
                for child_id in children:
312
348
                    child = self.branch.repository.get_revision(child_id)
313
349
                    try:
317
353
 
318
354
                    item = gtk.MenuItem(child.message.split("\n")[0] + str)
319
355
                    item.connect('activate', self._set_revision_cb, child_id)
320
 
                    fwd_menu.add(item)
321
 
                fwd_menu.show_all()
 
356
                    next_menu.add(item)
 
357
                next_menu.show_all()
322
358
            else:
323
 
                self.fwd_button.set_sensitive(False)
324
 
                fwd_menu.hide()
325
 
 
326
 
            self.fwd_button.set_menu(fwd_menu)
327
 
 
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]
333
 
            self.revisionview.set_revision(revision, tags, children)
 
359
                self.next_rev_action.set_sensitive(False)
 
360
                next_menu.hide()
 
361
 
 
362
            self.next_button.set_menu(next_menu)
 
363
 
 
364
            self.revisionview.set_revision(revision)
 
365
            self.revisionview.set_children(children)
 
366
    
 
367
    def _tree_revision_activated(self, widget, path, col):
 
368
        # TODO: more than one parent
 
369
        """Callback for when a treeview row gets activated."""
 
370
        revision = self.treeview.get_revision()
 
371
        parents  = self.treeview.get_parents()
 
372
 
 
373
        if len(parents) == 0:
 
374
            parent_id = None
 
375
        else:
 
376
            parent_id = parents[0]
 
377
 
 
378
        self.show_diff(revision.revision_id, parent_id)
 
379
        self.treeview.grab_focus()
 
380
        
 
381
    def _menu_diff_cb(self,w):
 
382
        (path, focus) = self.treeview.treeview.get_cursor()
 
383
        revid = self.treeview.model[path][treemodel.REVID]
 
384
        
 
385
        parentids = self.branch.repository.revision_parents(revid)
 
386
 
 
387
        if len(parentids) == 0:
 
388
            parentid = NULL_REVISION
 
389
        else:
 
390
            parentid = parentids[0]
 
391
        
 
392
        self.show_diff(revid,parentid)    
334
393
 
335
394
    def _back_clicked_cb(self, *args):
336
395
        """Callback for when the back button is clicked."""
340
399
        """Callback for when the forward button is clicked."""
341
400
        self.treeview.forward()
342
401
 
343
 
    def _go_clicked_cb(self, revid):
 
402
    def _go_clicked_cb(self, w, p):
344
403
        """Callback for when the go button for a parent is clicked."""
345
 
        self.treeview.set_revision_id(revid)
 
404
        if self.revisionview.get_revision() is not None:
 
405
            self.treeview.set_revision(self.revisionview.get_revision())
346
406
 
347
407
    def _show_clicked_cb(self, revid, parentid):
348
408
        """Callback for when the show button for a parent is clicked."""
349
 
        self.treeview.show_diff(revid, parentid)
 
409
        self.show_diff(revid, parentid)
350
410
        self.treeview.grab_focus()
351
411
 
 
412
    def _compare_with_cb(self,w):
 
413
        """Callback for revision 'compare with' menu. Will show a small
 
414
            dialog with branch revisions to compare with selected revision in TreeView"""
 
415
        
 
416
        from bzrlib.plugins.gtk.revbrowser import RevisionBrowser
 
417
        
 
418
        rb = RevisionBrowser(self.branch,self)
 
419
        ret = rb.run()
 
420
        
 
421
        if ret == gtk.RESPONSE_OK:          
 
422
            (path, focus) = self.treeview.treeview.get_cursor()
 
423
            revid = self.treeview.model[path][treemodel.REVID]
 
424
            self.show_diff(revid, rb.selected_revid)
 
425
            
 
426
        rb.destroy()
 
427
            
352
428
    def _set_revision_cb(self, w, revision_id):
353
429
        self.treeview.set_revision_id(revision_id)
354
430
 
361
437
            option = 'no'
362
438
 
363
439
        self.config.set_user_option('viz-compact-view', option)
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)
 
440
        self.treeview.set_property('compact', self.compact_view)
 
441
        self.treeview.refresh()
371
442
 
372
443
    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()
 
444
        try:
 
445
            self.treeview.set_sensitive(False)
 
446
            dialog = AddTagDialog(self.branch.repository, self.treeview.get_revision().revision_id, self.branch)
 
447
            response = dialog.run()
 
448
            if response != gtk.RESPONSE_NONE:
 
449
                dialog.hide()
384
450
            
385
 
            dialog.destroy()
 
451
                if response == gtk.RESPONSE_OK:
 
452
                    self.treeview.add_tag(dialog.tagname, dialog._revid)
 
453
                
 
454
                dialog.destroy()
 
455
 
 
456
        finally:
 
457
            self.treeview.set_sensitive(True)
 
458
 
 
459
    def _about_dialog_cb(self, w):
 
460
        from bzrlib.plugins.gtk.about import AboutDialog
 
461
 
 
462
        AboutDialog().run()
386
463
 
387
464
    def _col_visibility_changed(self, col, property):
 
465
        self.config.set_user_option(property + '-column-visible', col.get_active())
388
466
        self.treeview.set_property(property + '-column-visible', col.get_active())
389
467
 
390
468
    def _toolbar_visibility_changed(self, col):
392
470
            self.toolbar.show() 
393
471
        else:
394
472
            self.toolbar.hide()
 
473
 
 
474
    def _show_about_cb(self, w):
 
475
        dialog = AboutDialog()
 
476
        dialog.connect('response', lambda d,r: d.destroy())
 
477
        dialog.run()
 
478
 
 
479
    def _refresh_clicked(self, w):
 
480
        self.treeview.refresh()
 
481
 
 
482
    def _update_tags(self):
 
483
        menu = gtk.Menu()
 
484
 
 
485
        if self.branch.supports_tags():
 
486
            tags = self.branch.tags.get_tag_dict().items()
 
487
            tags.sort()
 
488
            tags.reverse()
 
489
            for tag, revid in tags:
 
490
                tag_image = gtk.Image()
 
491
                tag_image.set_from_file(icon_path('tag-16.png'))
 
492
                tag_item = gtk.ImageMenuItem(tag.replace('_', '__'))
 
493
                tag_item.set_image(tag_image)
 
494
                tag_item.connect('activate', self._tag_selected_cb, revid)
 
495
                menu.add(tag_item)
 
496
            self.go_menu_tags.set_submenu(menu)
 
497
 
 
498
            self.go_menu_tags.set_sensitive(len(tags) != 0)
 
499
        else:
 
500
            self.go_menu_tags.set_sensitive(False)
 
501
 
 
502
        self.go_menu_tags.show_all()
 
503
 
 
504
    def show_diff(self, revid=None, parentid=None):
 
505
        """Open a new window to show a diff between the given revisions."""
 
506
        from bzrlib.plugins.gtk.diff import DiffWindow
 
507
        window = DiffWindow(parent=self)
 
508
 
 
509
        if parentid is None:
 
510
            parentid = NULL_REVISION
 
511
 
 
512
        rev_tree    = self.branch.repository.revision_tree(revid)
 
513
        parent_tree = self.branch.repository.revision_tree(parentid)
 
514
 
 
515
        description = revid + " - " + self.branch.nick
 
516
        window.set_diff(description, rev_tree, parent_tree)
 
517
        window.show()
 
518
 
 
519