/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to preferences/plugins.py

  • Committer: Curtis Hovey
  • Date: 2012-02-05 05:14:11 UTC
  • mto: This revision was merged to the branch mainline in revision 775.
  • Revision ID: sinzui.is@verizon.net-20120205051411-y9ra08wae1wsfv52
Remove unneeded gtksourceview1 support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
from gi.repository import Gtk
 
18
 
 
19
 
 
20
class PluginsPage(Gtk.VPaned):
 
21
 
 
22
    def __init__(self):
 
23
        super(PluginsPage, self).__init__()
 
24
        self.set_border_width(12)
 
25
        self.set_position(216)
 
26
 
 
27
        scrolledwindow = Gtk.ScrolledWindow()
 
28
        scrolledwindow.set_policy(
 
29
            Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
 
30
        scrolledwindow.set_shadow_type(Gtk.ShadowType.IN)
 
31
        self.model = Gtk.ListStore(str, str)
 
32
        treeview = Gtk.TreeView()
 
33
        scrolledwindow.add(treeview)
 
34
        self.pack1(scrolledwindow, resize=True, shrink=False)
 
35
 
 
36
        self.table = Gtk.Table(columns=2)
 
37
        self.table.set_border_width(12)
 
38
        self.table.set_row_spacings(6)
 
39
        self.table.set_col_spacings(6)
 
40
 
 
41
        treeview.set_headers_visible(False)
 
42
        treeview.set_model(self.model)
 
43
        treeview.connect("row-activated", self.row_selected)
 
44
        treeview.connect("cursor-changed", self.row_selected)
 
45
 
 
46
        cell = Gtk.CellRendererText()
 
47
        column = Gtk.TreeViewColumn()
 
48
        column.pack_start(cell, True)
 
49
        column.add_attribute(cell, "text", 0)
 
50
        treeview.append_column(column)
 
51
 
 
52
        cell = Gtk.CellRendererText()
 
53
        column = Gtk.TreeViewColumn()
 
54
        column.pack_start(cell, True)
 
55
        column.add_attribute(cell, "text", 1)
 
56
        treeview.append_column(column)
 
57
 
 
58
        import bzrlib.plugin
 
59
        plugins = bzrlib.plugin.plugins()
 
60
        plugin_names = plugins.keys()
 
61
        plugin_names.sort()
 
62
        for name in plugin_names:
 
63
            self.model.append([name, getattr(plugins[name], '__file__', None)])
 
64
 
 
65
        scrolledwindow = Gtk.ScrolledWindow()
 
66
        scrolledwindow.set_policy(
 
67
            Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
 
68
        scrolledwindow.add_with_viewport(self.table)
 
69
        self.pack2(scrolledwindow, resize=False, shrink=True)
 
70
        self.show()
 
71
 
 
72
    def row_selected(self, tv, path=None, tvc=None):
 
73
        if path is None:
 
74
            (path, focus) = tv.get_cursor()
 
75
        if path is None:
 
76
            # The event was fired as the widget was destroyed.
 
77
            return
 
78
        import bzrlib
 
79
        p = bzrlib.plugin.plugins()[self.model[path][0]].module
 
80
        from inspect import getdoc
 
81
 
 
82
        for w in self.table.get_children():
 
83
            self.table.remove(w)
 
84
 
 
85
        if getattr(p, '__author__', None) is not None:
 
86
            align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
 
87
            label = Gtk.Label()
 
88
            label.set_markup("<b>Author:</b>")
 
89
            align.add(label)
 
90
            self.table.attach(align, 0, 1, 0, 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
 
91
            align.show()
 
92
            label.show()
 
93
 
 
94
            align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
 
95
            author = Gtk.Label()
 
96
            author.set_text(p.__author__)
 
97
            author.set_selectable(True)
 
98
            align.add(author)
 
99
            self.table.attach(align, 1, 2, 0, 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
 
100
 
 
101
        if getattr(p, '__version__', None) is not None:
 
102
            align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
 
103
            label = Gtk.Label()
 
104
            label.set_markup("<b>Version:</b>")
 
105
            align.add(label)
 
106
            self.table.attach(align, 0, 1, 0, 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
 
107
            align.show()
 
108
            label.show()
 
109
 
 
110
            align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
 
111
            author = Gtk.Label()
 
112
            author.set_text(p.__version__)
 
113
            author.set_selectable(True)
 
114
            align.add(author)
 
115
            self.table.attach(align, 1, 2, 0, 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
 
116
 
 
117
        if getdoc(p) is not None:
 
118
            align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0)
 
119
            description = Gtk.Label()
 
120
            description.set_text(getdoc(p))
 
121
            description.set_selectable(True)
 
122
            align.add(description)
 
123
            self.table.attach(align, 0, 2, 1, 2, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL)
 
124
 
 
125
        self.table.show_all()