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