/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-20 20:58:17 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-20060820205817-19c10a333512cd52
Added Test write access functionality to the Push dialog.

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

    * po/olive-gtk.pot: regenerated
    * olive/frontend/gtk/push.py: added basic test functionality
    * olive.glade: added test related widgets to the Push dialog

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
        # Dictionary for signal_autoconnect
50
50
        dic = { "on_button_push_push_clicked": self.push,
51
51
                "on_button_push_cancel_clicked": self.close,
 
52
                "on_button_push_test_clicked": self.test,
52
53
                "on_radiobutton_push_stored_toggled": self.stored_toggled,
53
54
                "on_radiobutton_push_specific_toggled": self.specific_toggled, }
54
55
        
56
57
        self.glade.signal_autoconnect(dic)
57
58
        
58
59
        # Get some useful widgets
 
60
        self.radio_stored = self.glade.get_widget('radiobutton_push_stored')
 
61
        self.radio_specific = self.glade.get_widget('radiobutton_push_specific')
59
62
        self.entry_stored = self.glade.get_widget('entry_push_stored')
60
63
        self.entry_location = self.glade.get_widget('entry_push_location')
61
64
        self.check_remember = self.glade.get_widget('checkbutton_push_remember')
62
65
        self.check_overwrite = self.glade.get_widget('checkbutton_push_overwrite')
63
66
        self.check_create = self.glade.get_widget('checkbutton_push_create')
 
67
        self.label_test = self.glade.get_widget('label_push_test')
 
68
        self.image_test = self.glade.get_widget('image_push_test')
64
69
        
65
70
        # Get stored location
66
71
        self.notbranch = False
109
114
            self.check_create.hide()
110
115
    
111
116
    def push(self, widget):
112
 
        radio_stored = self.glade.get_widget('radiobutton_push_stored')
113
 
        radio_specific = self.glade.get_widget('radiobutton_push_specific')
114
 
        
115
117
        revs = 0
116
118
        self.comm.set_busy(self.window)
117
 
        if radio_stored.get_active():
 
119
        if self.radio_stored.get_active():
118
120
            try:
119
121
                revs = commit.push(self.comm.get_path(),
120
122
                                   overwrite=self.check_overwrite.get_active())
136
138
                return
137
139
            except:
138
140
                raise
139
 
        elif radio_specific.get_active():
 
141
        elif self.radio_specific.get_active():
140
142
            location = self.entry_location.get_text()
141
143
            if location == '':
142
144
                self.dialog.error_dialog(_('No location specified'),
178
180
        self.dialog.info_dialog(_('Push successful'),
179
181
                                _('%d revision(s) pushed.') % revs)
180
182
    
 
183
    def test(self, widget):
 
184
        """ Test if write access possible. """
 
185
        import re
 
186
        _urlRE = re.compile(r'^(?P<proto>[^:/\\]+)://(?P<path>.*)$')
 
187
        
 
188
        if self.radio_stored.get_active():
 
189
            url = self.entry_stored.get_text()
 
190
        elif self.radio_specific.get_active():
 
191
            url = self.entry_location.get_text()
 
192
        
 
193
        m = _urlRE.match(url)
 
194
        if m:
 
195
            proto = m.groupdict()['proto']
 
196
            if (proto == 'sftp') or (proto == 'file'):
 
197
                # have write acces (most probably)
 
198
                self.image_test.set_from_stock(gtk.STOCK_YES, 4)
 
199
                self.label_test.set_markup(_('<b>Write access is available most probably</b>'))
 
200
            else:
 
201
                # no write access
 
202
                self.image_test.set_from_stock(gtk.STOCK_NO, 4)
 
203
                self.label_test.set_markup(_('<b>No write access</b>'))
 
204
        else:
 
205
            # couldn't determine
 
206
            self.image_test.set_from_stock(gtk.STOCK_DIALOG_QUESTION, 4)
 
207
            self.label_test.set_markup(_('<b>Could not determine</b>'))
 
208
    
181
209
    def close(self, widget=None):
182
210
        self.window.destroy()