1
# Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org>
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
class PluginsPage(gtk.VPaned):
28
gtk.VPaned.__init__(self)
29
self.set_border_width(12)
30
self.set_position(216)
32
scrolledwindow = gtk.ScrolledWindow()
33
scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
34
scrolledwindow.set_shadow_type(gtk.SHADOW_IN)
35
self.model = gtk.ListStore(str, str)
36
treeview = gtk.TreeView()
37
scrolledwindow.add(treeview)
38
self.pack1(scrolledwindow, resize=True, shrink=False)
40
self.table = gtk.Table(columns=2)
41
self.table.set_border_width(12)
42
self.table.set_row_spacings(6)
43
self.table.set_col_spacings(6)
45
treeview.set_headers_visible(False)
46
treeview.set_model(self.model)
47
treeview.connect("row-activated", self.row_selected)
49
cell = gtk.CellRendererText()
50
column = gtk.TreeViewColumn()
51
column.pack_start(cell, expand=True)
52
column.add_attribute(cell, "text", 0)
53
treeview.append_column(column)
55
cell = gtk.CellRendererText()
56
column = gtk.TreeViewColumn()
57
column.pack_start(cell, expand=True)
58
column.add_attribute(cell, "text", 1)
59
treeview.append_column(column)
62
plugins = bzrlib.plugin.plugins()
63
plugin_names = plugins.keys()
65
for name in plugin_names:
66
self.model.append([name, getattr(plugins[name], '__file__', None)])
68
scrolledwindow = gtk.ScrolledWindow()
69
scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
70
scrolledwindow.add_with_viewport(self.table)
71
self.pack2(scrolledwindow, resize=False, shrink=True)
74
def row_selected(self, tv, path, tvc):
76
p = bzrlib.plugin.plugins()[self.model[path][0]].module
77
from inspect import getdoc
79
for w in self.table.get_children():
82
if getattr(p, '__author__', None) is not None:
83
align = gtk.Alignment(0.0, 0.5)
85
label.set_markup("<b>Author:</b>")
87
self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
91
align = gtk.Alignment(0.0, 0.5)
93
author.set_text(p.__author__)
94
author.set_selectable(True)
96
self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
98
if getattr(p, '__version__', None) is not None:
99
align = gtk.Alignment(0.0, 0.5)
101
label.set_markup("<b>Version:</b>")
103
self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
107
align = gtk.Alignment(0.0, 0.5)
109
author.set_text(p.__version__)
110
author.set_selectable(True)
112
self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
114
if getdoc(p) is not None:
115
align = gtk.Alignment(0.0, 0.5)
116
description = gtk.Label()
117
description.set_text(getdoc(p))
118
description.set_selectable(True)
119
align.add(description)
120
self.table.attach(align, 0, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
122
self.table.show_all()