/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-09 03:43:01 UTC
  • mto: This revision was merged to the branch mainline in revision 776.
  • Revision ID: sinzui.is@verizon.net-20120209034301-0uwkobbb0d64ugrw
Switched from Gtk.VPaned to Gtk.Paned.new(Gtk.Orientation.VERTICAL).

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