/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to olive/menu.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-09-27 19:10:00 UTC
  • mto: (0.14.1 main)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060927191000-2b5382eda85d82e4
Fixed a context menu bug; set release date.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
except:
29
29
    sys.exit(1)
30
30
 
31
 
import olive.backend.fileops as fileops
32
 
import olive.backend.errors as errors
 
31
import bzrlib.errors as errors
 
32
 
 
33
from launch import launch
33
34
 
34
35
class OliveMenu:
35
36
    """ This class is responsible for building the context menus. """
65
66
                                       _('Remove'), None,
66
67
                                       _('Remove the selected file'),
67
68
                                       self.remove_file),
 
69
                                      ('open', gtk.STOCK_OPEN,
 
70
                                       _('Open'), None,
 
71
                                       _('Open the selected file'),
 
72
                                       self.open_file),
68
73
                                      ('commit', None,
69
74
                                       _('Commit'), None,
70
75
                                       _('Commit the changes'),
77
82
                                       _('Bookmark'), None,
78
83
                                       _('Bookmark current location'),
79
84
                                       self.bookmark),
 
85
                                      ('edit_bookmark', gtk.STOCK_EDIT,
 
86
                                       _('Edit'), None,
 
87
                                       _('Edit the selected bookmark'),
 
88
                                       self.edit_bookmark),
80
89
                                      ('remove_bookmark', gtk.STOCK_REMOVE,
81
90
                                       _('Remove'), None,
82
91
                                       _('Remove the selected bookmark'),
83
92
                                       self.remove_bookmark),
 
93
                                      ('open_folder', gtk.STOCK_OPEN,
 
94
                                       _('Open Folder'), None,
 
95
                                       _('Open bookmark folder in Nautilus'),
 
96
                                       self.open_folder),
84
97
                                      ('diff_selected', None,
85
98
                                       _('Selected...'), None,
86
99
                                       _('Show the differences of the selected file'),
130
143
            return
131
144
        
132
145
        try:
133
 
            fileops.add([directory + '/' + filename])
 
146
            bzrlib.add.smart_add([directory + '/' + filename])
134
147
        except errors.NotBranchError:
135
148
            self.dialog.error_dialog(_('Directory is not a branch'),
136
149
                                     _('You can perform this action only in a branch.'))
137
150
            return
138
 
        except:
139
 
            raise
140
151
        
141
152
        self.comm.refresh_right()
142
153
    
152
163
            return
153
164
        
154
165
        try:
155
 
            fileops.remove([directory + '/' + filename])
 
166
            wt, path = WorkingTree.open_containing(directory+'/'+filename)
 
167
            wt.remove(path)
 
168
 
156
169
        except errors.NotBranchError:
157
170
            self.dialog.error_dialog(_('Directory is not a branch'),
158
171
                                     _('You can perform this action only in a branch.'))
166
179
        
167
180
        self.comm.refresh_right()
168
181
 
 
182
    def open_file(self, action):
 
183
        """ Right context menu -> Open """
 
184
        # Open only the selected file
 
185
        filename = self.comm.get_selected_right()
 
186
        
 
187
        if filename is None:
 
188
            self.dialog.error_dialog(_('No file was selected'),
 
189
                                     _('Please select a file from the list,\nor choose the other option.'))
 
190
            return
 
191
 
 
192
        if filename == '..':
 
193
            self.comm.set_path(os.path.split(self.comm.get_path())[0])
 
194
        else:
 
195
            fullpath = self.comm.get_path() + os.sep + filename
 
196
            if os.path.isdir(fullpath):
 
197
                # selected item is an existant directory
 
198
                self.comm.set_path(fullpath)
 
199
            else:
 
200
                launch(fullpath) 
 
201
        
 
202
        self.comm.refresh_right()
 
203
 
169
204
    def commit(self, action):
170
205
        """ Right context menu -> Commit """
171
206
        from commit import OliveCommit
189
224
        
190
225
        self.comm.refresh_left()
191
226
 
 
227
    def edit_bookmark(self, action):
 
228
        """ Left context menu -> Edit """
 
229
        from bookmark import OliveBookmark
 
230
 
 
231
        if self.comm.get_selected_left() != None:
 
232
            bookmark = OliveBookmark(self.gladefile, self.comm, self.dialog)
 
233
            bookmark.display()
 
234
 
192
235
    def remove_bookmark(self, action):
193
236
        """ Left context menu -> Remove """
194
 
        self.comm.pref.remove_bookmark(self.comm.get_selected_left())
195
237
        
196
 
        self.comm.refresh_left()
 
238
        if self.comm.get_selected_left() != None:
 
239
            self.comm.pref.remove_bookmark(self.comm.get_selected_left())
 
240
            self.comm.refresh_left()
 
241
    
 
242
    def open_folder(self, action):
 
243
        """ Left context menu -> Open Folder """
 
244
        path = self.comm.get_selected_left()
 
245
 
 
246
        if path != None:
 
247
            launch(path)
197
248
    
198
249
    def diff_selected(self, action):
199
250
        """ Diff toolbutton -> Selected... """