/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: 2012-07-09 15:23:26 UTC
  • mto: This revision was merged to the branch mainline in revision 794.
  • Revision ID: jelmer@samba.org-20120709152326-dzxb8zoz0btull7n
Remove bzr-notify.

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