/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-29 20:59:52 UTC
  • mfrom: (0.8.92 merge)
  • Revision ID: jelmer@samba.org-20060929205952-32ce1f02b7cf334b
MergeĀ OliveĀ code.

Show diffs side-by-side

added added

removed removed

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