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

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-08-13 11:02:48 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-20060813110248-4f256d8db6247b61
Some bugs fixed in the Push dialog; added TODO items.

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

    * TODO: some more items added
    * olive.glade: Push window should not be visible by default
    * olive/frontend/gtk/push.py: fixed a bug if no push location known; user
      gets an error if directory is not a branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
import olive.backend.errors as errors
33
33
import olive.backend.info as info
34
34
 
 
35
from dialog import OliveDialog
 
36
 
35
37
class OlivePush:
36
38
    """ Display Push dialog and perform the needed actions. """
37
39
    def __init__(self, gladefile, comm):
40
42
        self.glade = gtk.glade.XML(self.gladefile, 'window_push')
41
43
        
42
44
        self.comm = comm
 
45
        self.dialog = OliveDialog(self.gladefile)
43
46
        
44
47
        self.window = self.glade.get_widget('window_push')
45
48
        
60
63
        self.check_create = self.glade.get_widget('checkbutton_push_create')
61
64
        
62
65
        # Get stored location
63
 
        loc = info.get_push_location(self.comm.get_path())
64
 
        if loc != '':
 
66
        self.notbranch = False
 
67
        try:
 
68
            loc = info.get_push_location(self.comm.get_path())
 
69
        except errors.NotBranchError:
 
70
            self.notbranch = True
 
71
            return
 
72
 
 
73
        if loc is not None:
65
74
            self.entry_stored.set_text(loc)
66
75
    
67
76
    def display(self):
68
77
        """ Display the Push dialog. """
69
 
        self.window.show()
70
 
        self.width, self.height = self.window.get_size()
 
78
        if self.notbranch:
 
79
            self.dialog.error_dialog('Directory is not a branch.')
 
80
            self.close()
 
81
        else:
 
82
            self.window.show()
 
83
            self.width, self.height = self.window.get_size()
71
84
    
72
85
    def stored_toggled(self, widget):
73
86
        if widget.get_active():
95
108
            self.check_create.hide()
96
109
    
97
110
    def push(self, widget):
98
 
        from dialog import OliveDialog
99
 
        dialog = OliveDialog(self.gladefile)
100
 
        
101
111
        radio_stored = self.glade.get_widget('radiobutton_push_stored')
102
112
        radio_specific = self.glade.get_widget('radiobutton_push_specific')
103
113
        
108
118
                revs = commit.push(self.comm.get_path(),
109
119
                                   overwrite=self.check_overwrite.get_active())
110
120
            except errors.NotBranchError:
111
 
                dialog.error_dialog('Directory is not a branch.')
 
121
                self.dialog.error_dialog('Directory is not a branch.')
112
122
                return
113
123
            except errors.NoLocationKnown:
114
 
                dialog.error_dialog('No location known.')
 
124
                self.dialog.error_dialog('No location known.')
115
125
                return
116
126
            except errors.NonExistingParent, errmsg:
117
 
                dialog.error_dialog('Parent directory doesn\'t exist: %s', errmsg)
 
127
                self.dialog.error_dialog('Parent directory doesn\'t exist: %s', errmsg)
118
128
                return
119
129
            except errors.DivergedBranchesError:
120
 
                dialog.error_dialog('Branches have been diverged.')
 
130
                self.dialog.error_dialog('Branches have been diverged.')
121
131
                return
122
132
            except:
123
133
                raise
124
134
        elif radio_specific.get_active():
125
135
            location = self.entry_location.get_text()
126
136
            if location == '':
127
 
                dialog.error_dialog('No location specified.')
 
137
                self.dialog.error_dialog('No location specified.')
128
138
                return
129
139
            
130
140
            try:
133
143
                                   self.check_overwrite.get_active(),
134
144
                                   self.check_create.get_active())
135
145
            except errors.NotBranchError:
136
 
                dialog.error_dialog('Directory is not a branch.')
 
146
                self.dialog.error_dialog('Directory is not a branch.')
137
147
                self.comm.set_busy(self.window, False)
138
148
                return
139
149
            except errors.NonExistingParent, errmsg:
140
 
                dialog.error_dialog('Parent directory doesn\'t exist: %s', errmsg)
 
150
                self.dialog.error_dialog('Parent directory doesn\'t exist: %s', errmsg)
141
151
                self.comm.set_busy(self.window, False)
142
152
                return
143
153
            except errors.DivergedBranchesError:
144
 
                dialog.error_dialog('Branches have been diverged.')
 
154
                self.dialog.error_dialog('Branches have been diverged.')
145
155
                self.comm.set_busy(self.window, False)
146
156
                return
147
157
            except errors.PathPrefixNotCreated:
148
 
                dialog.error_dialog('Path prefix couldn\'t be created.')
 
158
                self.dialog.error_dialog('Path prefix couldn\'t be created.')
149
159
                self.comm.set_busy(self.window, False)
150
160
                return
151
161
            except:
155
165
            pass
156
166
        
157
167
        self.close()
158
 
        dialog.info_dialog('%d revision(s) pushed.' % revs)
 
168
        self.dialog.info_dialog('%d revision(s) pushed.' % revs)
159
169
    
160
170
    def close(self, widget=None):
161
171
        self.window.destroy()