/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: rodney.dawes at canonical
  • Date: 2008-10-25 06:02:09 UTC
  • Revision ID: rodney.dawes@canonical.com-20081025060209-irlizouino63cs1m
        * preferences/__init__.py:
        Remove the dialog separator
        Remove useless extra call to self._create_pages()
        Make the default window size smaller
        Set the default border width on various widgets
        Set the current notebook page to the first one

        * preferences/identity.py:
        Set various border widths appropriately
        Align the labels to the left
        Remove the unneeded bold markup from the labels
        Change the "User Id" label to "E-Mail"
        Align the radio group labels to the top of the groups

        * preferences/plugins.py:
        Set various border widths appropriately
        Set the default paned position to something more sensible
        Set the shadow type on the treeview's scrolled window to in
        Align the Author and Version labels to the left

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import gtk
23
23
import sys
24
24
 
25
 
import bzrlib.progress
 
25
from bzrlib import progress
26
26
from bzrlib.ui import UIFactory
27
27
 
28
28
 
40
40
                         gtk.RESPONSE_NO)
41
41
 
42
42
 
43
 
class GtkProgressBar(gtk.ProgressBar):
44
 
    def __init__(self, stack):
45
 
        super(GtkProgressBar, self).__init__()
 
43
class GtkProgressBar(gtk.ProgressBar,progress._BaseProgressBar):
 
44
    def __init__(self, _stack=None):
 
45
        gtk.ProgressBar.__init__(self)
46
46
        self.set_fraction(0.0)
47
 
        self._stack = stack
48
 
 
49
 
    def finished(self):
50
 
        self._stack.remove(self)
 
47
        progress._BaseProgressBar.__init__(self, _stack=_stack)
 
48
        self.current = None
 
49
        self.total = None
51
50
 
52
51
    def clear(self):
53
 
        pass
 
52
        self.hide()
54
53
 
55
54
    def tick(self):
56
55
        self.pulse()
57
56
 
58
 
    def update(self, msg=None, current=None, total=None):
 
57
    def child_update(self, message, current, total):
 
58
        pass
 
59
 
 
60
    def update(self, msg=None, current_cnt=None, total_cnt=None):
 
61
        if current_cnt is not None:
 
62
            self.current = current_cnt
 
63
        if total_cnt is not None:
 
64
            self.total = total_cnt
59
65
        if msg is not None:
60
66
            self.set_text(msg)
61
 
        if None not in (current, total) and total > 0:
62
 
            self.set_fraction(1.0 * current / total)
 
67
        if None not in (self.current, self.total):
 
68
            self.fraction = float(self.current) / self.total
 
69
            if self.fraction < 0.0 or self.fraction > 1.0:
 
70
                raise AssertionError
 
71
            self.set_fraction(self.fraction)
63
72
        while gtk.events_pending():
64
73
            gtk.main_iteration()
65
74
 
66
75
 
67
 
class GtkProgressBarStack(gtk.Window):
68
 
    def __init__(self):
69
 
        super(GtkProgressBarStack, self).__init__(type=gtk.WINDOW_TOPLEVEL)
 
76
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):
 
79
        super(ProgressBarWindow, self).__init__(type=gtk.WINDOW_TOPLEVEL)
 
80
        self._stack = _stack
70
81
        self.set_border_width(0)
71
82
        self.set_title("Progress")
72
83
        self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
73
 
        self.vbox = gtk.VBox()
74
 
        self.add(self.vbox)
 
84
        self.pb = GtkProgressBar(self)
 
85
        self.add(self.pb)
 
86
        self.resize(250, 15)
75
87
        self.set_resizable(False)
76
 
 
77
 
    def _adapt_size(self):
78
 
        self.resize(250, 15 * len(self.vbox.get_children()))
79
 
 
80
 
    def get_nested(self):
81
 
        nested = GtkProgressBar(self)
82
 
        self.vbox.pack_start(nested)
83
 
        self._adapt_size()
84
 
        self.show_all()
85
 
        return nested
86
 
 
87
 
    def remove(self, pb):
88
 
        self.vbox.remove(pb)
89
 
        if len(self.vbox.get_children()) == 0: # If there is nothing to show, don't leave a ghost window here
90
 
             self.destroy()
 
88
        self.show_all()
 
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
 
 
103
    def clear(self):
 
104
        self.pb.clear()
 
105
        self.destroy()
 
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
 
 
117
 
 
118
class ProgressPanel(gtk.HBox):
 
119
    def __init__(self):
 
120
        super(ProgressPanel, self).__init__()
 
121
        image_loading = gtk.image_new_from_stock(gtk.STOCK_REFRESH,
 
122
                                                 gtk.ICON_SIZE_BUTTON)
 
123
        image_loading.show()
 
124
        
 
125
        self.pb = GtkProgressBar(self)
 
126
        self.set_spacing(5)
 
127
        self.set_border_width(5)        
 
128
        self.pack_start(image_loading, False, False)
 
129
        self.pack_start(self.pb, True, True)
 
130
 
 
131
    def return_pb(self, pb):
 
132
        self._stack.return_pb(self)
 
133
 
 
134
    def get_progress_bar(self, to_file=None, show_pct=None, show_spinner=None, show_eta=None, 
 
135
                         show_bar=None, show_count=None, to_messages_file=None, 
 
136
                         _stack=None):
 
137
        self._stack = _stack
 
138
        self.show_all()
 
139
        return self
 
140
 
 
141
    def tick(self, *args, **kwargs):
 
142
        self.pb.tick(*args, **kwargs)
 
143
    
 
144
    def update(self, *args, **kwargs):
 
145
        self.pb.update(*args, **kwargs)
 
146
 
 
147
    def finished(self):
 
148
        self.pb.finished()
 
149
        self.hide_all()
 
150
 
 
151
    def clear(self):
 
152
        self.pb.clear()
 
153
        self.hide_all()
 
154
 
 
155
    def child_progress(self, *args, **kwargs):
 
156
        return self.pb.child_progress(*args, **kwargs)
 
157
 
 
158
    def child_update(self, *args, **kwargs):
 
159
        return self.pb.child_update(*args, **kwargs)
 
160
 
91
161
 
92
162
 
93
163
class PasswordDialog(gtk.Dialog):
122
192
 
123
193
        """
124
194
        super(GtkUIFactory, self).__init__()
125
 
        self._progress_bar_stack = None
 
195
        self.set_nested_progress_bar_widget(ProgressBarWindow)
126
196
 
127
197
    def get_boolean(self, prompt):
128
198
        """GtkDialog with yes/no answers"""
150
220
        else:
151
221
            return None
152
222
 
 
223
    def set_nested_progress_bar_widget(self, widget):
 
224
        self._progress_bar_stack = progress.ProgressBarStack(klass=widget)
 
225
 
153
226
    def nested_progress_bar(self):
154
227
        """Return a nested progress bar.
155
228
        """
156
 
        if self._progress_bar_stack is None:
157
 
            self._progress_bar_stack = GtkProgressBarStack()
158
229
        return self._progress_bar_stack.get_nested()
159
230
 
160
231
    def set_progress_bar_vbox(self, vbox):