/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-13 21:42:45 UTC
  • Revision ID: jelmer@samba.org-20070713214245-a66om6hcbahzvvmr
Ignore ctags files.

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