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