/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: Jelmer Vernooij
  • Date: 2008-10-28 16:02:01 UTC
  • Revision ID: jelmer@samba.org-20081028160201-5t1bznxbbgoqj5or
Add notifications tab in preferences dialog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
from bzrlib.plugins.gtk.annotate.gannotate import GAnnotateWindow
37
37
from bzrlib.plugins.gtk.annotate.config import GAnnotateConfig
38
38
from bzrlib.plugins.gtk.diff import DiffWindow
39
 
from launch import launch
40
 
from bzrlib.plugins.gtk.olive import Preferences
 
39
from bzrlib.plugins.gtk.olive import Preferences, launch
41
40
 
42
41
class OliveMenu:
43
42
    """ This class is responsible for building the context menus. """
179
178
                         _i18n('Please select a file from the list,\nor choose the other option.'))
180
179
            return
181
180
        
182
 
        bzrlib.add.smart_add([os.path.join(directory, filename)])
 
181
        wt, path = WorkingTree.open_containing(os.path.join(directory, filename))
 
182
        wt.add([path])
 
183
        
 
184
        self.app.refresh_right()
183
185
    
184
186
    @show_bzr_error
185
187
    def annotate(self, action):
196
198
        
197
199
        branch = wt.branch
198
200
        file_id = wt.path2id(wt.relpath(os.path.join(directory, filename)))
199
 
        
 
201
        if file_id is None:
 
202
            raise errors.NotVersionedError(filename)
200
203
        window = GAnnotateWindow(all=False, plain=False, parent=self.app)
201
204
        window.set_title(os.path.join(directory, filename) + " - Annotate")
202
205
        config = GAnnotateConfig(window)
208
211
            branch.unlock()
209
212
    
210
213
    @show_bzr_error
211
 
    def remove_file(self, action,delete_on_disk=0):
 
214
    def remove_file(self, action, delete_on_disk=False):
212
215
        """ Right context menu -> Remove """
213
216
        # Remove only the selected file
214
217
        directory = self.path
236
239
        
237
240
    def remove_and_delete_file(self, action):
238
241
        """ Right context menu -> Remove and delete"""
239
 
        self.remove_file(action,delete_on_disk=1)
 
242
        self.remove_file(action, delete_on_disk=True)
240
243
 
241
244
    def rename_file(self, action):
242
245
        """ Right context menu -> Rename """
243
 
        from rename import OliveRename
244
 
        wt = WorkingTree.open_containing(self.path + os.sep + self.selected)[0]
245
 
        rename = OliveRename(wt, wt.relpath(self.path), self.selected)
246
 
        rename.display()
 
246
        from bzrlib.plugins.gtk.olive.rename import RenameDialog
 
247
        wt = WorkingTree.open_containing(os.path.join(self.path, self.selected))[0]
 
248
        rename = RenameDialog(wt, wt.relpath(self.path), self.selected)
 
249
        response = rename.run()
 
250
        rename.destroy()
 
251
        if response == gtk.RESPONSE_OK:
 
252
            self.app.refresh_right()
247
253
    
248
254
    def open_file(self, action):
249
255
        """ Right context menu -> Open """
259
265
            # TODO: how to enter a directory?
260
266
            return
261
267
        else:
262
 
            fullpath = self.path + os.sep + filename
263
 
            if os.path.isdir(fullpath):
264
 
                # selected item is an existant directory
265
 
                # TODO: how to enter a directory?
266
 
                return
267
 
            else:
268
 
                launch(fullpath) 
 
268
            fullpath = os.path.join(self.path, filename)
 
269
            launch.launch(fullpath) 
269
270
 
270
271
    def revert(self, action):
271
272
        """ Right context menu -> Revert """
276
277
                           _i18n('Please have a look at the working tree before continuing.'))
277
278
        else:
278
279
            info_dialog(_i18n('Revert successful'),
279
 
                        _i18n('All files reverted to last revision.'))
 
280
                        _i18n('Selected file reverted to last revision.'))
280
281
        self.app.refresh_right()       
281
282
    
282
283
    def commit(self, action):
355
356
        path = self.selected
356
357
 
357
358
        if path != None:
358
 
            launch(path)
 
359
            launch.launch(path)
359
360
    
360
361
    def diff_selected(self, action):
361
362
        """ Diff toolbutton -> Selected... """
363
364
    
364
365
    def diff_all(self, action):
365
366
        """ Diff toolbutton -> All... """
366
 
        from diff import OliveDiff
367
 
        diff = OliveDiff(self.comm)
368
 
        diff.display()
 
367
        wt = WorkingTree.open_containing(self.path)[0]
 
368
        window = DiffWindow(self.app)
 
369
        parent_tree = wt.branch.repository.revision_tree(wt.branch.last_revision())
 
370
        window.set_diff(wt.branch.nick, wt, parent_tree)
 
371
        window.show()
369
372
    
370
373
    def view_remote(self, action):
371
374
        """ Remote context menu -> View contents """