38
37
self.vbox.show_all()
40
self.add_buttons(gtk.STOCK_YES, gtk.RESPONSE_YES, gtk.STOCK_NO, gtk.RESPONSE_NO)
39
self.add_buttons(gtk.STOCK_YES, gtk.RESPONSE_YES, gtk.STOCK_NO,
43
class GtkProgressBar(gtk.ProgressBar,progress._BaseProgressBar):
44
def __init__(self, _stack=None):
45
gtk.ProgressBar.__init__(self)
46
self.set_fraction(0.0)
47
progress._BaseProgressBar.__init__(self, _stack=_stack)
57
def child_update(self, message, current, total):
60
def update(self, msg=None, current_cnt=None, total_cnt=None):
62
self.current = current_cnt
64
self.total = total_cnt
67
if None not in (self.current, self.total):
68
self.fraction = float(self.current) / self.total
69
self.set_fraction(self.fraction)
70
while gtk.events_pending():
74
class ProgressBarWindow(gtk.Window):
75
def __init__(self, to_file=None, show_pct=None, show_spinner=None, show_eta=None,
76
show_bar=None, show_count=None, to_messages_file=None, _stack=None):
77
super(ProgressBarWindow, self).__init__(type=gtk.WINDOW_TOPLEVEL)
79
self.set_border_width(0)
80
self.set_title("Progress")
81
self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
82
self.pb = GtkProgressBar(self)
85
self.set_resizable(False)
88
def return_pb(self, pb):
89
self._stack.return_pb(self)
91
def update(self, *args, **kwargs):
92
self.pb.update(*args, **kwargs)
102
def child_progress(self, *args, **kwargs):
103
return self.pb.child_progress(*args, **kwargs)
105
def child_update(self, *args, **kwargs):
106
return self.pb.child_update(*args, **kwargs)
108
def get_progress_bar(self):
113
class ProgressPanel(gtk.HBox):
115
super(ProgressPanel, self).__init__()
116
image_loading = gtk.image_new_from_stock(gtk.STOCK_REFRESH,
117
gtk.ICON_SIZE_BUTTON)
120
self.pb = GtkProgressBar(self)
122
self.set_border_width(5)
123
self.pack_start(image_loading, False, False)
124
self.pack_start(self.pb, True, True)
126
def return_pb(self, pb):
127
self._stack.return_pb(self)
129
def get_progress_bar(self, to_file=None, show_pct=None, show_spinner=None, show_eta=None,
130
show_bar=None, show_count=None, to_messages_file=None,
136
def update(self, *args, **kwargs):
137
self.pb.update(*args, **kwargs)
147
def child_progress(self, *args, **kwargs):
148
return self.pb.child_progress(*args, **kwargs)
150
def child_update(self, *args, **kwargs):
151
return self.pb.child_update(*args, **kwargs)
43
155
class PasswordDialog(gtk.Dialog):
215
def set_nested_progress_bar_widget(self, widget):
216
self._progress_bar_stack = progress.ProgressBarStack(klass=widget)
122
218
def nested_progress_bar(self):
123
219
"""Return a nested progress bar.
125
The actual bar type returned depends on the progress module which
126
may return a tty or dots bar depending on the terminal.
128
FIXME: It should return a GtkProgressBar actually.
130
if self._progress_bar_stack is None:
131
self._progress_bar_stack = bzrlib.progress.ProgressBarStack(
132
klass=self._bar_type)
133
221
return self._progress_bar_stack.get_nested()
223
def set_progress_bar_vbox(self, vbox):
224
"""Change the vbox to put progress bars in.
226
self._progress_bar_stack = vbox
135
228
def clear_term(self):
136
229
"""Prepare the terminal for output.