/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.py

  • Committer: Jelmer Vernooij
  • Date: 2007-07-15 15:13:34 UTC
  • Revision ID: jelmer@samba.org-20070715151334-2t0g8fmpgj6vnqa7
Add icon for Bazaar preferences.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import gtk
24
24
 
25
25
from bzrlib.config import GlobalConfig
26
 
from identity import IdentityPage
27
 
from plugins import PluginsPage
28
 
from notifications import NotificationsPage
29
26
 
30
27
class PreferencesWindow(gtk.Dialog):
31
28
    """Displays global preferences windows."""
32
 
    # Note that we don't allow configuration of aliases or 
33
 
    # default log formats. This is because doing so wouldn't make 
34
 
    # a lot of sense to pure GUI users. Users that need these settings 
35
 
    # will already be familiar with the configuration file.
36
 
 
37
29
    def __init__(self, config=None):
38
30
        """ Initialize the Status window. """
39
31
        super(PreferencesWindow, self).__init__(flags=gtk.DIALOG_MODAL)
40
32
        self.set_title("Bazaar Preferences")
41
 
        self.set_has_separator(False)
42
33
        self.config = config
43
34
        if self.config is None:
44
35
            self.config = GlobalConfig()
45
36
        self._create()
46
37
 
 
38
    def _create_mainpage(self):
 
39
        table = gtk.Table(rows=4, columns=2)
 
40
        table.set_row_spacings(6)
 
41
        table.set_col_spacings(6)
 
42
 
 
43
        align = gtk.Alignment(1.0, 0.5)
 
44
        label = gtk.Label()
 
45
        label.set_markup("<b>User Id:</b>")
 
46
        align.add(label)
 
47
        table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
 
48
 
 
49
        align = gtk.Alignment(0.0, 0.5)
 
50
        self.username = gtk.Entry()
 
51
        align.add(self.username)
 
52
        self.username.set_text(self.config.username())
 
53
        table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
54
 
 
55
        align = gtk.Alignment(1.0, 0.5)
 
56
        label = gtk.Label()
 
57
        label.set_markup("<b>GPG signing command:</b>")
 
58
        align.add(label)
 
