/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-06-29 18:12:29 UTC
  • mto: This revision was merged to the branch mainline in revision 519.
  • Revision ID: jelmer@samba.org-20080629181229-1l2m4cf7vvbyh8qg
Simplify progress bar code, use embedded progress bar inside viz window.

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 is not None:
 
61
        if current_cnt:
62
62
            self.current = current_cnt
63
 
        if total_cnt is not None:
 
63
        if total_cnt:
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
71
69
            self.set_fraction(self.fraction)
72
70
        while gtk.events_pending():
73
71
            gtk.main_iteration()
74
72
 
75
73
 
76
74
class ProgressBarWindow(gtk.Window):
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):
 
75
    def __init__(self):
79
76
        super(ProgressBarWindow, self).__init__(type=gtk.WINDOW_TOPLEVEL)
80
 
        self._stack = _stack
81
77
        self.set_border_width(0)
82
78
        self.set_title("Progress")
83
79
        self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
87
83
        self.set_resizable(False)
88
84
        self.show_all()
89
85
 
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
 
 
103
86
    def clear(self):
104
87
        self.pb.clear()
105
88
        self.destroy()
106
89
 
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
 
 
117
90
 
118
91
class ProgressPanel(gtk.HBox):
119
92
    def __init__(self):
137
110
        self._stack = _stack
138
111
        self.show_all()
139
112
        return self
140
 
 
141
 
    def tick(self, *args, **kwargs):
142
 
        self.pb.tick(*args, **kwargs)
143
113
    
144
114
    def update(self, *args, **kwargs):
145
115
        self.pb.update(*args, **kwargs)