/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: Vincent Ladeuil
  • Date: 2009-06-12 09:46:44 UTC
  • mto: This revision was merged to the branch mainline in revision 648.
  • Revision ID: v.ladeuil+lp@free.fr-20090612094644-70bbxt2cgmf8sr27
Address Jelmer's review.

* ui.py:
(GtkProgressBar.tick, ProgressBarWindow.tick, ProgressPanel.tick):
Should show the widget, there may be some overlap here.
(ProgressBarWindow.finished): Relay to the progress bar and
destroy.
(ProgressBarWindow.clear): Don't destroy.
(GtkUIFactory.__init__): Default to None for the progress widget.
(GtkUIFactory._progress_updated): Create a ProgressBarWindow if no
widget has been set.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
        self.total = None
49
49
 
50
50
    def tick(self):
 
51
        self.show()
51
52
        self.pulse()
52
53
 
53
54
    def update(self, msg=None, current_cnt=None, total_cnt=None):
86
87
        self.set_resizable(False)
87
88
 
88
89
    def tick(self, *args, **kwargs):
 
90
        self.show_all()
89
91
        self.pb.tick(*args, **kwargs)
90
92
 
91
93
    def update(self, *args, **kwargs):
93
95
        self.pb.update(*args, **kwargs)
94
96
 
95
97
    def finished(self):
 
98
        self.pb.finished()
96
99
        self.hide_all()
97
 
 
98
 
    def clear(self):
99
 
        self.pb.clear()
100
 
        # FIXME: destroy() ? Really ? -- vila 20090610
101
100
        self.destroy()
102
101
 
 
102
    def clear(self):
 
103
        self.pb.clear()
 
104
        self.hide_all()
 
105
 
103
106
 
104
107
class ProgressPanel(gtk.HBox):
105
108
 
116
119
        self.pack_start(self.pb, True, True)
117
120
 
118
121
    def tick(self, *args, **kwargs):
 
122
        self.show_all()
119
123
        self.pb.tick(*args, **kwargs)
120
124
 
121
125
    def update(self, *args, **kwargs):
133
137
 
134
138
class PasswordDialog(gtk.Dialog):
135
139
    """ Prompt the user for a password. """
 
140
 
136
141
    def __init__(self, prompt):
137
142
        gtk.Dialog.__init__(self)
138
143
 
160
165
    def __init__(self):
161
166
        """Create a GtkUIFactory"""
162
167
        super(GtkUIFactory, self).__init__()
163
 
        # FIXME: The following seems to be there to provide a default for cases
164
 
        # where set_progress_bar_widget() is not called explicitely. It will be
165
 
        # better to call it explicitely and get rid of that default. (I'm not
166
 
        # even sure it really needed now :-/ -- vila 20090610.
167
 
        self.set_progress_bar_widget(ProgressBarWindow())
 
168
        self.set_progress_bar_widget(None)
168
169
 
169
170
    def get_boolean(self, prompt):
170
171
        """GtkDialog with yes/no answers"""
197
198
        pbw = self._progress_bar_widget
198
199
        if pbw:
199
200
            pbw.finished()
 
201
            self.set_progress_bar_widget(None)
200
202
 
201
203
    def _progress_updated(self, task):
202
204
        """See UIFactory._progress_updated"""
203
 
        pbw = self._progress_bar_widget
204
 
        if pbw:
205
 
            pbw.update(task.msg, task.current_cnt, task.total_cnt)
 
205
        if self._progress_bar_widget is None:
 
206
            # Default to a window since nobody gave us a better mean to report
 
207
            # progress.
 
208
            self.set_progress_bar_widget(ProgressBarWindow())
 
209
        self._progress_bar_widget.update(task.msg,
 
210
                                         task.current_cnt, task.total_cnt)
206
211
 
207
212
    def set_progress_bar_widget(self, widget):
208
213
        self._progress_bar_widget = widget