bzr branch
http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
| 
450.3.2
by Jelmer Vernooij
 Split plugins page out into a separate file.  | 
1  | 
# Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org>
 | 
2  | 
#
 | 
|
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.
 | 
|
7  | 
#
 | 
|
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.
 | 
|
12  | 
#
 | 
|
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
 | 
|
16  | 
||
17  | 
try:  | 
|
18  | 
import pygtk  | 
|
19  | 
pygtk.require("2.0")  | 
|
20  | 
except:  | 
|
21  | 
    pass
 | 
|
22  | 
||
23  | 
import gtk  | 
|
24  | 
||
25  | 
class PluginsPage(gtk.VPaned):  | 
|
26  | 
def __init__(self):  | 
|
27  | 
gtk.VPaned.__init__(self)  | 
|
28  | 
scrolledwindow = gtk.ScrolledWindow()  | 
|
29  | 
scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)  | 
|
| 
450.1.14
by Jelmer Vernooij
 Fix regressions in plugins tab.  | 
30  | 
self.model = gtk.ListStore(str, str)  | 
| 
450.3.2
by Jelmer Vernooij
 Split plugins page out into a separate file.  | 
31  | 
treeview = gtk.TreeView()  | 
32  | 
scrolledwindow.add(treeview)  | 
|
33  | 
self.pack1(scrolledwindow, resize=True, shrink=False)  | 
|
34  | 
||
| 
450.1.14
by Jelmer Vernooij
 Fix regressions in plugins tab.  | 
35  | 
self.table = gtk.Table(columns=2)  | 
36  | 
self.table.set_row_spacings(6)  | 
|
37  | 
self.table.set_col_spacings(6)  | 
|
| 
450.3.2
by Jelmer Vernooij
 Split plugins page out into a separate file.  | 
38  | 
|
39  | 
treeview.set_headers_visible(False)  | 
|
| 
450.1.14
by Jelmer Vernooij
 Fix regressions in plugins tab.  | 
40  | 
treeview.set_model(self.model)  | 
| 
450.3.2
by Jelmer Vernooij
 Split plugins page out into a separate file.  | 
41  | 
treeview.connect("row-activated", self.row_selected)  | 
42  | 
||
43  | 
cell = gtk.CellRendererText()  | 
|
44  | 
column = gtk.TreeViewColumn()  | 
|
45  | 
column.pack_start(cell, expand=True)  | 
|
46  | 
column.add_attribute(cell, "text", 0)  | 
|
47  | 
treeview.append_column(column)  | 
|
48  | 
||
49  | 
cell = gtk.CellRendererText()  | 
|
50  | 
column = gtk.TreeViewColumn()  | 
|
51  | 
column.pack_start(cell, expand=True)  | 
|
52  | 
column.add_attribute(cell, "text", 1)  | 
|
53  | 
treeview.append_column(column)  | 
|
54  | 
||
55  | 
import bzrlib.plugin  | 
|
56  | 
plugins = bzrlib.plugin.plugins()  | 
|
57  | 
plugin_names = plugins.keys()  | 
|
58  | 
plugin_names.sort()  | 
|
59  | 
for name in plugin_names:  | 
|
| 
450.1.14
by Jelmer Vernooij
 Fix regressions in plugins tab.  | 
60  | 
self.model.append([name, getattr(plugins[name], '__file__', None)])  | 
| 
450.3.2
by Jelmer Vernooij
 Split plugins page out into a separate file.  | 
61  | 
|
62  | 
scrolledwindow = gtk.ScrolledWindow()  | 
|
63  | 
scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)  | 
|
| 
450.1.14
by Jelmer Vernooij
 Fix regressions in plugins tab.  | 
64  | 
scrolledwindow.add_with_viewport(self.table)  | 
| 
450.3.2
by Jelmer Vernooij
 Split plugins page out into a separate file.  | 
65  | 
self.pack2(scrolledwindow, resize=False, shrink=True)  | 
66  | 
self.show()  | 
|
67  | 
||
68  | 
def row_selected(self, tv, path, tvc):  | 
|
| 
450.1.14
by Jelmer Vernooij
 Fix regressions in plugins tab.  | 
