/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: Gustav Hartvigsson
  • Date: 2014-11-25 15:34:07 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20141125153407-827k8g7qy9u5byd5
* Fixed bzr-gtk's viz util, using the new Gtk Inspector.

Show diffs side-by-side

added added

removed removed

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