/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: 2007-07-15 18:12:57 UTC
  • Revision ID: jelmer@samba.org-20070715181257-g264qus2zyi3v39z
Add RevisionSelectionBox widget, use in TagDialog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
import bzrlib.errors as errors
29
29
from bzrlib.workingtree import WorkingTree
30
30
 
31
 
from olive import gladefile
32
 
from dialog import error_dialog
 
31
from bzrlib.plugins.gtk.dialog import error_dialog
 
32
from guifiles import GLADEFILENAME
 
33
 
33
34
 
34
35
class OliveRename:
35
36
    """ Display the Rename dialog and perform the needed actions. """
36
37
    def __init__(self, wt, wtpath, selected=[]):
37
38
        """ Initialize the Rename dialog. """
38
 
        self.glade = gtk.glade.XML(gladefile, 'window_rename')
 
39
        self.glade = gtk.glade.XML(GLADEFILENAME, 'window_rename')
39
40
        
40
41
        self.window = self.glade.get_widget('window_rename')
 
42
        self.entry = self.glade.get_widget('entry_rename')
41
43
        
42
44
        # Dictionary for signal_autoconnect
43
45
        dic = { "on_button_rename_rename_clicked": self.rename,
52
54
        
53
55
    def display(self):
54
56
        """ Display the Rename dialog. """
 
57
        if self.selected is not None:
 
58
            self.entry.set_text(self.selected)
 
59
        
55
60
        self.window.show_all()
56
61
 
 
62
    @show_bzr_error
57
63
    def rename(self, widget):
58
64
        # Get entry
59
 
        entry = self.glade.get_widget('entry_rename')
60
 
        
61
65
        old_filename = self.selected
62
 
        new_filename = entry.get_text()
 
66
        new_filename = self.entry.get_text()
63
67
            
64
68
        if old_filename is None:
65
69
            error_dialog(_('No file was selected'),
75
79
        destination = os.path.join(self.wtpath, new_filename)
76
80
        
77
81
        # Rename the file
78
 
        try:
79
 
            wt1, path1 = WorkingTree.open_containing(self.wt.abspath(source))
80
 
            wt2, path2 = WorkingTree.open_containing(self.wt.abspath(source))
 
82
        wt1, path1 = WorkingTree.open_containing(self.wt.abspath(source))
 
83
        wt2, path2 = WorkingTree.open_containing(self.wt.abspath(source))
81
84
 
82
 
            if wt1.basedir != wt2.basedir:
83
 
                error_dialog(_('Not the same branch'),
84
 
                             _('The destination is not in the same branch.'))
85
 
                return
86
 
            wt1.rename_one(source, destination)
87
 
        except errors.NotBranchError:
88
 
            error_dialog(_('File is not in a branch'),
89
 
                         _('The selected file is not in a branch.'))
 
85
        if wt1.basedir != wt2.basedir:
 
86
            error_dialog(_('Not the same branch'),
 
87
                         _('The destination is not in the same branch.'))
90
88
            return
91
 
        except errors.BzrError, msg:
92
 
            error_dialog(_('Unknown bzr error'), str(msg))
93
 
 
 
89
        wt1.rename_one(source, destination)
94
90
        self.close()
95
91
    
96
92
    def close(self, widget=None):