/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/frontend/gtk/branch.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-08-15 17:37:54 UTC
  • mto: (0.14.1 main) (93.1.1 win32.bialix)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060815173754-9877ef0e3e64660e
Some small tweaks in the .desktop file.

2006-08-15  Szilveszter Farkas <Szilveszter.Farkas@gmail.com>

    * icons/olive-gtk.png: added application icon

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    pygtk.require("2.0")
22
22
except:
23
23
    pass
24
 
 
25
 
import gtk
26
 
import gtk.glade
27
 
 
28
 
import bzrlib.errors as errors
29
 
from __init__ import gladefile
 
24
try:
 
25
    import gtk
 
26
    import gtk.glade
 
27
except:
 
28
    sys.exit(1)
 
29
 
 
30
import olive.backend.init as init
 
31
import olive.backend.errors as errors
30
32
 
31
33
class OliveBranch:
32
34
    """ Display branch dialog and perform the needed operations. """
33
 
    def __init__(self, path=None):
 
35
    def __init__(self, gladefile, comm, dialog):
34
36
        """ Initialize the Branch dialog. """
35
 
        self.glade = gtk.glade.XML(gladefile, 'window_branch', 'olive-gtk')
36
 
 
 
37
        self.gladefile = gladefile
 
38
        self.glade = gtk.glade.XML(self.gladefile, 'window_branch')
 
39
        
 
40
        # Communication object
 
41
        self.comm = comm
 
42
        # Dialog object
 
43
        self.dialog = dialog
 
44
        
37
45
        self.window = self.glade.get_widget('window_branch')
38
46
        
39
47
        # Dictionary for signal_autoconnect
45
53
        
46
54
        # Save FileChooser state
47
55
        self.filechooser = self.glade.get_widget('filechooserbutton_branch')
48
 
        if path is not None:
49
 
            self.filechooser.set_filename(path)
 
56
        self.filechooser.set_filename(self.comm.get_path())
50
57
 
51
58
    def display(self):
52
59
        """ Display the Branch dialog. """
56
63
        entry_location = self.glade.get_widget('entry_branch_location')
57
64
        location = entry_location.get_text()
58
65
        if location is '':
59
 
            error_dialog(_('Missing branch location'),
60
 
                                     _('You must specify a branch location.'))
 
66
            self.dialog.error_dialog('Missing branch location',
 
67
                                     'You must specify a branch location.')
61
68
            return
62
69
        
63
70
        destination = self.filechooser.get_filename()
64
71
        
65
72
        spinbutton_revno = self.glade.get_widget('spinbutton_branch_revno')
66
73
        revno = spinbutton_revno.get_value_as_int()
67
 
        revision_id = br_from.get_rev_id(revno)
 
74
        if revno == 0:
 
75
            revno = None
68
76
        
 
77
        self.comm.set_busy(self.window)
69
78
        try:
70
 
            from bzrlib.transport import get_transport
71
 
 
72
 
            br_from = Branch.open(location)
73
 
            br_from.lock_read()
74
 
 
75
 
            try:
76
 
                destination = destination + '/' + os.path.basename(location.rstrip("/\\"))
77
 
                to_transport = get_transport(destination)
78
 
                to_transport.mkdir('.')
79
 
 
80
 
                try:
81
 
                    dir = br_from.bzrdir.sprout(to_transport.base, revision_id)
82
 
                    branch = dir.open_branch()
83
 
                except NoSuchRevision:
84
 
                    to_transport.delete_tree('.')
85
 
                    raise
86
 
 
87
 
            finally:
88
 
                br_from.unlock()
89
 
                
90
 
            self.close()
91
 
            info_dialog(_('Branching successful'),
92
 
                        _('%d revision(s) branched.') % revs)
 
79
            revs = init.branch(location, destination, revno)
93
80
        except errors.NonExistingSource, errmsg:
94
 
            error_dialog(_('Non existing source'),
95
 
                                     _("The location (%s)\ndoesn't exist.") % errmsg)
 
81
            self.dialog.error_dialog('Non existing source',
 
82
                                     "The location (%s)\ndoesn't exist." % errmsg)
 
83
            self.comm.set_busy(self.window, False)
96
84
            return
97
85
        except errors.TargetAlreadyExists, errmsg:
98
 
            error_dialog(_('Target already exists'),
99
 
                                     _('Target directory (%s)\nalready exists. Please select another target.') % errmsg)
 
86
            self.dialog.error_dialog('Target already exists',
 
87
                                     'Target directory (%s)\nalready exists. Please select another target.' % errmsg)
 
88
            self.comm.set_busy(self.window, False)
100
89
            return
101
90
        except errors.NonExistingParent, errmsg:
102
 
            error_dialog(_('Non existing parent directory'),
103
 
                                     _("The parent directory (%s)\ndoesn't exist.") % errmsg)
 
91
            self.dialog.error_dialog("Non existing parent directory",
 
92
                                     "The parent directory (%s)\ndoesn't exist." % errmsg)
 
93
            self.comm.set_busy(self.window, False)
104
94
            return
105
95
        except errors.NonExistingRevision:
106
 
            error_dialog(_('Non existing revision'),
107
 
                                     _("The revision you specified doesn't exist."))
 
96
            self.dialog.error_dialog('Non existing revision',
 
97
                                     "The revision you specified doesn't exist.")
 
98
            self.comm.set_busy(self.window, False)
108
99
            return
109
100
        except errors.NotBranchError, errmsg:
110
 
            error_dialog(_('Location is not a branch'),
111
 
                                     _('The specified location has to be a branch.'))
 
101
            self.dialog.error_dialog('Location is not a branch'
 
102
                                     'The specified location has to be a branch')
 
103
            self.comm.set_busy(self.window, False)
112
104
            return
 
105
        except:
 
106
            raise
113
107
        
 
108
        self.close()
 
109
        self.dialog.info_dialog('Branching successful',
 
110
                                '%d revision(s) branched.' % revs)
 
111
        self.comm.refresh_right()
114
112
 
115
113
    def close(self, widget=None):
116
114
        self.window.destroy()