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
32
31
import bzrlib.errors as errors
34
from olive.dialog import error_dialog, info_dialog
33
from dialog import error_dialog, info_dialog
35
from history import UrlHistory
36
from olive import Preferences
37
38
class BranchDialog(gtk.Dialog):
38
39
""" New implementation of the Branch dialog. """
39
def __init__(self, path=None, parent=None):
41
def __init__(self, path=None, parent=None, remote_path=None):
40
42
""" Initialize the Branch dialog. """
41
43
gtk.Dialog.__init__(self, title="Branch - Olive",
64
66
self._button_branch.connect('clicked', self._on_branch_clicked)
65
67
self._button_revision.connect('clicked', self._on_revision_clicked)
66
self._combo.connect('changed', self._on_combo_changed)
68
self._combo.child.connect('focus-out-event', self._on_combo_changed)
68
70
# Create the table and pack the widgets into it
69
71
self._table = gtk.Table(rows=3, columns=2)
90
92
self.vbox.set_spacing(3)
91
93
if self.path is not None:
92
94
self._filechooser.set_filename(self.path)
95
if remote_path is not None:
96
self._combo.child.set_text(remote_path)
94
98
# Pack some widgets
95
99
self._hbox_revision.pack_start(self._entry_revision, True, True)
101
105
self.vbox.show_all()
103
107
# Build branch history
108
self._history = UrlHistory(GlobalConfig(), 'branch_history')
104
109
self._build_history()
106
111
def _build_history(self):
107
112
""" Build up the branch history. """
108
config = GlobalConfig()
109
history = config.get_user_option('gbranch_history')
110
if history is not None:
111
self._combo_model = gtk.ListStore(str)
112
for item in history.split(delimiter):
113
self._combo_model.append([ item ])
114
self._combo.set_model(self._combo_model)
115
self._combo.set_text_column(0)
117
def _add_to_history(self, location):
118
""" Add specified location to the history (if not yet added). """
119
config = GlobalConfig()
120
history = config.get_user_option('gbranch_history')
122
config.set_user_option('gbranch_history', location)
124
h = history.split(delimiter)
125
if location not in h:
127
config.set_user_option('gbranch_history', delimiter.join(h))
113
self._combo_model = gtk.ListStore(str)
115
for item in self._history.get_entries():
116
self._combo_model.append([ item ])
119
for item in pref.get_bookmarks():
120
self._combo_model.append([ item ])
122
self._combo.set_model(self._combo_model)
123
self._combo.set_text_column(0)
129
125
def _get_last_revno(self):
130
126
""" Get the revno of the last revision (if any). """
208
self._add_to_history(location)
204
self._history.add_entry(location)
209
205
info_dialog(_('Branching successful'),
210
206
_('%d revision(s) branched.') % revs)
212
208
self.response(gtk.RESPONSE_OK)
214
def _on_combo_changed(self, widget):
210
def _on_combo_changed(self, widget, event):
215
211
""" We try to get the last revision if focus lost. """
216
212
rev = self._get_last_revno()