/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/rename.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:
28
28
except:
29
29
    sys.exit(1)
30
30
 
31
 
import olive.backend.errors as errors
32
 
import olive.backend.fileops as fileops
 
31
import bzrlib.errors as errors
33
32
 
34
33
class OliveRename:
35
34
    """ Display the Rename dialog and perform the needed actions. """
36
 
    def __init__(self, gladefile, comm, dialog):
 
35
    def __init__(self, comm):
37
36
        """ Initialize the Rename dialog. """
38
 
        self.gladefile = gladefile
39
 
        self.glade = gtk.glade.XML(self.gladefile, 'window_rename')
 
37
        self.glade = gtk.glade.XML(gladefile, 'window_rename')
40
38
        
41
39
        # Communication object
42
40
        self.comm = comm
43
 
        # Dialog object
44
 
        self.dialog = dialog
45
41
        
46
42
        self.window = self.glade.get_widget('window_rename')
47
43
        
64
60
        new_filename = entry.get_text()
65
61
            
66
62
        if old_filename is None:
67
 
            self.dialog.error_dialog(_('No file was selected'),
 
63
            error_dialog(_('No file was selected'),
68
64
                                     _('Please select a file from the list to proceed.'))
69
65
            return
70
66
        
71
67
        if new_filename == "":
72
 
            self.dialog.error_dialog(_('Filename not given'),
 
68
            error_dialog(_('Filename not given'),
73
69
                                     _('Please specify a new name for the file.'))
74
70
            return
75
71
        
78
74
        
79
75
        # Rename the file
80
76
        try:
81
 
            fileops.rename(source, destination)
 
77
            wt1, path1 = WorkingTree.open_containing(source)
 
78
            wt2, path2 = WorkingTree.open_containing(source)
 
79
 
 
80
            if wt1.base != wt2.base:
 
81
                error_dialog(_('Not the same branch'),
 
82
                                         _('The destination is not in the same branch.'))
 
83
                return
 
84
            wt1.rename_one(source, destination)
82
85
        except errors.NotBranchError:
83
 
            self.dialog.error_dialog(_('File is not in a branch'),
 
86
            error_dialog(_('File is not in a branch'),
84
87
                                     _('The selected file is not in a branch.'))
85
88
            return
86
 
        except errors.NotSameBranchError:
87
 
            self.dialog.error_dialog(_('Not the same branch'),
88
 
                                     _('The destination is not in the same branch.'))
89
 
            return
90
 
        except:
91
 
            raise
92
89
 
93
90
        self.close()
94
91
        self.comm.refresh_right()