/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: Jelmer Vernooij
  • Date: 2011-12-20 16:16:57 UTC
  • Revision ID: jelmer@canonical.com-20111220161657-zjn6rqjrw8ouehf8
Drop support for old bencode location.

Show diffs side-by-side

added added

removed removed

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