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