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