33
35
return with_main_iteration
36
class PromptDialog(Gtk.MessageDialog):
38
class PromptDialog(Gtk.Dialog):
37
39
"""Prompt the user for a yes/no answer."""
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)
45
class InfoDialog(Gtk.MessageDialog):
46
"""Show the user an informational message."""
48
MESSAGE_TYPE = Gtk.MessageType.INFO
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)
56
class WarningDialog(InfoDialog):
57
"""Show the user a warning message."""
59
MESSAGE_TYPE = Gtk.MessageType.WARNING
62
class ErrorDialog(InfoDialog):
63
"""Show the user a warning message."""
65
MESSAGE_TYPE = Gtk.MessageType.ERROR
41
def __init__(self, prompt):
42
super(PromptDialog, self).__init__()
44
label = Gtk.Label(label=prompt)
45
self.get_content_area().pack_start(label, True, True, 10)
46
self.get_content_area().show_all()
48
self.add_buttons(Gtk.STOCK_YES, Gtk.ResponseType.YES, Gtk.STOCK_NO,
68
52
class GtkProgressBar(Gtk.ProgressBar):
194
178
return (response == Gtk.ResponseType.YES)
196
def show_message(self, msg):
197
"""See UIFactory.show_message."""
198
dialog = InfoDialog(msg)
202
def show_warning(self, msg):
203
"""See UIFactory.show_warning."""
204
dialog = WarningDialog(msg)
208
def show_error(self, msg):
209
"""See UIFactory.show_error."""
210
dialog = ErrorDialog(msg)
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)
220
180
def get_password(self, prompt='', **kwargs):
221
181
"""Prompt the user for a password.
249
209
self.set_progress_bar_widget(ProgressBarWindow())
251
211
def _progress_updated(self, task):
252
"""See UIFactory._progress_updated."""
212
"""See UIFactory._progress_updated"""
253
213
self._ensure_progress_widget()
254
214
self._progress_bar_widget.update(task.msg,
255
215
task.current_cnt, task.total_cnt)
257
217
def report_transport_activity(self, transport, byte_count, direction):
258
"""See UIFactory.report_transport_activity."""
218
"""See UIFactory.report_transport_activity"""
259
219
self._ensure_progress_widget()
260
220
self._progress_bar_widget.tick()