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