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

  • Committer: Curtis Hovey
  • Date: 2012-02-27 19:21:31 UTC
  • mto: (776.3.1 gpush)
  • mto: This revision was merged to the branch mainline in revision 779.
  • Revision ID: sinzui.is@verizon.net-20120227192131-eye15mnp9os7cv6j
Clean up test module.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    return with_main_iteration
34
34
 
35
35
 
36
 
class PromptDialog(Gtk.MessageDialog):
 
36
class PromptDialog(Gtk.Dialog):
37
37
    """Prompt the user for a yes/no answer."""
38
38
 
39
 
    def __init__(self, prompt, parent=None):
40
 
        super(PromptDialog, self).__init__(
41
 
            parent, Gtk.DialogFlags.DESTROY_WITH_PARENT,
42
 
            Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, prompt)
43
 
 
44
 
 
45
 
class InfoDialog(Gtk.MessageDialog):
46
 
    """Show the user an informational message."""
47
 
 
48
 
    MESSAGE_TYPE = Gtk.MessageType.INFO
49
 
 
50
 
    def __init__(self, prompt, parent=None):
51
 
        super(InfoDialog, self).__init__(
52
 
            parent, Gtk.DialogFlags.DESTROY_WITH_PARENT,
53
 
            self.MESSAGE_TYPE, Gtk.ButtonsType.CLOSE, prompt)
54
 
 
55
 
 
56
 
class WarningDialog(InfoDialog):
57
 
    """Show the user a warning message."""
58
 
 
59
 
    MESSAGE_TYPE = Gtk.MessageType.WARNING
60
 
 
61
 
 
62
 
class ErrorDialog(InfoDialog):
63
 
    """Show the user a warning message."""
64
 
 
65
 
    MESSAGE_TYPE = Gtk.MessageType.ERROR
 
39
    def __init__(self, prompt):
 
40
        super(PromptDialog, self).__init__()
 
41
 
 
42
        label = Gtk.Label(label=prompt)
 
43
        self.get_content_area().pack_start(label, True, True, 10)
 
44
        self.get_content_area().show_all()
 
45
 
 
46
        self.add_buttons(Gtk.STOCK_YES, Gtk.ResponseType.YES, Gtk.STOCK_NO,
 
47
                         Gtk.ResponseType.NO)
66
48
 
67
49
 
68
50
class GtkProgressBar(Gtk.ProgressBar):
193
175
        dialog.destroy()
194
176
        return (response == Gtk.ResponseType.YES)
195
177
 
196
 
    def show_message(self, msg):
197
 
        """See UIFactory.show_message."""
198
 
        dialog = InfoDialog(msg)
199
 
        dialog.run()
200
 
        dialog.destroy()
201
 
 
202
 
    def show_warning(self, msg):
203
 
        """See UIFactory.show_warning."""
204
 
        dialog = WarningDialog(msg)
205
 
        dialog.run()
206
 
        dialog.destroy()
207
 
 
208
 
    def show_error(self, msg):
209
 
        """See UIFactory.show_error."""
210
 
        dialog = ErrorDialog(msg)
211
 
        dialog.run()
212
 
        dialog.destroy()
213
 
 
214
 
    def show_user_warning(self, warning_id, **message_args):
215
 
        """See UIFactory.show_user_warning."""
216
 
        if warning_id not in self.suppressed_warnings:
217
 
            message = self.format_user_warning(warning_id, message_args)
218
 
            self.show_warning(message)
219
 
 
220
178
    def get_password(self, prompt='', **kwargs):
221
179
        """Prompt the user for a password.
222
180