/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: Mateusz Korniak
  • Date: 2007-07-21 13:16:33 UTC
  • mto: This revision was merged to the branch mainline in revision 248.
  • Revision ID: matkor@laptop-hp-20070721131633-t40kxs20j1q2fvvc
Context menu "Remove and delete added"
Acts like "Remove" but also deletes file locally.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
 
17
import os
17
18
import os.path
 
19
import shutil
18
20
import sys
19
21
 
20
22
try:
24
26
    pass
25
27
 
26
28
import gtk
 
29
from dialog import question_dialog
27
30
 
28
31
import bzrlib.errors as errors
29
32
from bzrlib.workingtree import WorkingTree
64
67
                                       _('Remove'), None,
65
68
                                       _('Remove the selected file'),
66
69
                                       self.remove_file),
 
70
                                      ('remove_and_delete', gtk.STOCK_REMOVE,
 
71
                                       _('Remove and delete'), None,
 
72
                                       _('Remove the selected file/dir and delete from disk'),
 
73
                                       self.remove_and_delete_file),
67
74
                                      ('rename', None,
68
75
                                       _('Rename'), None,
69
76
                                       _('Rename the selected file'),
201
208
            branch.unlock()
202
209
    
203
210
    @show_bzr_error
204
 
    def remove_file(self, action):
 
211
    def remove_file(self, action,delete_on_disk=0):
205
212
        """ Right context menu -> Remove """
206
213
        # Remove only the selected file
207
214
        directory = self.path
214
221
        
215
222
        wt, path = WorkingTree.open_containing(os.path.join(directory, filename))
216
223
        wt.remove(path)
 
224
        
 
225
        if delete_on_disk:
 
226
            abs_filename = os.path.join(directory,filename)
 
227
            if os.path.isdir(abs_filename):
 
228
                response = question_dialog(_('Delete directory with all directories below ?'), abs_filename )
 
229
                if response == gtk.RESPONSE_YES:
 
230
                    shutil.rmtree(abs_filename)
 
231
            else:
 
232
                os.remove(abs_filename)
 
233
                
217
234
        self.app.set_path(self.path)
218
235
        self.app.refresh_right()
 
236
        
 
237
    def remove_and_delete_file(self, action):
 
238
        """ Right context menu -> Remove and delete"""
 
239
        self.remove_file(action,delete_on_disk=1)
219
240
 
220
241
    def rename_file(self, action):
221
242
        """ Right context menu -> Rename """