2
# -*- coding: UTF-8 -*-
5
This module contains the code to manage the branch information window,
6
which contains both the revision graph and details panes.
9
__copyright__ = "Copyright © 2005 Canonical Ltd."
10
__author__ = "Scott James Remnant <scott@ubuntu.com>"
19
from bzrlib.osutils import format_date
21
from graph import graph
22
from graphcell import CellRendererGraph
25
class BranchWindow(gtk.Window):
28
This object represents and manages a single window containing information
29
for a particular branch.
33
gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
34
self.set_border_width(0)
35
self.set_title("bzrk")
37
# Use three-quarters of the screen by default
38
screen = self.get_screen()
39
width = int(screen.get_width() * 0.75)
40
height = int(screen.get_height() * 0.75)
41
self.set_default_size(width, height)
44
icon = self.render_icon(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON)
50
"""Construct the window contents."""
51
scrollwin = gtk.ScrolledWindow()
52
scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
53
scrollwin.set_shadow_type(gtk.SHADOW_IN)
54
scrollwin.set_border_width(12)
58
self.treeview = gtk.TreeView()
59
self.treeview.set_rules_hint(True)
60
self.treeview.set_search_column(4)
61
scrollwin.add(self.treeview)
64
cell = CellRendererGraph()
65
column = gtk.TreeViewColumn()
66
column.set_resizable(False)
67
column.pack_start(cell, expand=False)
68
column.add_attribute(cell, "node", 1)
69
column.add_attribute(cell, "in-lines", 2)
70
column.add_attribute(cell, "out-lines", 3)
71
self.treeview.append_column(column)
73
cell = gtk.CellRendererText()
74
cell.set_property("width-chars", 40)
75
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
76
column = gtk.TreeViewColumn("Message")
77
column.set_resizable(True)
78
column.pack_start(cell, expand=True)
79
column.add_attribute(cell, "text", 4)
80
self.treeview.append_column(column)
82
cell = gtk.CellRendererText()
83
cell.set_property("width-chars", 40)
84
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
85
column = gtk.TreeViewColumn("Committer")
86
column.set_resizable(True)
87
column.pack_start(cell, expand=True)
88
column.add_attribute(cell, "text", 5)
89
self.treeview.append_column(column)
91
cell = gtk.CellRendererText()
92
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
93
column = gtk.TreeViewColumn("Date")
94
column.set_resizable(True)
95
column.pack_start(cell, expand=True)
96
column.add_attribute(cell, "text", 6)
97
self.treeview.append_column(column)
99
def set_branch(self, branch, start):
100
"""Set the branch and start position for this window.
102
Creates a new TreeModel and populates it with information about
103
the new branch before updating the window title and model of the
106
# [ revision, node, last_lines, lines, message, committer, timestamp ]
107
model = gtk.ListStore(gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT,
108
gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT,
112
for revision, node, lines in graph(branch, start):
113
message = revision.message.split("\n")[0]
114
if revision.committer is not None:
115
timestamp = format_date(revision.timestamp, revision.timezone)
119
model.append([ revision, node, last_lines, lines,
120
message, revision.committer, timestamp ])
123
self.set_title(os.path.basename(branch.base) + " - bzrk")
124
self.treeview.set_model(model)