1
# Copyright (C) 2005, 2006, 2008, 2009 Canonical Ltd
1
# Copyright (C) 2005, 2006, 2008, 2009, 2010 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
231
231
self.to_messages_file.write(fmt_string % args)
232
232
self.to_messages_file.write('\n')
234
@deprecated_function(deprecated_in((1, 16, 0)))
235
def child_progress(self, **kwargs):
236
return ChildProgress(**kwargs)
239
235
class DummyProgress(_BaseProgressBar):
240
236
"""Progress-bar standin that does nothing.
261
257
return DummyProgress(**kwargs)
265
class ChildProgress(_BaseProgressBar):
266
"""A progress indicator that pushes its data to the parent"""
268
@deprecated_function(deprecated_in((1, 16, 0)))
269
def __init__(self, _stack, **kwargs):
270
_BaseProgressBar.__init__(self, _stack=_stack, **kwargs)
271
self.parent = _stack.top()
274
self.child_fraction = 0
277
def update(self, msg, current_cnt=None, total_cnt=None):
278
self.current = current_cnt
279
if total_cnt is not None:
280
self.total = total_cnt
282
self.child_fraction = 0
285
def child_update(self, message, current, total):
286
if current is None or total == 0:
287
self.child_fraction = 0
289
self.child_fraction = float(current) / total
293
if self.current is None:
296
count = self.current+self.child_fraction
297
if count > self.total:
299
mutter('clamping count of %d to %d' % (count, self.total))
301
self.parent.child_update(self.message, count, self.total)
306
def note(self, *args, **kwargs):
307
self.parent.note(*args, **kwargs)
310
260
def str_tdelta(delt):