/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 19:52:46 UTC
  • mto: (0.12.2 olive)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060927195246-9354d7ccf56127f5
Don't pass around gladefile all the time. 
Fix bug in status information when files have been removed.

Show diffs side-by-side

added added

removed removed

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