/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: Martin Pool
  • Date: 2010-03-25 06:33:53 UTC
  • Revision ID: mbp@canonical.com-20100325063353-ptzq652kpbwxj1w4
Works with bzr 2.2

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. """
181
180
        
182
181
        wt, path = WorkingTree.open_containing(os.path.join(directory, filename))
183
182
        wt.add([path])
 
183
        
 
184
        self.app.refresh_right()
184
185
    
185
186
    @show_bzr_error
186
187
    def annotate(self, action):
197
198
        
198
199
        branch = wt.branch
199
200
        file_id = wt.path2id(wt.relpath(os.path.join(directory, filename)))
200
 
        
 
201
        if file_id is None:
 
202
            raise errors.NotVersionedError(filename)
201
203
        window = GAnnotateWindow(all=False, plain=False, parent=self.app)
202
204
        window.set_title(os.path.join(directory, filename) + " - Annotate")
203
205
        config = GAnnotateConfig(window)
209
211
            branch.unlock()
210
212
    
211
213
    @show_bzr_error
212
 
    def remove_file(self, action,delete_on_disk=0):
 
214
    def remove_file(self, action, delete_on_disk=False):
213
215
        """ Right context menu -> Remove """
214
216
        # Remove only the selected file
215
217
        directory = self.path
237
239
        
238
240
    def remove_and_delete_file(self, action):
239
241
        """ Right context menu -> Remove and delete"""
240
 
        self.remove_file(action,delete_on_disk=1)
 
242
        self.remove_file(action, delete_on_disk=True)
241
243
 
242
244
    def rename_file(self, action):
243
245
        """ Right context menu -> Rename """
244
 
        from rename import OliveRename
245
 
        wt = WorkingTree.open_containing(self.path + os.sep + self.selected)[0]
246
 
        rename = OliveRename(wt, wt.relpath(self.path), self.selected)
247
 
        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()
248
253
    
249
254
    def open_file(self, action):
250
255
        """ Right context menu -> Open """
260
265
            # TODO: how to enter a directory?
261
266
            return
262
267
        else:
263
 
            fullpath = self.path + os.sep + filename
264
 
            if os.path.isdir(fullpath):
265
 
                # selected item is an existant directory
266
 
                # TODO: how to enter a directory?
267
 
                return
268
 
            else:
269
 
                launch(fullpath) 
 
268
            fullpath = os.path.join(self.path, filename)
 
269
            launch.launch(fullpath) 
270
270
 
271
271
    def revert(self, action):
272
272
        """ Right context menu -> Revert """
277
277
                           _i18n('Please have a look at the working tree before continuing.'))
278
278
        else:
279
279
            info_dialog(_i18n('Revert successful'),
280
 
                        _i18n('All files reverted to last revision.'))
 
280
                        _i18n('Selected file reverted to last revision.'))
281
281
        self.app.refresh_right()       
282
282
    
283
283
    def commit(self, action):
284
284
        """ Right context menu -> Commit """
285
 
        from commit import CommitDialog
 
285
        from bzrlib.plugins.gtk.commit import CommitDialog
286
286
        branch = None
287
287
        try:
288
288
            wt, path = WorkingTree.open_containing(self.path)
310
310
        wt = WorkingTree.open_containing(self.path)[0]
311
311
        window = DiffWindow(self.app)
312
312
        parent_tree = wt.branch.repository.revision_tree(wt.branch.last_revision())
313
 
        window.set_diff(wt.branch.nick, wt, parent_tree)
 
313
        window.set_diff(wt.branch._get_nick(local=True), wt, parent_tree)
314
314
        window.set_file(wt.relpath(self.path + os.sep + self.selected))
315
315
        window.show()
316
316
    
356
356
        path = self.selected
357
357
 
358
358
        if path != None:
359
 
            launch(path)
 
359
            launch.launch(path)
360
360
    
361
361
    def diff_selected(self, action):
362
362
        """ Diff toolbutton -> Selected... """
364
364
    
365
365
    def diff_all(self, action):
366
366
        """ Diff toolbutton -> All... """
367
 
        from diff import OliveDiff
368
 
        diff = OliveDiff(self.comm)
369
 
        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._get_nick(local=True), wt, parent_tree)
 
371
        window.show()
370
372
    
371
373
    def view_remote(self, action):
372
374
        """ Remote context menu -> View contents """