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) |
|
615
by rodney.dawes at canonical
* preferences/__init__.py: |
28 |
self.set_border_width(12) |
29 |
self.set_position(216) |
|
30 |
||
450.3.2
by Jelmer Vernooij
Split plugins page out into a separate file. |
31 |
scrolledwindow = gtk.ScrolledWindow() |
32 |
scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
|
615
by rodney.dawes at canonical
* preferences/__init__.py: |
33 |
scrolledwindow.set_shadow_type(gtk.SHADOW_IN) |
450.1.14
by Jelmer Vernooij
Fix regressions in plugins tab. |
34 |
self.model = gtk.ListStore(str, str) |
450.3.2
by Jelmer Vernooij
Split plugins page out into a separate file. |
35 |
treeview = gtk.TreeView() |
36 |
scrolledwindow.add(treeview) |
|
37 |
self.pack1(scrolledwindow, resize=True, shrink=False) |
|
38 |
||
450.1.14
by Jelmer Vernooij
Fix regressions in plugins tab. |
39 |
self.table = gtk.Table(columns=2) |
615
by rodney.dawes at canonical
* preferences/__init__.py: |
40 |
self.table.set_border_width(12) |
450.1.14
by Jelmer Vernooij
Fix regressions in plugins tab. |
41 |
self.table.set_row_spacings(6) |
42 |
self.table.set_col_spacings(6) |
|
450.3.2
by Jelmer Vernooij
Split plugins page out into a separate file. |
43 |
|
44 |
treeview.set_headers_visible(False) |
|
450.1.14
by Jelmer Vernooij
Fix regressions in plugins tab. |
45 |
treeview.set_model(self.model) |
450.3.2
by Jelmer Vernooij
Split plugins page out into a separate file. |
46 |
treeview.connect("row-activated", self.row_selected) |
47 |
||
48 |
cell = gtk.CellRendererText() |
|
49 |
column = gtk.TreeViewColumn() |
|
50 |
column.pack_start(cell, expand=True) |
|
51 |
column.add_attribute(cell, "text", 0) |
|
52 |
treeview.append_column(column) |
|
53 |
||
54 |
cell = gtk.CellRendererText() |
|
55 |
column = gtk.TreeViewColumn() |
|
56 |
column.pack_start(cell, expand=True) |
|
57 |
column.add_attribute(cell, "text", 1) |
|
58 |
treeview.append_column(column) |
|
59 |
||
60 |
import bzrlib.plugin |
|
61 |
plugins = bzrlib.plugin.plugins() |
|
62 |
plugin_names = plugins.keys() |
|
63 |
plugin_names.sort() |
|
64 |
for name in plugin_names: |
|
450.1.14
by Jelmer Vernooij
Fix regressions in plugins tab. |
65 |
self.model.append([name, getattr(plugins[name], '__file__', None)]) |
450.3.2
by Jelmer Vernooij
Split plugins page out into a separate file. |
66 |
|
67 |
scrolledwindow = gtk.ScrolledWindow() |
|
68 |
scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
|
450.1.14
by Jelmer Vernooij
Fix regressions in plugins tab. |
69 |
scrolledwindow.add_with_viewport(self.table) |
450.3.2
by Jelmer Vernooij
Split plugins page out into a separate file. |
70 |
self.pack2(scrolledwindow, resize=False, shrink=True) |
71 |
self.show() |
|
72 |
||
73 |
def row_selected(self, tv, path, tvc): |
|
450.1.14
by Jelmer Vernooij
Fix regressions in plugins tab. |
74 |
import bzrlib |
560.1.1
by Jasper Groenewegen
Fix plugin description in gpreferences |
75 |
p = bzrlib.plugin.plugins()[self.model[path][0]].module |
450.3.2
by Jelmer Vernooij
Split plugins page out into a separate file. |
76 |
from inspect import getdoc |
77 |
||
450.1.14
by Jelmer Vernooij
Fix regressions in plugins tab. |
78 |
for w in self.table.get_children(): |
79 |
self.table.remove(w) |
|
450.3.2
by Jelmer Vernooij
Split plugins page out into a separate file. |
80 |
|
81 |
if getattr(p, '__author__', None) is not None: |
|
615
by rodney.dawes at canonical
* preferences/__init__.py: |
82 |
align = gtk.Alignment(0.0, 0.5) |
450.3.2
by Jelmer Vernooij
Split plugins page out into a separate file. |
83 |
label = gtk.Label() |
84 |
label.set_markup("<b>Author:</b>") |
|
85 |
align.add(label) |
|
450.1.14
by Jelmer Vernooij
Fix regressions in plugins tab. |
86 |
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. |
87 |
align.show() |
88 |
label.show() |
|
89 |
||
90 |
align = gtk.Alignment(0.0, 0.5) |
|
91 |
author = gtk.Label() |
|
92 |
author.set_text(p.__author__) |
|
93 |
author.set_selectable(True) |
|
94 |
align.add(author) |
|
450.1.14
by Jelmer Vernooij
Fix regressions in plugins tab. |
95 |
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. |
96 |
|
97 |
if getattr(p, '__version__', None) is not None: |
|
615
by rodney.dawes at canonical
* preferences/__init__.py: |
98 |
align = gtk.Alignment(0.0, 0.5) |
450.3.2
by Jelmer Vernooij
Split plugins page out into a separate file. |
99 |
label = gtk.Label() |
100 |
label.set_markup("<b>Version:</b>") |
|
101 |
align.add(label) |
|
450.1.14
by Jelmer Vernooij
Fix regressions in plugins tab. |
102 |
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. |
103 |
align.show() |
104 |
label.show() |
|
105 |
||
106 |
align = gtk.Alignment(0.0, 0.5) |
|
107 |
author = gtk.Label() |
|
108 |
author.set_text(p.__version__) |
|
109 |
author.set_selectable(True) |
|
110 |
align.add(author) |
|
450.1.14
by Jelmer Vernooij
Fix regressions in plugins tab. |
111 |
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. |
112 |
|
113 |
if getdoc(p) is not None: |
|
114 |
align = gtk.Alignment(0.0, 0.5) |
|
115 |
description = gtk.Label() |
|
116 |
description.set_text(getdoc(p)) |
|
117 |
description.set_selectable(True) |
|
118 |
align.add(description) |
|
450.1.14
by Jelmer Vernooij
Fix regressions in plugins tab. |
119 |
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. |
120 |
|
450.1.14
by Jelmer Vernooij
Fix regressions in plugins tab. |
121 |
self.table.show_all() |
450.3.2
by Jelmer Vernooij
Split plugins page out into a separate file. |
122 |
|
123 |