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