/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: Jelmer Vernooij
  • Date: 2008-07-31 01:55:07 UTC
  • mto: (580.2.1 gtk.gloom)
  • mto: This revision was merged to the branch mainline in revision 581.
  • Revision ID: jelmer@samba.org-20080731015507-tarukc7r26ud7twu
Avoid making assumptions about a branch being a loom until we've checked.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
        pass
59
59
 
60
60
    def update(self, msg=None, current_cnt=None, total_cnt=None):
61
 
        if current_cnt:
 
61
        if current_cnt is not None:
62
62
            self.current = current_cnt
63
 
        if total_cnt:
 
63
        if total_cnt is not None:
64
64
            self.total = total_cnt
65
65
        if msg is not None:
66
66
            self.set_text(msg)
67
67
        if None not in (self.current, self.total):
68
68
            self.fraction = float(self.current) / self.total
 
69
            if self.fraction < 0.0 or self.fraction > 1.0:
 
70
                raise AssertionError
69
71
            self.set_fraction(self.fraction)
70
72
        while gtk.events_pending():
71
73
            gtk.main_iteration()
72
74
 
73
75
 
74
76
class ProgressBarWindow(gtk.Window):
75
 
    def __init__(self):
 
77
    def __init__(self, to_file=None, show_pct=None, show_spinner=None, show_eta=None, 
 
78
                 show_bar=None, show_count=None, to_messages_file=None, _stack=None):
76
79
        super(ProgressBarWindow, self).__init__(type=gtk.WINDOW_TOPLEVEL)
 
80
        self._stack = _stack
77
81
        self.set_border_width(0)
78
82
        self.set_title("Progress")
79
83
        self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
83
87
        self.set_resizable(False)
84
88
        self.show_all()
85
89
 
 
90
    def return_pb(self, pb):
 
91
        self._stack.return_pb(self)
 
92
    
 
93
    def update(self, *args, **kwargs):
 
94
        self.pb.update(*args, **kwargs)
 
95
 
 
96
    def tick(self, *args, **kwargs):
 
97
        self.pb.tick(*args, **kwargs)
 
98
 
 
99
    def finished(self):
 
100
        self.pb.finished()
 
101
        self.hide_all()
 
102
 
86
103
    def clear(self):
87
104
        self.pb.clear()
88
105
        self.destroy()
89
106
 
 
107
    def child_progress(self, *args, **kwargs):
 
108
        return self.pb.child_progress(*args, **kwargs)
 
109
 
 
110
    def child_update(self, *args, **kwargs):
 
111
        return self.pb.child_update(*args, **kwargs)
 
112
 
 
113
    def get_progress_bar(self):
 
114
        self.show_all()
 
115
        return self
 
116
 
90
117
 
91
118
class ProgressPanel(gtk.HBox):
92
119
    def __init__(self):
110
137
        self._stack = _stack
111
138
        self.show_all()
112
139
        return self
 
140
 
 
141
    def tick(self, *args, **kwargs):
 
142
        self.pb.tick(*args, **kwargs)
113
143
    
114
144
    def update(self, *args, **kwargs):
115
145
        self.pb.update(*args, **kwargs)