/b-gtk/fix-viz

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