39
39
gtk.link_button_set_uri_hook(_open_link)
41
class BugsTab(gtk.Table):
41
class BugsTab(gtk.VBox):
43
43
def __init__(self):
44
super(BugsTab, self).__init__(rows=5, columns=2)
45
self.set_row_spacings(6)
46
self.set_col_spacings(6)
44
super(BugsTab, self).__init__(False, 6)
46
table = gtk.Table(rows=2, columns=2)
48
table.set_row_spacings(6)
49
table.set_col_spacing(0, 16)
52
image.set_from_file(icon_path("bug.png"))
53
table.attach(image, 0, 1, 0, 1, gtk.FILL)
55
align = gtk.Alignment(0.0, 0.1)
56
self.label = gtk.Label()
58
table.attach(align, 1, 2, 0, 1, gtk.FILL)
60
treeview = self.construct_treeview()
61
table.attach(treeview, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND)
63
self.set_border_width(6)
64
self.pack_start(table, expand=False)
69
def set_revision(self, revision):
74
bugs_text = revision.properties.get('bugs', '')
75
for bugline in bugs_text.splitlines():
76
(url, status) = bugline.split(" ")
78
self.add_bug(url, status)
80
if self.num_bugs == 0:
82
elif self.num_bugs == 1:
87
self.label.set_markup("<b>Bugs fixed</b>\n" +
88
"This revision claims to fix " +
89
"%d %s." % (self.num_bugs, label))
91
def construct_treeview(self):
92
self.bugs = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
93
self.treeview = gtk.TreeView(self.bugs)
94
self.treeview.set_headers_visible(False)
96
uri_column = gtk.TreeViewColumn('Bug URI', gtk.CellRendererText(), text=0)
97
self.treeview.append_column(uri_column)
99
self.treeview.connect('row-activated', self.on_row_activated)
101
win = gtk.ScrolledWindow()
102
win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
103
win.set_shadow_type(gtk.SHADOW_IN)
104
win.add(self.treeview)
50
for c in self.get_children():
53
self.hide_all() # Only shown when there are bugs
111
self.set_sensitive(False)
112
self.label.set_markup("<b>No bugs fixed</b>\n" +
113
"This revision does not claim to fix any bugs.")
55
115
def add_bug(self, url, status):
56
button = gtk.LinkButton(url, url)
57
self.attach(button, 0, 1, self.count, self.count + 1,
58
gtk.EXPAND | gtk.FILL, gtk.FILL)
59
status_label = gtk.Label(status)
60
self.attach(status_label, 1, 2, self.count, self.count + 1,
61
gtk.EXPAND | gtk.FILL, gtk.FILL)
117
self.bugs.append([url, status])
118
self.set_sensitive(True)
120
def get_num_bugs(self):
123
def on_row_activated(self, treeview, path, column):
124
uri = self.bugs.get_value(self.bugs.get_iter(path), 0)
125
_open_link(self, uri)
66
128
class SignatureTab(gtk.VBox):