92
92
def construct_top(self):
93
93
"""Construct the top-half of the window."""
94
scrollwin = gtk.ScrolledWindow()
95
scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
96
scrollwin.set_shadow_type(gtk.SHADOW_IN)
99
self.treeview = gtk.TreeView()
100
self.treeview.set_rules_hint(True)
101
self.treeview.set_search_column(4)
102
self.treeview.get_selection().connect("changed", self._treeselection_changed_cb)
103
self.treeview.connect("row-activated", self._treeview_row_activated_cb)
104
self.treeview.connect("button-release-event",
105
self._treeview_row_mouseclick)
106
self.treeview.set_property('fixed-height-mode', True)
107
scrollwin.add(self.treeview)
94
self.treeview = TreeView()
96
self.treeview.treeview.get_selection().connect("changed",
97
self._treeselection_changed_cb)
108
99
self.treeview.show()
110
cell = gtk.CellRendererText()
111
cell.set_property("width-chars", 15)
112
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
113
column = gtk.TreeViewColumn("Revision No")
114
column.set_resizable(True)
115
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
116
column.set_fixed_width(cell.get_size(self.treeview)[2])
117
column.pack_start(cell, expand=True)
118
column.add_attribute(cell, "text", treemodel.REVNO)
119
self.treeview.append_column(column)
121
self.graph_cell = CellRendererGraph()
122
self.graph_column = gtk.TreeViewColumn()
123
self.graph_column.set_resizable(True)
124
self.graph_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
125
self.graph_column.pack_start(self.graph_cell, expand=False)
126
self.graph_column.add_attribute(self.graph_cell, "node", treemodel.NODE)
127
self.graph_column.add_attribute(self.graph_cell, "in-lines", treemodel.LAST_LINES)
128
self.graph_column.add_attribute(self.graph_cell, "out-lines", treemodel.LINES)
129
self.treeview.append_column(self.graph_column)
131
cell = gtk.CellRendererText()
132
cell.set_property("width-chars", 65)
133
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
134
column = gtk.TreeViewColumn("Message")
135
column.set_resizable(True)
136
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
137
column.set_fixed_width(cell.get_size(self.treeview)[2])
138
column.pack_start(cell, expand=True)
139
column.add_attribute(cell, "text", treemodel.MESSAGE)
140
self.treeview.append_column(column)
142
cell = gtk.CellRendererText()
143
cell.set_property("width-chars", 15)
144
cell.set_property("ellipsize", pango.ELLIPSIZE_END)
145
column = gtk.TreeViewColumn("Committer")
146
column.set_resizable(True)
147
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
148
column.set_fixed_width(cell.get_size(self.treeview)[2])
149
column.pack_start(cell, expand=True)
150
column.add_attribute(cell, "text", treemodel.COMMITER)
151
self.treeview.append_column(column)
155
103
def construct_navigation(self):
156
104
"""Construct the navigation buttons."""
201
149
self.branch = branch
202
150
self.set_title(branch.nick + " - revision history")
203
gobject.idle_add(self.populate_model, start, maxnum)
205
def populate_model(self, start, maxnum):
206
self.branch.lock_read()
207
(linegraphdata, index, columns_len) = linegraph(self.branch,
210
self.model = TreeModel(self.branch, linegraphdata)
211
self.graph_cell.columns_len = columns_len
212
width = self.graph_cell.get_size(self.treeview)[2]
213
self.graph_column.set_fixed_width(width)
214
self.graph_column.set_max_width(width)
216
self.treeview.set_model(self.model)
217
self.treeview.set_cursor(0)
218
self.loading_msg_box.hide()
151
self.treeview.set_branch(branch, start, maxnum)
221
153
def _on_key_pressed(self, widget, event):
222
154
""" Key press event handler. """
238
170
def _treeselection_changed_cb(self, selection, *args):
239
"""Callback for when the treeview changes."""
240
(model, selected_rows) = selection.get_selected_rows()
241
if len(selected_rows) > 0:
242
iter = self.model.get_iter(selected_rows[0])
243
revision = self.model.get_value(iter, treemodel.REVISION)
244
parents = self.model.get_value(iter, treemodel.PARENTS)
245
children = self.model.get_value(iter, treemodel.CHILDREN)
171
"""callback for when the treeview changes."""
172
revision = self.treeview.get_revision()
173
parents = self.treeview.get_parents()
174
children = self.treeview.get_children()
176
if revision is not None:
247
177
self.back_button.set_sensitive(len(parents) > 0)
248
178
self.fwd_button.set_sensitive(len(children) > 0)