14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
from gi.repository import Gtk
20
class PluginsPage(Gtk.VPaned):
25
class PluginsPage(gtk.VPaned):
22
26
def __init__(self):
23
Gtk.VPaned.__init__(self)
24
self.set_border_width(12)
25
self.set_position(216)
27
scrolledwindow = Gtk.ScrolledWindow()
28
scrolledwindow.set_policy(
29
Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
30
scrolledwindow.set_shadow_type(Gtk.ShadowType.IN)
31
self.model = Gtk.ListStore(str, str)
32
treeview = Gtk.TreeView()
27
gtk.VPaned.__init__(self)
28
scrolledwindow = gtk.ScrolledWindow()
29
scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
30
self.model = gtk.ListStore(str, str)
31
treeview = gtk.TreeView()
33
32
scrolledwindow.add(treeview)
34
33
self.pack1(scrolledwindow, resize=True, shrink=False)
36
self.table = Gtk.Table(columns=2)
37
self.table.set_border_width(12)
35
self.table = gtk.Table(columns=2)
38
36
self.table.set_row_spacings(6)
39
37
self.table.set_col_spacings(6)
42
40
treeview.set_model(self.model)
43
41
treeview.connect("row-activated", self.row_selected)
45
cell = Gtk.CellRendererText()
46
column = Gtk.TreeViewColumn()
47
column.pack_start(cell, True)
43
cell = gtk.CellRendererText()
44
column = gtk.TreeViewColumn()
45
column.pack_start(cell, expand=True)
48
46
column.add_attribute(cell, "text", 0)
49
47
treeview.append_column(column)
51
cell = Gtk.CellRendererText()
52
column = Gtk.TreeViewColumn()
53
column.pack_start(cell, True)
49
cell = gtk.CellRendererText()
50
column = gtk.TreeViewColumn()
51
column.pack_start(cell, expand=True)
54
52
column.add_attribute(cell, "text", 1)
55
53
treeview.append_column(column)
57
55
import bzrlib.plugin
58
56
plugins = bzrlib.plugin.plugins()
59
57
plugin_names = plugins.keys()
60
58
plugin_names.sort()
61
59
for name in plugin_names:
62
60
self.model.append([name, getattr(plugins[name], '__file__', None)])
64
scrolledwindow = Gtk.ScrolledWindow()
65
scrolledwindow.set_policy(
66
Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
62
scrolledwindow = gtk.ScrolledWindow()
63
scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
67
64
scrolledwindow.add_with_viewport(self.table)
68
65
self.pack2(scrolledwindow, resize=False, shrink=True)
71
68
def row_selected(self, tv, path, tvc):
73
p = bzrlib.plugin.plugins()[self.model[path][0]].module
70
p = bzrlib.plugin.plugins()[self.model[path][0]]
74
71
from inspect import getdoc
76
73
for w in self.table.get_children():
77
74
self.table.remove(w)
79
76
if getattr(p, '__author__', None) is not None:
80
align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
77
align = gtk.Alignment(1.0, 0.5)
82
79
label.set_markup("<b>Author:</b>")
84
self.table.attach(align, 0, 1, 0, 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
81
self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
88
align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
85
align = gtk.Alignment(0.0, 0.5)
90
87
author.set_text(p.__author__)
91
88
author.set_selectable(True)
93
self.table.attach(align, 1, 2, 0, 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
90
self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
95
92
if getattr(p, '__version__', None) is not None:
96
align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
93
align = gtk.Alignment(1.0, 0.5)
98
95
label.set_markup("<b>Version:</b>")
100
self.table.attach(align, 0, 1, 0, 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
97
self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
104
align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
101
align = gtk.Alignment(0.0, 0.5)
106
103
author.set_text(p.__version__)
107
104
author.set_selectable(True)
108
105
align.add(author)
109
self.table.attach(align, 1, 2, 0, 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
106
self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
111
108
if getdoc(p) is not None:
112
align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
113
description = Gtk.Label()
109
align = gtk.Alignment(0.0, 0.5)
110
description = gtk.Label()
114
111
description.set_text(getdoc(p))
115
112
description.set_selectable(True)
116
113
align.add(description)
117
self.table.attach(align, 0, 2, 1, 2, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
114
self.table.attach(align, 0, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
119
116
self.table.show_all()