25
class PluginsPage(gtk.VPaned):
23
from gi.repository import Gtk
26
class PluginsPage(Gtk.VPaned):
26
28
def __init__(self):
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()
29
GObject.GObject.__init__(self)
30
self.set_border_width(12)
31
self.set_position(216)
33
scrolledwindow = Gtk.ScrolledWindow()
34
scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
35
scrolledwindow.set_shadow_type(Gtk.ShadowType.IN)
36
self.model = Gtk.ListStore(str, str)
37
treeview = Gtk.TreeView()
32
38
scrolledwindow.add(treeview)
33
39
self.pack1(scrolledwindow, resize=True, shrink=False)
35
self.table = gtk.Table(columns=2)
41
self.table = Gtk.Table(columns=2)
42
self.table.set_border_width(12)
36
43
self.table.set_row_spacings(6)
37
44
self.table.set_col_spacings(6)
40
47
treeview.set_model(self.model)
41
48
treeview.connect("row-activated", self.row_selected)
43
cell = gtk.CellRendererText()
44
column = gtk.TreeViewColumn()
45
column.pack_start(cell, expand=True)
50
cell = Gtk.CellRendererText()
51
column = Gtk.TreeViewColumn()
52
column.pack_start(cell, True, True, 0)
46
53
column.add_attribute(cell, "text", 0)
47
54
treeview.append_column(column)
49
cell = gtk.CellRendererText()
50
column = gtk.TreeViewColumn()
51
column.pack_start(cell, expand=True)
56
cell = Gtk.CellRendererText()
57
column = Gtk.TreeViewColumn()
58
column.pack_start(cell, True, True, 0)
52
59
column.add_attribute(cell, "text", 1)
53
60
treeview.append_column(column)
55
62
import bzrlib.plugin
56
63
plugins = bzrlib.plugin.plugins()
57
64
plugin_names = plugins.keys()
58
65
plugin_names.sort()
59
66
for name in plugin_names:
60
67
self.model.append([name, getattr(plugins[name], '__file__', None)])
62
scrolledwindow = gtk.ScrolledWindow()
63
scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
69
scrolledwindow = Gtk.ScrolledWindow()
70
scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
64
71
scrolledwindow.add_with_viewport(self.table)
65
72
self.pack2(scrolledwindow, resize=False, shrink=True)
68
75
def row_selected(self, tv, path, tvc):
70
p = bzrlib.plugin.plugins()[self.model[path][0]]
77
p = bzrlib.plugin.plugins()[self.model[path][0]].module
71
78
from inspect import getdoc
73
80
for w in self.table.get_children():
74
81
self.table.remove(w)
76
83
if getattr(p, '__author__', None) is not None:
77
align = gtk.Alignment(1.0, 0.5)
84
align = Gtk.Alignment.new(0.0, 0.5)
79
86
label.set_markup("<b>Author:</b>")
81
self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
88
self.table.attach(align, 0, 1, 0, 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
85
align = gtk.Alignment(0.0, 0.5)
92
align = Gtk.Alignment.new(0.0, 0.5)
87
94
author.set_text(p.__author__)
88
95
author.set_selectable(True)
90
self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
97
self.table.attach(align, 1, 2, 0, 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
92
99
if getattr(p, '__version__', None) is not None:
93
align = gtk.Alignment(1.0, 0.5)
100
align = Gtk.Alignment.new(0.0, 0.5)
95
102
label.set_markup("<b>Version:</b>")
97
self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
104
self.table.attach(align, 0, 1, 0, 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
101
align = gtk.Alignment(0.0, 0.5)
108
align = Gtk.Alignment.new(0.0, 0.5)
103
110
author.set_text(p.__version__)
104
111
author.set_selectable(True)
105
112
align.add(author)
106
self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
113
self.table.attach(align, 1, 2, 0, 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
108
115
if getdoc(p) is not None:
109
align = gtk.Alignment(0.0, 0.5)
110
description = gtk.Label()
116
align = Gtk.Alignment.new(0.0, 0.5)
117
description = Gtk.Label()
111
118
description.set_text(getdoc(p))
112
119
description.set_selectable(True)
113
120
align.add(description)
114
self.table.attach(align, 0, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
121
self.table.attach(align, 0, 2, 1, 2, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
116
123
self.table.show_all()