/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 branchview/treeview.py

  • Committer: Curtis Hovey
  • Date: 2012-03-22 17:14:22 UTC
  • mto: This revision was merged to the branch mainline in revision 789.
  • Revision ID: sinzui.is@verizon.net-20120322171422-l7bq6muqqgr36nxr
Ensure that the per/file message widget fits at least one line.

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
        :param broken_line_length: After how much lines to break 
106
106
                                   branches.
107
107
        """
108
 
        GObject.GObject.__init__(self, spacing=0)
 
108
        super(TreeView, self).__init__(homogeneous=False, spacing=0)
109
109
 
110
110
        self.progress_widget = ProgressPanel()
111
 
        self.pack_start(self.progress_widget, expand=False, fill=True)
 
111
        self.pack_start(self.progress_widget, False, True, 0)
112
112
        if getattr(ui.ui_factory, "set_progress_bar_widget", None) is not None:
113
113
            # We'are using our own ui, let's tell it to use our widget.
114
114
            ui.ui_factory.set_progress_bar_widget(self.progress_widget)
118
118
                                        Gtk.PolicyType.AUTOMATIC)
119
119
        self.scrolled_window.set_shadow_type(Gtk.ShadowType.IN)
120
120
        self.scrolled_window.show()
121
 
        self.pack_start(self.scrolled_window, expand=True, fill=True)
 
121
        self.pack_start(self.scrolled_window, True, True, 0)
122
122
 
123
123
        self.scrolled_window.add(self.construct_treeview())
124
124
 
131
131
        self.maxnum = maxnum
132
132
        self.compact = compact
133
133
 
134
 
        self.model = treemodel.TreeModel(self.branch, [])
 
134
        self.model = treemodel.BranchTreeModel(self.branch, [])
135
135
        GObject.idle_add(self.populate)
136
136
 
137
137
        self.connect("destroy", self._on_destroy)
211
211
 
212
212
        :param revid: Revision id of revision to display.
213
213
        """
214
 
        self.treeview.set_cursor(self.index[revid])
 
214
        self.treeview.set_cursor(
 
215
            Gtk.TreePath(path=self.index[revid]), None, False)
215
216
        self.treeview.grab_focus()
216
217
 
217
218
    def get_children(self):
259
260
    def back(self):
260
261
        """Signal handler for the Back button."""
261
262
        parents = self.get_parents()
262
 
        if not len(parents):
 
263
        if not parents:
263
264
            return
264
265
 
265
266
        for parent_id in parents:
274
275
    def forward(self):
275
276
        """Signal handler for the Forward button."""
276
277
        children = self.get_children()
277
 
        if not len(children):
 
278
        if not children:
278
279
            return
279
280
 
280
281
        for child_id in children:
311
312
            show_graph = self.graph_column.get_visible()
312
313
 
313
314
            self.branch.lock_read()
314
 
            (linegraphdata, index, columns_len) = linegraph(self.branch.repository.get_graph(),
315
 
                                                            self.start,
316
 
                                                            self.maxnum, 
317
 
                                                            broken_line_length,
318
 
                                                            show_graph,
319
 
                                                            self.mainline_only,
320
 
                                                            self.progress_bar)
 
315
            (linegraphdata, index, columns_len) = linegraph(
 
316
                self.branch.repository.get_graph(),
 
317
                self.start,
 
318
                self.maxnum, 
 
319
                broken_line_length,
 
320
                show_graph,
 
321
                self.mainline_only,
 
322
                self.progress_bar)
321
323
 
322
 
            self.model.line_graph_data = linegraphdata
 
324
            self.model.set_line_graph_data(linegraphdata)
323
325
            self.graph_cell.columns_len = columns_len
324
 
            width = self.graph_cell.get_size(self.treeview)[2]
 
326
            width = self.graph_cell.get_preferred_width(self.treeview)[1]
325
327
            if width > 500:
326
328
                width = 500
 
329
            elif width == 0:
 
330
                # The get_preferred_width() call got an insane value.
 
331
                width = 200
327
332
            self.graph_column.set_fixed_width(width)
328
333
            self.graph_column.set_max_width(width)
329
334
            self.index = index
330
335
            self.treeview.set_model(self.model)
331
336
 
332
337
            if not revision or revision == NULL_REVISION:
333
 
                self.treeview.set_cursor(0)
 
338
                self.treeview.set_cursor(Gtk.TreePath(path=0), None, False)
334
339
            else:
335
340
                self.set_revision(revision)
336
341
 
353
358
            return (model.get_value(iter, treemodel.REVNO).find(key) != 0
354
359
                and model.get_value(iter, treemodel.MESSAGE).lower().find(key.lower()) == -1)
355
360
 
356
 
        self.treeview.set_search_equal_func(search_equal_func)
 
361
        self.treeview.set_search_equal_func(search_equal_func, None)
