22
22
pygtk.require("2.0")
31
28
import bzrlib.errors as errors
29
from dialog import error_dialog
33
31
from launch import launch
36
34
""" This class is responsible for building the context menus. """
37
def __init__(self, gladefile, comm, dialog):
39
37
if sys.platform == 'win32':
40
38
self.uifile = os.path.dirname(sys.executable) + "/share/olive/cmenu.ui"
138
132
filename = self.comm.get_selected_right()
140
134
if filename is None:
141
self.dialog.error_dialog(_('No file was selected'),
142
_('Please select a file from the list,\nor choose the other option.'))
135
error_dialog(_('No file was selected'),
136
_('Please select a file from the list,\nor choose the other option.'))
146
140
bzrlib.add.smart_add([directory + '/' + filename])
147
141
except errors.NotBranchError:
148
self.dialog.error_dialog(_('Directory is not a branch'),
149
_('You can perform this action only in a branch.'))
142
error_dialog(_('Directory is not a branch'),
143
_('You can perform this action only in a branch.'))
152
146
self.comm.refresh_right()
158
152
filename = self.comm.get_selected_right()
160
154
if filename is None:
161
self.dialog.error_dialog(_('No file was selected'),
162
_('Please select a file from the list,\nor choose the other option.'))
155
error_dialog(_('No file was selected'),
156
_('Please select a file from the list,\nor choose the other option.'))
169
163
except errors.NotBranchError:
170
self.dialog.error_dialog(_('Directory is not a branch'),
164
error_dialog(_('Directory is not a branch'),
171
165
_('You can perform this action only in a branch.'))
173
167
except errors.NotVersionedError:
174
self.dialog.error_dialog(_('File not versioned'),
168
error_dialog(_('File not versioned'),
175
169
_('The selected file is not versioned.'))
180
172
self.comm.refresh_right()
185
177
filename = self.comm.get_selected_right()
187
179
if filename is None:
188
self.dialog.error_dialog(_('No file was selected'),
180
error_dialog(_('No file was selected'),
189
181
_('Please select a file from the list,\nor choose the other option.'))
204
196
def commit(self, action):
205
197
""" Right context menu -> Commit """
206
198
from commit import OliveCommit
207
commit = OliveCommit(self.gladefile, self.comm, self.dialog)
199
wt, path = WorkingTree.open_containing(self.comm.get_path())
200
commit = OliveCommit(wt, path)
210
203
def diff(self, action):
211
204
""" Right context menu -> Diff """
212
205
from diff import OliveDiff
213
diff = OliveDiff(self.gladefile, self.comm, self.dialog)
206
diff = OliveDiff(self.comm)
216
209
def bookmark(self, action):
217
210
""" Right context menu -> Bookmark """
218
211
if self.comm.pref.add_bookmark(self.comm.get_path()):
219
self.dialog.info_dialog(_('Bookmark successfully added'),
212
info_dialog(_('Bookmark successfully added'),
220
213
_('The current directory was bookmarked. You can reach\nit by selecting it from the left panel.'))
222
self.dialog.warning_dialog(_('Location already bookmarked'),
215
warning_dialog(_('Location already bookmarked'),
223
216
_('The current directory is already bookmarked.\nSee the left panel for reference.'))
225
218
self.comm.refresh_left()
229
222
from bookmark import OliveBookmark
231
224
if self.comm.get_selected_left() != None:
232
bookmark = OliveBookmark(self.gladefile, self.comm, self.dialog)
225
bookmark = OliveBookmark(self.comm)
233
226
bookmark.display()
235
228
def remove_bookmark(self, action):
253
246
def diff_all(self, action):
254
247
""" Diff toolbutton -> All... """
255
248
from diff import OliveDiff
256
diff = OliveDiff(self.gladefile, self.comm, self.dialog)
249
diff = OliveDiff(self.comm)