/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-28 06:35:56 UTC
  • mto: (0.12.2 olive)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060928063556-62ec354cb06ba38c
Update TODO
integrate the handle and communicator functions into a main class.

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