/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 olive/checkout.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2007-02-01 14:41:43 UTC
  • mto: (157.1.2 trunk) (170.1.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 141.
  • Revision ID: szilveszter.farkas@gmail.com-20070201144143-guso1rfcy76ma7a4
Refactored the Push dialog. Add 'gpush' command.

Show diffs side-by-side

added added

removed removed

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