/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: Javier Derderian
  • Date: 2008-04-11 20:34:06 UTC
  • mto: (465.1.1 gtk.patch)
  • mto: This revision was merged to the branch mainline in revision 466.
  • Revision ID: javierder@gmail.com-20080411203406-ftlwyodw9vr87olv
Updated "Compare with..." (#78765) to use revbrowser.RevisionBrowser.
Also needed to fix #215872 to make it work.

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