357
362
        self.treeview.set_enable_search(True)
358
363
 
359
 
        set_tooltip(treemodel.MESSAGE)
 
364
        self.treeview.set_tooltip_column(treemodel.MESSAGE)
 
365
        self.treeview.set_headers_visible(True)
360
366
 
361
367
        self._prev_cursor_path = None
362
368
        self.treeview.connect("cursor-changed",
378
384
        self.revno_column = Gtk.TreeViewColumn("Revision No")
379
385
        self.revno_column.set_resizable(True)
380
386
        self.revno_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
381
 
        self.revno_column.set_fixed_width(cell.get_size(self.treeview)[2])
382
 
        self.revno_column.pack_start(cell, True, True, 0)
 
387
        self.revno_column.set_fixed_width(
 
388
            cell.get_preferred_width(self.treeview)[1])
 
389
        self.revno_column.pack_start(cell, True)
383
390
        self.revno_column.add_attribute(cell, "text", treemodel.REVNO)
384
391
        self.treeview.append_column(self.revno_column)
385
392
 
387
394
        self.graph_column = Gtk.TreeViewColumn()
388
395
        self.graph_column.set_resizable(True)
389
396
        self.graph_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
390
 
        self.graph_column.pack_start(self.graph_cell, True, True, 0)
391
 
        self.graph_column.add_attribute(self.graph_cell, "node", treemodel.NODE)
392
 
        self.graph_column.add_attribute(self.graph_cell, "tags", treemodel.TAGS)
393
 
        self.graph_column.add_attribute(self.graph_cell, "in-lines", treemodel.LAST_LINES)
394
 
        self.graph_column.add_attribute(self.graph_cell, "out-lines", treemodel.LINES)
 
397
        self.graph_column.pack_start(self.graph_cell, True)
 
398
        self.graph_column.add_attribute(
 
399
            self.graph_cell, "node", treemodel.NODE)
 
400
        self.graph_column.add_attribute(
 
401
            self.graph_cell, "tags", treemodel.TAGS)
 
402
        self.graph_column.add_attribute(
 
403
            self.graph_cell, "in-lines", treemodel.LAST_LINES)
 
404
        self.graph_column.add_attribute(
 
405
            self.graph_cell, "out-lines", treemodel.LINES)
395
406
        self.treeview.append_column(self.graph_column)
396
407
 
397
408
        cell = Gtk.CellRendererText()
401
412
        self.summary_column.set_resizable(True)
402
413
        self.summary_column.set_expand(True)
403
414
        self.summary_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
404
 
        self.summary_column.set_fixed_width(cell.get_size(self.treeview)[2])
405
 
        self.summary_column.pack_start(cell, True, True, 0)
 
415
        self.summary_column.set_fixed_width(
 
416
            cell.get_preferred_width(self.treeview)[1])
 
417
        self.summary_column.pack_start(cell, True)
406
418
        self.summary_column.add_attribute(cell, "markup", treemodel.SUMMARY)
407
419
        self.treeview.append_column(self.summary_column)
408
420
 
413
425
        self.authors_column.set_resizable(False)
414
426
        self.authors_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
415
427
        self.authors_column.set_fixed_width(200)
416
 
        self.authors_column.pack_start(cell, True, True, 0)
 
428
        self.authors_column.pack_start(cell, True)
417
429
        self.authors_column.add_attribute(cell, "text", treemodel.AUTHORS)
418
430
        self.treeview.append_column(self.authors_column)
419
431
 
425
437
        self.date_column.set_resizable(True)
426
438
        self.date_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
427
439
        self.date_column.set_fixed_width(130)
428
 
        self.date_column.pack_start(cell, True, True, 0)
 
440
        self.date_column.pack_start(cell, True)
429
441
        self.date_column.add_attribute(cell, "text", treemodel.TIMESTAMP)
430
442
        self.treeview.append_column(self.date_column)
431
443
 
442
454
    def _on_revision_selected(self, widget, event):
443
455
        from bzrlib.plugins.gtk.revisionmenu import RevisionMenu
444
456
        if event.button == 3:
445
 
            menu = RevisionMenu(self.branch.repository, 
446
 
                [self.get_revision().revision_id],
447
 
                self.branch)
 
457
            revs = []
 
458
            rev = self.get_revision()
 
459
            if rev is not None:
 
460
                revs.append(rev.revision_id)
 
461
            menu = RevisionMenu(self.branch.repository, revs, self.branch)
448
462
            menu.connect('tag-added', lambda w, t, r: self.add_tag(t, r))
449
 
            menu.popup(None, None, None, event.button, event.get_time())
 
463
            menu.popup(None, None, None, None, event.button, event.get_time())
450
464
 
451
465
    def _on_revision_activated(self, widget, path, col):
452
466
        self.emit('revision-activated', path, col)