/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-11-30 21:45:54 UTC
  • Revision ID: jelmer@samba.org-20111130214554-5kfx0b5y7t5zh033
Extend branch preferences, show location widget.

Show diffs side-by-side

added added

removed removed

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