31
31
import olive.backend.fileops as fileops
32
32
import olive.backend.errors as errors
34
from commit import OliveCommit
35
from diff import OliveDiff
38
35
""" This class is responsible for building the context menus. """
39
36
def __init__(self, gladefile, comm, dialog):
87
84
self.cmenu_right = self.ui.get_widget('/context_right')
89
86
self.cmenu_left = self.ui.get_widget('/context_left')
89
commit_menu = self.ui.get_widget('/context_right/commit')
90
commit_image = self.comm.menuitem_branch_commit.get_image()
91
commit_pixbuf = commit_image.get_pixbuf()
92
commit_icon = gtk.Image()
93
commit_icon.set_from_pixbuf(commit_pixbuf)
94
commit_menu.set_image(commit_icon)
95
diff_menu = self.ui.get_widget('/context_right/diff')
96
diff_image = self.comm.menuitem_stats_diff.get_image()
97
diff_pixbuf = diff_image.get_pixbuf()
98
diff_icon = gtk.Image()
99
diff_icon.set_from_pixbuf(diff_pixbuf)
100
diff_menu.set_image(diff_icon)
101
log_menu = self.ui.get_widget('/context_right/log')
102
log_image = self.comm.menuitem_stats_log.get_image()
103
log_pixbuf = log_image.get_pixbuf()
104
log_icon = gtk.Image()
105
log_icon.set_from_pixbuf(log_pixbuf)
106
log_menu.set_image(log_icon)
91
108
def right_context_menu(self):
92
109
return self.cmenu_right
101
118
filename = self.comm.get_selected_right()
103
120
if filename is None:
104
self.dialog.error_dialog('No file was selected.')
121
self.dialog.error_dialog('No file was selected',
122
'Please select a file from the list,\nor choose the other option.')
108
126
fileops.add([directory + '/' + filename])
109
127
except errors.NotBranchError:
110
self.dialog.error_dialog('The directory is not a branch.')
128
self.dialog.error_dialog('Directory is not a branch',
129
'You can perform this action only in a branch.')
121
140
filename = self.comm.get_selected_right()
123
142
if filename is None:
124
self.dialog.error_dialog('No file was selected.')
143
self.dialog.error_dialog('No file was selected',
144
'Please select a file from the list,\nor choose the other option.')
128
148
fileops.remove([directory + '/' + filename])
129
149
except errors.NotBranchError:
130
self.dialog.error_dialog('The directory is not a branch.')
150
self.dialog.error_dialog('Directory is not a branch',
151
'You can perform this action only in a branch.')
132
153
except errors.NotVersionedError:
133
self.dialog.error_dialog('Selected file is not versioned.')
154
self.dialog.error_dialog('File not versioned',
155
'The selected file is not versioned.')
140
162
def commit(self, action):
141
163
""" Right context menu -> Commit """
142
commit = OliveCommit(self.gladefile, self.comm)
164
from commit import OliveCommit
165
commit = OliveCommit(self.gladefile, self.comm, self.dialog)
145
168
def diff(self, action):
146
169
""" Right context menu -> Diff """
147
diff = OliveDiff(self.gladefile, self.comm)
170
from diff import OliveDiff
171
diff = OliveDiff(self.gladefile, self.comm, self.dialog)
150
174
def log(self, action):
151
175
""" Right context menu -> Log """
152
self.dialog.error_dialog('This feature is not yet implemented.')
176
from log import OliveLog
177
log = OliveLog(self.gladefile, self.comm, self.dialog)
154
180
def bookmark(self, action):
155
181
""" Right context menu -> Bookmark """
156
182
if self.comm.pref.add_bookmark(self.comm.get_path()):
157
self.dialog.info_dialog('Bookmark successfully added.')
183
self.dialog.info_dialog('Bookmark successfully added',
184
'The current directory was bookmarked. You can reach\nit by selecting it from the left panel.')
159
self.dialog.warning_dialog('Location already bookmarked.')
186
self.dialog.warning_dialog('Location already bookmarked'
187
'The current directory is already bookmarked.\nSee the left panel for reference.')
161
189
self.comm.refresh_left()