/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 checkout.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:
24
24
 
25
25
import gtk
26
26
 
27
 
from olive import delimiter
 
27
from bzrlib.plugins.gtk import _i18n
28
28
from errors import show_bzr_error
29
29
 
30
30
from bzrlib.branch import Branch
31
31
from bzrlib.config import GlobalConfig
32
32
 
33
 
from olive.dialog import error_dialog
 
33
from dialog import error_dialog
34
34
 
 
35
from history import UrlHistory
 
36
from olive import Preferences
35
37
 
36
38
class CheckoutDialog(gtk.Dialog):
37
39
    """ New implementation of the Checkout dialog. """
38
 
    def __init__(self, path=None, parent=None):
 
40
    def __init__(self, path=None, parent=None, remote_path=None):
39
41
        """ Initialize the Checkout dialog. """
40
42
        gtk.Dialog.__init__(self, title="Checkout - Olive",
41
43
                                  parent=parent,
46
48
        self.path = path
47
49
        
48
50
        # Create the widgets
49
 
        self._button_checkout = gtk.Button(_("Check_out"), use_underline=True)
 
51
        self._button_checkout = gtk.Button(_i18n("Check_out"), use_underline=True)
50
52
        self._button_revision = gtk.Button('')
51
53
        self._image_browse = gtk.Image()
52
 
        self._filechooser = gtk.FileChooserButton(_("Please select a folder"))
 
54
        self._filechooser = gtk.FileChooserButton(_i18n("Please select a folder"))
53
55
        self._combo = gtk.ComboBoxEntry()
54
 
        self._label_location = gtk.Label(_("Branch location:"))
55
 
        self._label_destination = gtk.Label(_("Destination:"))
56
 
        self._label_nick = gtk.Label(_("Branck nick:"))
57
 
        self._label_revision = gtk.Label(_("Revision:"))
 
56
        self._label_location = gtk.Label(_i18n("Branch location:"))
 
57
        self._label_destination = gtk.Label(_i18n("Destination:"))
 
58
        self._label_nick = gtk.Label(_i18n("Branck nick:"))
 
59
        self._label_revision = gtk.Label(_i18n("Revision:"))
58
60
        self._hbox_revision = gtk.HBox()
59
61
        self._entry_revision = gtk.Entry()
60
62
        self._entry_nick = gtk.Entry()
61
 
        self._check_lightweight = gtk.CheckButton(_("_Lightweight checkout"),
 
63
        self._check_lightweight = gtk.CheckButton(_i18n("_Lightweight checkout"),
62
64
                                                  use_underline=True)
63
65
        
64
66
        # Set callbacks
65
67
        self._button_checkout.connect('clicked', self._on_checkout_clicked)
66
68
        self._button_revision.connect('clicked', self._on_revision_clicked)
67
 
        self._combo.connect('changed', self._on_combo_changed)
 
69
        self._combo.child.connect('focus-out-event', self._on_combo_changed)
68
70
        
69
71
        # Create the table and pack the widgets into it
70
72
        self._table = gtk.Table(rows=3, columns=2)
92
94
        self.vbox.set_spacing(3)
93
95
        if self.path is not None:
94
96
            self._filechooser.set_filename(self.path)
 
97
        if remote_path is not None:
 
98
            self._combo.child.set_text(remote_path)
95
99
        
96
100
        # Pack some widgets
97
101
        self._hbox_revision.pack_start(self._entry_revision, True, True)
103
107
        self.vbox.show_all()
104
108
        
105
109
        # Build checkout history
 
110
        self._history = UrlHistory(GlobalConfig(), 'branch_history')
106
111
        self._build_history()
107
112
    
108
113
    def _build_history(self):
109
114
        """ Build up the checkout history. """
110
 
        config = GlobalConfig()
111
 
        history = config.get_user_option('gcheckout_history')
112
 
        if history is not None:
113
 
            self._combo_model = gtk.ListStore(str)
114
 
            for item in history.split(delimiter):
115
 
                self._combo_model.append([ item ])
116
 
            self._combo.set_model(self._combo_model)
117
 
            self._combo.set_text_column(0)
118
 
    
119
 
    def _add_to_history(self, location):
120
 
        """ Add specified location to the history (if not yet added). """
121
 
        config = GlobalConfig()
122
 
        history = config.get_user_option('gcheckout_history')
123
 
        if history is None:
124
 
            config.set_user_option('gcheckout_history', location)
125
 
        else:
126
 
            h = history.split(delimiter)
127
 
            if location not in h:
128
 
                h.append(location)
129
 
            config.set_user_option('gcheckout_history', delimiter.join(h))                
 
115
        self._combo_model = gtk.ListStore(str)
 
116
        
 
117
        for item in self._history.get_entries():
 
118
            self._combo_model.append([ item ])
 
119
        
 
120
        pref = Preferences()
 
121
        for item in pref.get_bookmarks():
 
122
            self._combo_model.append([ item ])
 
123
        
 
124
        self._combo.set_model(self._combo_model)
 
125
        self._combo.set_text_column(0)
130
126
    
131
127
    def _get_last_revno(self):
132
128
        """ Get the revno of the last revision (if any). """
165
161
        """ Checkout button clicked handler. """
166
162
        location = self._combo.get_child().get_text()
167
163
        if location is '':
168
 
            error_dialog(_('Missing branch location'),
169
 
                         _('You must specify a branch location.'))
 
164
            error_dialog(_i18n('Missing branch location'),
 
165
                         _i18n('You must specify a branch location.'))
170
166
            return
171
167
        
172
168
        destination = self._filechooser.get_filename()
189
185
        
190
186
        br_from.create_checkout(to_location, revision_id, lightweight)
191
187
        
192
 
        self._add_to_history(location)
 
188
        self._history.add_entry(location)
193
189
        
194
190
        self.response(gtk.RESPONSE_OK)
195
191
    
196
 
    def _on_combo_changed(self, widget):
 
192
    def _on_combo_changed(self, widget, event):
197
193
        """ We try to get the last revision if focus lost. """
198
194
        rev = self._get_last_revno()
199
195
        if rev is None:
200
 
            self._entry_revision.set_text(_('N/A'))
 
196
            self._entry_revision.set_text(_i18n('N/A'))
201
197
            self._button_revision.set_sensitive(False)
202
198
        else:
203
199
            self._entry_revision.set_text(str(rev))