/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: Daniel Schierbeck
  • Date: 2007-11-07 14:19:09 UTC
  • mfrom: (330.3.5 trunk)
  • Revision ID: daniel.schierbeck@gmail.com-20071107141909-3zxf7nw5laldvfxi
Merged with mainline.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from bzrlib.plugins.gtk.preferences import PreferencesWindow
19
19
from bzrlib.revision import Revision
20
20
from bzrlib.config import BranchConfig
 
21
from bzrlib.config import GlobalConfig
21
22
from treeview import TreeView
22
23
 
23
24
class BranchWindow(Window):
39
40
        Window.__init__(self, parent=parent)
40
41
        self.set_border_width(0)
41
42
 
42
 
        self.branch = branch
43
 
        self.start  = start
44
 
        self.maxnum = maxnum
 
43
        self.branch      = branch
 
44
        self.start       = start
 
45
        self.maxnum      = maxnum
 
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
45
52
 
46
53
        self.set_title(branch.nick + " - revision history")
47
54
 
61
68
 
62
69
        self.construct()
63
70
 
 
71
    def set_revision(self, revision):
 
72
        self.treeview.set_revision(revision)
 
73
 
64
74
    def construct(self):
65
75
        """Construct the window contents."""
66
76
        vbox = gtk.VBox(spacing=0)
192
202
        image_loading.show()
193
203
        
194
204
        label_loading = gtk.Label(_("Please wait, loading ancestral graph..."))
195
 
        label_loading.set_alignment(0.0, 0.5)  
 
205
        label_loading.set_alignment(0.0, 0.5)
196
206
        label_loading.show()
197
207
        
198
208
        self.loading_msg_box = gtk.HBox()
207
217
    def construct_top(self):
208
218
        """Construct the top-half of the window."""
209
219
        # FIXME: Make broken_line_length configurable
210
 
        self.treeview = TreeView(self.branch, self.start, self.maxnum, 32)
 
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)
211
226
 
212
227
        self.treeview.connect("revision-selected",
213
228
                self._treeselection_changed_cb)
229
244
                                         0, 0)
230
245
        self.back_button.connect("clicked", self._back_clicked_cb)
231
246
        self.toolbar.insert(self.back_button, -1)
232
 
        self.back_button.show()
233
247
 
234
248
        self.fwd_button = gtk.MenuToolButton(stock_id=gtk.STOCK_GO_UP)
235
249
        self.fwd_button.add_accelerator("clicked", self.accel_group, ord(']'),
236
250
                                        0, 0)
237
251
        self.fwd_button.connect("clicked", self._fwd_clicked_cb)
238
252
        self.toolbar.insert(self.fwd_button, -1)
239
 
        self.fwd_button.show()
240
 
 
241
 
        self.toolbar.show()
 
253
 
 
254
        self.toolbar.insert(gtk.SeparatorToolItem(), -1)
 
255
 
 
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)
 
262
 
 
263
        self.toolbar.show_all()
242
264
 
243
265
        return self.toolbar
244
266
 
330
352
    def _set_revision_cb(self, w, revision_id):
331
353
        self.treeview.set_revision_id(revision_id)
332
354
 
 
355
    def _brokenlines_toggled_cb(self, button):
 
356
        self.compact_view = button.get_active()
 
357
 
 
358
        if self.compact_view:
 
359
            option = 'yes'
 
360
        else:
 
361
            option = 'no'
 
362
 
 
363
        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)
 
371
 
333
372
    def _tag_revision_cb(self, w):
334
373
        dialog = AddTagDialog(self.branch.repository, self.treeview.get_revision().revision_id, self.branch)
335
374
        response = dialog.run()