/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 16:11:12 UTC
  • mfrom: (475.2.2 gtk)
  • mto: This revision was merged to the branch mainline in revision 519.
  • Revision ID: jelmer@samba.org-20080629161112-3j4zp0r0e7cv6cds
Merge Chad's progress bar in viz patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2006 Szilveszter Farkas <szilveszter.farkas@gmail.com>
 
2
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
2
3
 
3
4
# This program is free software; you can redistribute it and/or modify
4
5
# it under the terms of the GNU General Public License as published by
35
36
        
36
37
        self.vbox.show_all()
37
38
 
38
 
        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, 
 
40
                         gtk.RESPONSE_NO)
39
41
 
40
42
 
41
43
class GtkProgressBar(gtk.ProgressBar):
43
45
        super(GtkProgressBar, self).__init__()
44
46
        self.set_fraction(0.0)
45
47
        self._stack = stack
 
48
        self.current = None
 
49
        self.total = None
46
50
 
47
51
    def finished(self):
48
52
        self._stack.remove(self)
54
58
        self.pulse()
55
59
 
56
60
    def update(self, msg=None, current=None, total=None):
 
61
        if current:
 
62
            self.current = current
 
63
        if total:
 
64
            self.total = total
57
65
        if msg is not None:
58
66
            self.set_text(msg)
59
 
        self.set_fraction(1.0 * current / total)
 
67
        if None not in (self.current, self.total):
 
68
            self.set_fraction(1.0 * self.current / self.total)
60
69
        while gtk.events_pending():
61
70
            gtk.main_iteration()
62
71
 
83
92
 
84
93
    def remove(self, pb):
85
94
        self.vbox.remove(pb)
 
95
        if len(self.vbox.get_children()) == 0: # If there is nothing to show, don't leave a ghost window here
 
96
             self.destroy()
86
97
 
87
98
 
88
99
class PasswordDialog(gtk.Dialog):
117
128
 
118
129
        """
119
130
        super(GtkUIFactory, self).__init__()
120
 
        if stdout is None:
121
 
            self.stdout = sys.stdout
122
 
        else:
123
 
            self.stdout = stdout
124
 
        if stderr is None:
125
 
            self.stderr = sys.stderr
126
 
        else:
127
 
            self.stderr = stderr
128
131
        self._progress_bar_stack = None
129
132
 
130
133
    def get_boolean(self, prompt):