69  | 
import bzrlib  | 
| 
560.1.1
by Jasper Groenewegen
 Fix plugin description in gpreferences  | 
70  | 
p = bzrlib.plugin.plugins()[self.model[path][0]].module  | 
| 
450.3.2
by Jelmer Vernooij
 Split plugins page out into a separate file.  | 
71  | 
from inspect import getdoc  | 
72  | 
||
| 
450.1.14
by Jelmer Vernooij
 Fix regressions in plugins tab.  | 
73  | 
for w in self.table.get_children():  | 
74  | 
self.table.remove(w)  | 
|
| 
450.3.2
by Jelmer Vernooij
 Split plugins page out into a separate file.  | 
75  | 
|
76  | 
if getattr(p, '__author__', None) is not None:  | 
|
77  | 
align = gtk.Alignment(1.0, 0.5)  | 
|
78  | 
label = gtk.Label()  | 
|
79  | 
label.set_markup("<b>Author:</b>")  | 
|
80  | 
align.add(label)  | 
|
| 
450.1.14
by Jelmer Vernooij
 Fix regressions in plugins tab.  | 
81  | 
self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)  | 
| 
450.3.2
by Jelmer Vernooij
 Split plugins page out into a separate file.  | 
82  | 
align.show()  | 
83  | 
label.show()  | 
|
84  | 
||
85  | 
align = gtk.Alignment(0.0, 0.5)  | 
|
86  | 
author = gtk.Label()  | 
|
87  | 
author.set_text(p.__author__)  | 
|
88  | 
author.set_selectable(True)  | 
|
89  | 
align.add(author)  | 
|
| 
450.1.14
by Jelmer Vernooij
 Fix regressions in plugins tab.  | 
90  | 
self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)  | 
| 
450.3.2
by Jelmer Vernooij
 Split plugins page out into a separate file.  | 
91  | 
|
92  | 
if getattr(p, '__version__', None) is not None:  | 
|
93  | 
align = gtk.Alignment(1.0, 0.5)  | 
|
94  | 
label = gtk.Label()  | 
|
95  | 
label.set_markup("<b>Version:</b>")  | 
|
96  | 
align.add(label)  | 
|
| 
450.1.14
by Jelmer Vernooij
 Fix regressions in plugins tab.  | 
97  | 
self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)  | 
| 
450.3.2
by Jelmer Vernooij
 Split plugins page out into a separate file.  | 
98  | 
align.show()  | 
99  | 
label.show()  | 
|
100  | 
||
101  | 
align = gtk.Alignment(0.0, 0.5)  | 
|
102  | 
author = gtk.Label()  | 
|
103  | 
author.set_text(p.__version__)  | 
|
104  | 
author.set_selectable(True)  | 
|
105  | 
align.add(author)  | 
|
| 
450.1.14
by Jelmer Vernooij
 Fix regressions in plugins tab.  | 
106  | 
self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)  | 
| 
450.3.2
by Jelmer Vernooij
 Split plugins page out into a separate file.  | 
107  | 
|
108  | 
if getdoc(p) is not None:  | 
|
109  | 
align = gtk.Alignment(0.0, 0.5)  | 
|
110  | 
description = gtk.Label()  | 
|
111  | 
description.set_text(getdoc(p))  | 
|
112  | 
description.set_selectable(True)  | 
|
113  | 
align.add(description)  | 
|
| 
450.1.14
by Jelmer Vernooij
 Fix regressions in plugins tab.  | 
114  | 
self.table.attach(align, 0, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)  | 
| 
450.3.2
by Jelmer Vernooij
 Split plugins page out into a separate file.  | 
115  | 
|
| 
450.1.14
by Jelmer Vernooij
 Fix regressions in plugins tab.  | 
116  | 
self.table.show_all()  | 
| 
450.3.2
by Jelmer Vernooij
 Split plugins page out into a separate file.  | 
117  | 
|
118  |