59
        table.attach(align, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
 
60
 
 
61
        align = gtk.Alignment(0.0, 0.5)
 
62
        self.email = gtk.Entry()
 
63
        self.email.set_text(self.config.gpg_signing_command())
 
64
        align.add(self.email)
 
65
        table.attach(align, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
66
 
 
67
        align = gtk.Alignment(1.0, 0.5)
 
68
        label = gtk.Label()
 
69
        label.set_markup("<b>Check GPG Signatures:</b>")
 
70
        align.add(label)
 
71
        table.attach(align, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
 
72
 
 
73
        align = gtk.Alignment(0.0, 0.5)
 
74
        sigvals = gtk.VBox()
 
75
        self.check_sigs_if_possible = gtk.RadioButton(None, 
 
76
                                                      "_Check if possible")
 
77
        sigvals.pack_start(self.check_sigs_if_possible)
 
78
        self.check_sigs_always = gtk.RadioButton(self.check_sigs_if_possible, 
 
79
                                                 "Check _always")
 
80
        sigvals.pack_start(self.check_sigs_always)
 
81
        self.check_sigs_never = gtk.RadioButton(self.check_sigs_if_possible,
 
82
                                                "Check _never")
 
83
        sigvals.pack_start(self.check_sigs_never)
 
84
        # FIXME: Set default
 
85
        align.add(sigvals)
 
86
        table.attach(align, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
87
 
 
88
        align = gtk.Alignment(1.0, 0.5)
 
89
        label = gtk.Label()
 
90
        label.set_markup("<b>Create GPG Signatures:</b>")
 
91
        align.add(label)
 
92
        table.attach(align, 0, 1, 3, 4, gtk.FILL, gtk.FILL)
 
93
 
 
94
        align = gtk.Alignment(0.0, 0.5)
 
95
        create_sigs = gtk.VBox()
 
96
        self.create_sigs_when_required = gtk.RadioButton(None, 
 
97
                                                         "Sign When _Required")
 
98
        create_sigs.pack_start(self.create_sigs_when_required)
 
99
        self.create_sigs_always = gtk.RadioButton(
 
100
            self.create_sigs_when_required, "Sign _Always")
 
101
        create_sigs.pack_start(self.create_sigs_always)
 
102
        self.create_sigs_never = gtk.RadioButton(
 
103
            self.create_sigs_when_required, "Sign _Never")
 
104
        create_sigs.pack_start(self.create_sigs_never)
 
105
        # FIXME: Set default
 
106
        align.add(create_sigs)
 
107
        table.attach(align, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
108
 
 
109
        return table
 
110
 
 
111
    def _create_pluginpage(self):
 
112
        vbox = gtk.VBox(False, 2)
 
113
        vbox.set_border_width(6)
 
114
 
 
115
        scrolledwindow = gtk.ScrolledWindow()
 
116
        scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
 
117
        model = gtk.ListStore(str, str)
 
118
        treeview = gtk.TreeView()
 
119
        scrolledwindow.add(treeview)
 
120
 
 
121
        table = gtk.Table(columns=2)
 
122
        table.set_row_spacings(6)
 
123
        table.set_col_spacings(6)
 
124
 
 
125
 
 
126
        def row_selected(tv, path, tvc):
 
127
            p = bzrlib.plugin.all_plugins()[model[path][0]]
 
128
            from inspect import getdoc
 
129
 
 
130
            for w in table.get_children():
 
131
                table.remove(w)
 
132
 
 
133
            if getattr(p, '__author__', None) is not None:
 
134
                align = gtk.Alignment(1.0, 0.5)
 
135
                label = gtk.Label()
 
136
                label.set_markup("<b>Author:</b>")
 
137
                align.add(label)
 
138
                table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
 
139
                align.show()
 
140
                label.show()
 
141
 
 
142
                align = gtk.Alignment(0.0, 0.5)
 
143
                author = gtk.Label()
 
144
                author.set_text(p.__author__)
 
145
                author.set_selectable(True)
 
146
                align.add(author)
 
147
                table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
148
 
 
149
            if getattr(p, '__version__', None) is not None:
 
150
                align = gtk.Alignment(1.0, 0.5)
 
151
                label = gtk.Label()
 
152
                label.set_markup("<b>Version:</b>")
 
153
                align.add(label)
 
154
                table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
 
155
                align.show()
 
156
                label.show()
 
157
 
 
158
                align = gtk.Alignment(0.0, 0.5)
 
159
                author = gtk.Label()
 
160
                author.set_text(p.__version__)
 
161
                author.set_selectable(True)
 
162
                align.add(author)
 
163
                table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
164
 
 
165
            if getdoc(p) is not None:
 
166
                align = gtk.Alignment(0.0, 0.5)
 
167
                description = gtk.Label()
 
168
                description.set_text(getdoc(p))
 
169
                description.set_selectable(True)
 
170
                align.add(description)
 
171
                table.attach(align, 0, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
172
 
 
173
            table.show_all()
 
174
 
 
175
        treeview.set_headers_visible(False)
 
176
        treeview.set_model(model)
 
177
        treeview.connect("row-activated", row_selected)
 
178
 
 
179
        cell = gtk.CellRendererText()
 
180
        column = gtk.TreeViewColumn()
 
181
        column.pack_start(cell, expand=True)
 
182
        column.add_attribute(cell, "text", 0)
 
183
        treeview.append_column(column)
 
184
 
 
185
        cell = gtk.CellRendererText()
 
186
        column = gtk.TreeViewColumn()
 
187
        column.pack_start(cell, expand=True)
 
188
        column.add_attribute(cell, "text", 1)
 
189
        treeview.append_column(column)
 
190
        
 
191
        import bzrlib.plugin
 
192
        plugins = bzrlib.plugin.all_plugins()
 
193
        plugin_names = plugins.keys()
 
194
        plugin_names.sort()
 
195
        for name in plugin_names:
 
196
            model.append([name, getattr(plugins[name], '__file__', None)])
 
197
                 
 
198
        vbox.pack_start(scrolledwindow, expand=True, fill=True)
 
199
 
 
200
        vbox.pack_start(table)
 
201
 
 
202
        return vbox
 
203
 
47
204
    def _create(self):
48
 
        self.set_default_size(320, 480)
49
 
        self.set_border_width(0)
50
 
 
 
205
        self.set_default_size(600, 600)
51
206
        notebook = gtk.Notebook()
52
 
        notebook.set_border_width(12)
53
 
        for (label, page) in self._create_pages():
54
 
            notebook.append_page(page, gtk.Label(label))
55
 
 
56
 
        notebook.set_current_page(0)
57
 
        self.vbox.set_border_width(0)
 
207
        notebook.insert_page(self._create_mainpage(), gtk.Label("Main"))
 
208
        notebook.insert_page(self._create_pluginpage(), gtk.Label("Plugins"))
58
209
        self.vbox.pack_start(notebook, True, True)
59
210
        self.vbox.show_all()
60
 
        self.action_area.set_border_width(12)
61
 
 
62
 
    def _create_pages(self):
63
 
        return [("Identity", IdentityPage(self.config)), 
64
 
                ("Plugins", PluginsPage()),
65
 
                ("Notifications", NotificationsPage(self.config))]
66
211
 
67
212
    def display(self):
68
213
        self.window.show_all()