/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/remove.py

  • Committer: Jelmer Vernooij
  • Date: 2006-09-27 18:08:35 UTC
  • mto: (0.12.2 olive)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060927180835-4c295d9bb936623a
Turn some windows into dialogs.
Remove the diffwindow code from olive, 
switched to using the one from bzr-gtk instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
except:
28
28
    sys.exit(1)
29
29
 
30
 
import olive.backend.errors as errors
31
 
import olive.backend.fileops as fileops
 
30
import bzrlib.errors as errors
 
31
from bzrlib.workingtree import WorkingTree
32
32
 
33
33
class OliveRemove:
34
34
    """ Display the Remove file(s) dialog and perform the needed actions. """
35
 
    def __init__(self, gladefile, comm, dialog):
 
35
    def __init__(self, gladefile, comm):
36
36
        """ Initialize the Remove file(s) dialog. """
37
37
        self.gladefile = gladefile
38
38
        self.glade = gtk.glade.XML(self.gladefile, 'window_remove')
39
39
        
40
40
        # Communication object
41
41
        self.comm = comm
42
 
        # Dialog object
43
 
        self.dialog = dialog
44
42
        
45
43
        self.window = self.glade.get_widget('window_remove')
46
44
        
67
65
            filename = self.comm.get_selected_right()
68
66
            
69
67
            if filename is None:
70
 
                self.dialog.error_dialog(_('No file was selected'),
 
68
                error_dialog(_('No file was selected'),
71
69
                                         _('Please select a file from the list,\nor choose the other option.'))
72
70
                self.comm.set_busy(self.window, False)
73
71
                return
74
72
            
75
73
            try:
76
 
                fileops.remove([directory + '/' + filename])
 
74
                wt, path = WorkingTree.open_containing(directory + '/' + filename)
 
75
                wt.remove(path)
77
76
            except errors.NotBranchError:
78
 
                self.dialog.error_dialog(_('Directory is not a branch'),
 
77
                error_dialog(_('Directory is not a branch'),
79
78
                                         _('You can perform this action only in a branch.'))
80
79
                self.comm.set_busy(self.window, False)
81
80
                return
82
81
            except errors.NotVersionedError:
83
 
                self.dialog.error_dialog(_('File not versioned'),
 
82
                error_dialog(_('File not versioned'),
84
83
                                         _('The selected file is not versioned.'))
85
84
                self.comm.set_busy(self.window, False)
86
85
                return
89
88
        elif radio_new.get_active():
90
89
            # Remove added files recursively
91
90
            try:
92
 
                fileops.remove([directory], True)
 
91
                wt, path = WorkingTree.open_containing(directory)
93
92
            except errors.NotBranchError:
94
 
                self.dialog.error_dialog(_('Directory is not a branch'),
 
93
                error_dialog(_('Directory is not a branch'),
95
94
                                         _('You can perform this action only in a branch.'))
96
95
                self.comm.set_busy(self.window, False)
97
96
                return
98
 
            except errors.NoMatchingFiles:
 
97
            
 
98
            added = wt.changes_from(wt.basis_tree()).added
 
99
            file_list = sorted([f[0] for f in added], reverse=True)
 
100
            if len(file_list) == 0:
99
101
                dialog.warning_dialog(_('No matching files'),
100
102
                                      _('No added files were found in the working tree.'))
101
103
                self.comm.set_busy(self.window, False)
102
 
            except:
103
 
                raise
 
104
                return
 
105
            wt.remove(file_list)
104
106
        else:
105
107
            # This should really never happen.
106
108
            pass