/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-06-27 16:55:09 UTC
  • mto: This revision was merged to the branch mainline in revision 506.
  • Revision ID: jelmer@samba.org-20080627165509-7b68w2chzvvgc8vz
Use helper script to open patches.

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