/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/move.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-09-30 11:01:59 UTC
  • mto: (0.14.3 main)
  • mto: This revision was merged to the branch mainline in revision 86.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060930110159-d1d716766985f3dd
Fix Move, Rename and glade file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
import os
18
 
import sys
 
18
from os.path import dirname
19
19
 
20
20
try:
21
21
    import pygtk
27
27
import gtk.glade
28
28
 
29
29
import bzrlib.errors as errors
 
30
from bzrlib.workingtree import WorkingTree
30
31
 
31
32
from olive import gladefile
 
33
from dialog import error_dialog
32
34
 
33
35
class OliveMove:
34
36
    """ Display the Move dialog and perform the needed actions. """
35
 
    def __init__(self, comm):
 
37
    def __init__(self, wt, wtpath, selected=[]):
36
38
        """ Initialize the Move dialog. """
37
39
        self.glade = gtk.glade.XML(gladefile, 'window_move', 'olive-gtk')
38
40
        
39
 
        # Communication object
40
 
        self.comm = comm
41
 
        
42
41
        self.window = self.glade.get_widget('window_move')
43
42
        
44
43
        # Dictionary for signal_autoconnect
48
47
        # Connect the signals to the handlers
49
48
        self.glade.signal_autoconnect(dic)
50
49
        
 
50
        self.wt = wt
 
51
        self.wtpath = wtpath
 
52
        self.selected = selected
 
53
        
 
54
        if self.selected is None:
 
55
            self.selected = ""
 
56
        
 
57
        if self.wtpath == "":
 
58
            directory = dirname(self.wt.abspath(self.selected))
 
59
        else:
 
60
            directory = dirname(self.wt.abspath(self.wtpath + os.sep + self.selected))
 
61
        
51
62
        # Set FileChooser directory
52
63
        self.filechooser = self.glade.get_widget('filechooserbutton_move')
53
 
        self.filechooser.set_filename(self.comm.get_path())
 
64
        self.filechooser.set_filename(directory)
54
65
 
55
66
    def display(self):
56
67
        """ Display the Move dialog. """
59
70
    def move(self, widget):
60
71
        destination = self.filechooser.get_filename()
61
72
 
62
 
        filename = self.comm.get_selected_right()
 
73
        filename = self.selected
63
74
            
64
75
        if filename is None:
65
76
            error_dialog(_('No file was selected'),
66
 
                                     _('Please select a file from the list to proceed.'))
 
77
                         _('Please select a file from the list to proceed.'))
67
78
            return
68
79
        
69
 
        source = self.comm.get_path() + '/' + filename
 
80
        if self.wtpath == "":
 
81
            source = self.wt.abspath(filename)
 
82
        else:
 
83
            source = self.wt.abspath(self.wtpath + os.sep + filename)
70
84
        
71
85
        # Move the file to a directory
72
86
        try:
74
88
            wt2, path2 = WorkingTree.open_containing(destination)
75
89
            if wt1.base != wt2.base:
76
90
                error_dialog(_('Not the same branch'),
77
 
                                         _('The destination is not in the same branch.'))
 
91
                             _('The destination is not in the same branch.'))
78
92
                return
79
93
 
80
94
            wt1.move([source], destination)
81
95
        except errors.NotBranchError:
82
96
            error_dialog(_('File is not in a branch'),
83
 
                                     _('The selected file is not in a branch.'))
 
97
                         _('The selected file is not in a branch.'))
84
98
            return
85
99
 
86
100
        self.close()
87
 
        self.comm.refresh_right()
88
101
    
89
102
    def close(self, widget=None):
90
103
        self.window.destroy()