1
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31
import olive.backend.fileops as fileops
32
import olive.backend.errors as errors
34
from commit import OliveCommit
35
from diff import OliveDiff
38
""" This class is responsible for building the context menus. """
39
def __init__(self, gladefile, comm, dialog):
41
self.uifile = "/usr/share/olive/cmenu.ui"
42
if not os.path.exists(self.uifile):
43
# Load from current directory if not installed
44
self.uifile = "cmenu.ui"
46
self.gladefile = gladefile
50
self.ui_right = gtk.UIManager()
52
self.actiongroup_right = gtk.ActionGroup('context_right')
53
self.actiongroup_right.add_actions([('add', gtk.STOCK_ADD,
55
'Add the selected file',
57
('remove', gtk.STOCK_REMOVE,
59
'Remove the selected file',
61
('commit', gtk.STOCK_REDO,
67
'Show the diff of the file',
71
'Show the log of the file',
74
self.ui_right.insert_action_group(self.actiongroup_right, 0)
75
self.ui_right.add_ui_from_file(self.uifile)
77
self.cmenu_right = self.ui_right.get_widget('/context_right')
79
def right_context_menu(self):
80
return self.cmenu_right
82
def add_file(self, action):
83
""" Right context menu -> Add """
84
# Add only the selected file
85
directory = self.comm.get_path()
86
filename = self.comm.get_selected_right()
89
self.dialog.error_dialog('No file was selected.')
93
fileops.add([directory + '/' + filename])
94
except errors.NotBranchError:
95
self.dialog.error_dialog('The directory is not a branch.')
100
self.comm.refresh_right()
102
def remove_file(self, action):
103
""" Right context menu -> Remove """
104
# Remove only the selected file
105
directory = self.comm.get_path()
106
filename = self.comm.get_selected_right()
109
self.dialog.error_dialog('No file was selected.')
113
fileops.remove([directory + '/' + filename])
114
except errors.NotBranchError:
115
self.dialog.error_dialog('The directory is not a branch.')
117
except errors.NotVersionedError:
118
self.dialog.error_dialog('Selected file is not versioned.')
123
self.comm.refresh_right()
125
def commit(self, action):
126
""" Right context menu -> Commit """
127
commit = OliveCommit(self.gladefile, self.comm)
130
def diff(self, action):
131
""" Right context menu -> Diff """
132
diff = OliveDiff(self.gladefile, self.comm)
135
def log(self, action):
136
""" Right context menu -> Log """
137
self.dialog.error_dialog('This feature is not yet implemented.')