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
30
import olive.backend.errors as errors
32
from dialog import OliveDialog
33
from menu import OliveMenu
36
""" Signal handler class for Olive. """
37
def __init__(self, gladefile, comm):
38
self.gladefile = gladefile
41
self.dialog = OliveDialog(self.gladefile)
43
self.menu = OliveMenu(self.gladefile, self.comm, self.dialog)
45
def on_about_activate(self, widget):
48
def on_menuitem_add_files_activate(self, widget):
49
""" Add file(s)... menu handler. """
50
from add import OliveAdd
51
add = OliveAdd(self.gladefile, self.comm, self.dialog)
54
def on_menuitem_branch_get_activate(self, widget):
55
""" Branch/Get... menu handler. """
56
from branch import OliveBranch
57
branch = OliveBranch(self.gladefile, self.comm, self.dialog)
60
def on_menuitem_branch_checkout_activate(self, widget):
61
""" Branch/Checkout... menu handler. """
62
from checkout import OliveCheckout
63
checkout = OliveCheckout(self.gladefile, self.comm, self.dialog)
66
def on_menuitem_branch_commit_activate(self, widget):
67
""" Branch/Commit... menu handler. """
68
from commit import OliveCommit
69
commit = OliveCommit(self.gladefile, self.comm, self.dialog)
72
def on_menuitem_branch_pull_activate(self, widget):
73
""" Branch/Pull menu handler. """
74
import olive.backend.update as update
76
self.comm.set_busy(self.comm.window_main)
79
ret = update.pull(self.comm.get_path())
80
except errors.NotBranchError:
81
self.dialog.error_dialog('Directory is not a branch',
82
'You can perform this action only in a branch.')
83
except errors.NoLocationKnown:
84
self.dialog.error_dialog('Parent location is unknown',
85
'Pulling is not possible until there is no parent location.')
87
self.dialog.info_dialog('Pull successful',
88
'%d revision(s) pulled.' % ret)
90
self.comm.set_busy(self.comm.window_main, False)
92
def on_menuitem_branch_push_activate(self, widget):
93
""" Branch/Push... menu handler. """
94
from push import OlivePush
95
push = OlivePush(self.gladefile, self.comm, self.dialog)
98
def on_menuitem_branch_status_activate(self, widget):
99
""" Branch/Status... menu handler. """
100
from status import OliveStatus
101
status = OliveStatus(self.gladefile, self.comm, self.dialog)
104
def on_menuitem_branch_initialize_activate(self, widget):
105
""" Initialize current directory. """
106
import olive.backend.init as init
109
init.init(self.comm.get_path())
110
except errors.AlreadyBranchError, errmsg:
111
self.dialog.error_dialog('Directory is already a branch',
112
'The current directory (%s) is already a branch.\nYou can start using it, or initialize another directory.' % errmsg)
113
except errors.BranchExistsWithoutWorkingTree, errmsg:
114
self.dialog.error_dialog('Branch without a working tree',
115
'The current directory (%s)\nis a branch without a working tree.' % errmsg)
119
self.dialog.info_dialog('Ininialize successful',
120
'Directory successfully initialized.')
121
self.comm.refresh_right()
123
def on_menuitem_file_make_directory_activate(self, widget):
124
""" File/Make directory... menu handler. """
125
from mkdir import OliveMkdir
126
mkdir = OliveMkdir(self.gladefile, self.comm, self.dialog)
129
def on_menuitem_file_move_activate(self, widget):
130
""" File/Move... menu handler. """
131
from move import OliveMove
132
move = OliveMove(self.gladefile, self.comm, self.dialog)
135
def on_menuitem_file_rename_activate(self, widget):
136
""" File/Rename... menu handler. """
137
from rename import OliveRename
138
rename = OliveRename(self.gladefile, self.comm, self.dialog)
141
def on_menuitem_remove_file_activate(self, widget):
142
""" Remove (unversion) selected file. """
143
from remove import OliveRemove
144
remove = OliveRemove(self.gladefile, self.comm, self.dialog)
147
def on_menuitem_stats_diff_activate(self, widget):
148
""" Statistics/Differences... menu handler. """
149
from diff import OliveDiff
150
diff = OliveDiff(self.gladefile, self.comm, self.dialog)
153
def on_menuitem_stats_infos_activate(self, widget):
154
""" Statistics/Informations... menu handler. """
155
from info import OliveInfo
156
info = OliveInfo(self.gladefile, self.comm, self.dialog)
159
def on_menuitem_stats_log_activate(self, widget):
160
""" Statistics/Log... menu handler. """
161
from log import OliveLog
162
log = OliveLog(self.gladefile, self.comm, self.dialog)
165
def on_treeview_left_button_press_event(self, widget, event):
166
""" Occurs when somebody right-clicks in the bookmark list. """
167
if event.button == 3:
168
self.menu.left_context_menu().popup(None, None, None, 0,
171
def on_treeview_left_row_activated(self, treeview, path, view_column):
172
""" Occurs when somebody double-clicks or enters an item in the
174
self.comm.set_busy(treeview)
176
newdir = self.comm.get_selected_left()
177
self.comm.set_path(newdir)
179
self.comm.refresh_right()
181
self.comm.set_busy(treeview, False)
183
def on_treeview_right_button_press_event(self, widget, event):
184
""" Occurs when somebody right-clicks in the file list. """
185
if event.button == 3:
186
self.menu.right_context_menu().popup(None, None, None, 0,
189
def on_treeview_right_row_activated(self, treeview, path, view_column):
190
""" Occurs when somebody double-clicks or enters an item in the
194
newdir = self.comm.get_selected_right()
197
self.comm.set_path(os.path.split(self.comm.get_path())[0])
199
self.comm.set_path(self.comm.get_path() + '/' + newdir)
201
self.comm.refresh_right()
203
def on_window_main_delete_event(self, widget, event=None):
204
""" Do some stuff before exiting. """
205
width, height = self.comm.window_main.get_size()
206
self.comm.pref.set_preference('window_width', width)
207
self.comm.pref.set_preference('window_height', height)
208
x, y = self.comm.window_main.get_position()
209
self.comm.pref.set_preference('window_x', x)
210
self.comm.pref.set_preference('window_y', y)
211
self.comm.pref.set_preference('paned_position',
212
self.comm.hpaned_main.get_position())
214
self.comm.pref.write()
215
self.comm.window_main.destroy()
217
def not_implemented(self, widget):
218
""" Display a Not implemented error message. """
219
self.dialog.error_dialog('I feel sorry',
220
'This feature is not yet implemented.')