/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: 2008-05-05 18:16:46 UTC
  • mto: (487.1.1 gtk)
  • mto: This revision was merged to the branch mainline in revision 490.
  • Revision ID: v.ladeuil+lp@free.fr-20080505181646-n95l8ltw2u6jtr26
Fix bug #187283 fix replacing _() by _i18n().

* genpot.sh 
Remove duplication. Add the ability to specify the genrated pot
file on command-line for debugging purposes.

* po/olive-gtk.pot:
Regenerated.

* __init__.py, branch.py, branchview/treeview.py, checkout.py,
commit.py, conflicts.py, diff.py, errors.py, initialize.py,
merge.py, nautilus-bzr.py, olive/__init__.py, olive/add.py,
olive/bookmark.py, olive/guifiles.py, olive/info.py,
olive/menu.py, olive/mkdir.py, olive/move.py, olive/remove.py,
olive/rename.py, push.py, revbrowser.py, status.py, tags.py:
Replace all calls to _() by calls to _i18n(), the latter being
defined in __init__.py and imported in the other modules from
there. This fix the problem encountered countless times when
running bzr selftest and getting silly error messages about
boolean not being callables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import gtk
23
23
import sys
24
24
 
25
 
from bzrlib import progress
 
25
import bzrlib.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,progress._BaseProgressBar):
44
 
    def __init__(self, _stack=None):
45
 
        gtk.ProgressBar.__init__(self)
 
43
class GtkProgressBar(gtk.ProgressBar):
 
44
    def __init__(self, stack):
 
45
        super(GtkProgressBar, self).__init__()
46
46
        self.set_fraction(0.0)
47
 
        progress._BaseProgressBar.__init__(self, _stack=_stack)
48
 
        self.current = None
49
 
        self.total = None
 
47
        self._stack = stack
 
48
 
 
49
    def finished(self):
 
50
        self._stack.remove(self)
50
51
 
51
52
    def clear(self):
52
 
        self.hide()
 
53
        pass
53
54
 
54
55
    def tick(self):
55
56
        self.pulse()
56
57
 
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:
62
 
            self.current = current_cnt
63
 
        if total_cnt:
64
 
            self.total = total_cnt
 
58
    def update(self, msg=None, current=None, total=None):
65
59
        if msg is not None:
66
60
            self.set_text(msg)
67
 
        if None not in (self.current, self.total):
68
 
            self.fraction = float(self.current) / self.total
69
 
            self.set_fraction(self.fraction)
 
61
        if None not in (current, total):
 
62
            self.set_fraction(1.0 * current / total)
70
63
        while gtk.events_pending():
71
64
            gtk.main_iteration()
72
65
 
73
66
 
74
 
class ProgressBarWindow(gtk.Window):
 
67
class GtkProgressBarStack(gtk.Window):
75
68
    def __init__(self):
76
 
        super(ProgressBarWindow, self).__init__(type=gtk.WINDOW_TOPLEVEL)
 
69
        super(GtkProgressBarStack, self).__init__(type=gtk.WINDOW_TOPLEVEL)
77
70
        self.set_border_width(0)
78
71
        self.set_title("Progress")
79
72
        self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
80
 
        self.pb = GtkProgressBar(self)
81
 
        self.add(self.pb)
82
 
        self.resize(250, 15)
 
73
        self.vbox = gtk.VBox()
 
74
        self.add(self.vbox)
83
75
        self.set_resizable(False)
84
 
        self.show_all()
85
 
 
86
 
    def clear(self):
87
 
        self.pb.clear()
88
 
        self.destroy()
89
 
 
90
 
 
91
 
class ProgressPanel(gtk.HBox):
92
 
    def __init__(self):
93
 
        super(ProgressPanel, self).__init__()
94
 
        image_loading = gtk.image_new_from_stock(gtk.STOCK_REFRESH,
95
 
                                                 gtk.ICON_SIZE_BUTTON)
96
 
        image_loading.show()
97
 
        
98
 
        self.pb = GtkProgressBar(self)
99
 
        self.set_spacing(5)
100
 
        self.set_border_width(5)        
101
 
        self.pack_start(image_loading, False, False)
102
 
        self.pack_start(self.pb, True, True)
103
 
 
104
 
    def return_pb(self, pb):
105
 
        self._stack.return_pb(self)
106
 
 
107
 
    def get_progress_bar(self, to_file=None, show_pct=None, show_spinner=None, show_eta=None, 
108
 
                         show_bar=None, show_count=None, to_messages_file=None, 
109
 
                         _stack=None):
110
 
        self._stack = _stack
111
 
        self.show_all()
112
 
        return self
113
 
    
114
 
    def update(self, *args, **kwargs):
115
 
        self.pb.update(*args, **kwargs)
116
 
 
117
 
    def finished(self):
118
 
        self.pb.finished()
119
 
        self.hide_all()
120
 
 
121
 
    def clear(self):
122
 
        self.pb.clear()
123
 
        self.hide_all()
124
 
 
125
 
    def child_progress(self, *args, **kwargs):
126
 
        return self.pb.child_progress(*args, **kwargs)
127
 
 
128
 
    def child_update(self, *args, **kwargs):
129
 
        return self.pb.child_update(*args, **kwargs)
130
 
 
 
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)
131
89
 
132
90
 
133
91
class PasswordDialog(gtk.Dialog):
162
120
 
163
121
        """
164
122
        super(GtkUIFactory, self).__init__()
165
 
        self.set_nested_progress_bar_widget(ProgressBarWindow)
 
123
        self._progress_bar_stack = None
166
124
 
167
125
    def get_boolean(self, prompt):
168
126
        """GtkDialog with yes/no answers"""
190
148
        else:
191
149
            return None
192
150
 
193
 
    def set_nested_progress_bar_widget(self, widget):
194
 
        self._progress_bar_stack = progress.ProgressBarStack(klass=widget)
195
 
 
196
151
    def nested_progress_bar(self):
197
152
        """Return a nested progress bar.
198
153
        """
 
154
        if self._progress_bar_stack is None:
 
155
            self._progress_bar_stack = GtkProgressBarStack()
199
156
        return self._progress_bar_stack.get_nested()
200
157
 
201
158
    def set_progress_bar_vbox(self, vbox):