/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-13 20:19:31 UTC
  • mfrom: (0.8.79 main)
  • mto: (0.8.83 merge)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060913201931-23adba246d4d6529
Merge main branch.

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