27
from olive import delimiter
28
27
from errors import show_bzr_error
30
29
from bzrlib.branch import Branch
31
30
from bzrlib.config import GlobalConfig
33
from olive.dialog import error_dialog
32
from dialog import error_dialog
34
from history import UrlHistory
35
from olive import Preferences
36
37
class CheckoutDialog(gtk.Dialog):
37
38
""" New implementation of the Checkout dialog. """
38
def __init__(self, path=None, parent=None):
39
def __init__(self, path=None, parent=None, remote_path=None):
39
40
""" Initialize the Checkout dialog. """
40
41
gtk.Dialog.__init__(self, title="Checkout - Olive",
65
66
self._button_checkout.connect('clicked', self._on_checkout_clicked)
66
67
self._button_revision.connect('clicked', self._on_revision_clicked)
67
self._combo.connect('changed', self._on_combo_changed)
68
self._combo.child.connect('focus-out-event', self._on_combo_changed)
69
70
# Create the table and pack the widgets into it
70
71
self._table = gtk.Table(rows=3, columns=2)
92
93
self.vbox.set_spacing(3)
93
94
if self.path is not None:
94
95
self._filechooser.set_filename(self.path)
96
if remote_path is not None:
97
self._combo.child.set_text(remote_path)
96
99
# Pack some widgets
97
100
self._hbox_revision.pack_start(self._entry_revision, True, True)
103
106
self.vbox.show_all()
105
108
# Build checkout history
109
self._history = UrlHistory(GlobalConfig(), 'branch_history')
106
110
self._build_history()
108
112
def _build_history(self):
109
113
""" 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)
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')
124
config.set_user_option('gcheckout_history', location)
126
h = history.split(delimiter)
127
if location not in h:
129
config.set_user_option('gcheckout_history', delimiter.join(h))
114
self._combo_model = gtk.ListStore(str)
116
for item in self._history.get_entries():
117
self._combo_model.append([ item ])
120
for item in pref.get_bookmarks():
121
self._combo_model.append([ item ])
123
self._combo.set_model(self._combo_model)
124
self._combo.set_text_column(0)
131
126
def _get_last_revno(self):
132
127
""" Get the revno of the last revision (if any). """
190
185
br_from.create_checkout(to_location, revision_id, lightweight)
192
self._add_to_history(location)
187
self._history.add_entry(location)
194
189
self.response(gtk.RESPONSE_OK)
196
def _on_combo_changed(self, widget):
191
def _on_combo_changed(self, widget, event):
197
192
""" We try to get the last revision if focus lost. """
198
193
rev = self._get_last_revno()