bzr branch
http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
0.8.26
by Szilveszter Farkas (Phanatic)
Implemented Diff window; added menu.py (was missing from last commit) |
1 |
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
|
2 |
||
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.
|
|
7 |
||
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.
|
|
12 |
||
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
|
|
16 |
||
17 |
import os.path |
|
18 |
import sys |
|
19 |
||
20 |
try: |
|
21 |
import pygtk |
|
22 |
pygtk.require("2.0") |
|
23 |
except: |
|
24 |
pass
|
|
25 |
try: |
|
26 |
import gtk |
|
27 |
import gtk.glade |
|
28 |
except: |
|
29 |
sys.exit(1) |
|
30 |
||
31 |
import olive.backend.fileops as fileops |
|
32 |
import olive.backend.errors as errors |
|
33 |
||
34 |
from commit import OliveCommit |
|
35 |
from diff import OliveDiff |
|
36 |
||
37 |
class OliveMenu: |
|
38 |
""" This class is responsible for building the context menus. """ |
|
39 |
def __init__(self, gladefile, comm, dialog): |
|
40 |
# Load the UI file
|
|
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" |
|
45 |
||
46 |
self.gladefile = gladefile |
|
47 |
self.comm = comm |
|
48 |
self.dialog = dialog |
|
49 |
||
50 |
self.ui_right = gtk.UIManager() |
|
51 |
||
52 |
self.actiongroup_right = gtk.ActionGroup('context_right') |
|
53 |
self.actiongroup_right.add_actions([('add', gtk.STOCK_ADD, |
|
54 |
'Add', None, |
|
55 |
'Add the selected file', |
|
56 |
self.add_file), |
|
57 |
('remove', gtk.STOCK_REMOVE, |
|
58 |
'Remove', None, |
|
59 |
'Remove the selected file', |
|
60 |
self.remove_file), |
|
61 |
('commit', gtk.STOCK_REDO, |
|
62 |
'Commit', None, |
|
63 |
'Commit the changes', |
|
64 |
self.commit), |
|
65 |
('diff', None, |
|
66 |
'Diff', None, |
|
67 |
'Show the diff of the file', |
|
68 |
self.diff), |
|
69 |
('log', None, |
|
70 |
'Log', None, |
|
71 |
'Show the log of the file', |
|
72 |
self.log)]) |
|
73 |
||
74 |
self.ui_right.insert_action_group(self.actiongroup_right, 0) |
|
75 |
self.ui_right.add_ui_from_file(self.uifile) |
|
76 |
||
77 |
self.cmenu_right = self.ui_right.get_widget('/context_right') |
|
78 |
||
79 |
def right_context_menu(self): |
|
80 |
return self.cmenu_right |
|
81 |
||
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() |
|
87 |
||
88 |
if filename is None: |
|
89 |
self.dialog.error_dialog('No file was selected.') |
|
90 |
return
|
|
91 |
||
92 |
try: |
|
93 |
fileops.add([directory + '/' + filename]) |
|
94 |
except errors.NotBranchError: |
|
95 |
self.dialog.error_dialog('The directory is not a branch.') |
|
96 |
return
|
|
97 |
except: |
|
98 |
raise
|
|
99 |
||
100 |
self.comm.refresh_right() |
|
101 |
||
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() |
|
107 |
||
108 |
if filename is None: |
|
109 |
self.dialog.error_dialog('No file was selected.') |
|
110 |
return
|
|
111 |
||
112 |
try: |
|
113 |
fileops.remove([directory + '/' + filename]) |
|
114 |
except errors.NotBranchError: |
|
115 |
self.dialog.error_dialog('The directory is not a branch.') |
|
116 |
return
|
|
117 |
except errors.NotVersionedError: |
|
118 |
self.dialog.error_dialog('Selected file is not versioned.') |
|
119 |
return
|
|
120 |
except: |
|
121 |
raise
|
|
122 |
||
123 |
self.comm.refresh_right() |
|
124 |
||
125 |
def commit(self, action): |
|
126 |
""" Right context menu -> Commit """ |
|
127 |
commit = OliveCommit(self.gladefile, self.comm) |
|
128 |
commit.display() |
|
129 |
||
130 |
def diff(self, action): |
|
131 |
""" Right context menu -> Diff """ |
|
132 |
diff = OliveDiff(self.gladefile, self.comm) |
|
133 |
diff.display() |
|
134 |
||
135 |
def log(self, action): |
|
136 |
""" Right context menu -> Log """ |
|
137 |
self.dialog.error_dialog('This feature is not yet implemented.') |