/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-09-11 02:56:58 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-20060911025658-997cf3a305b9f1da
A better implementation for the drive selection. (OptionMenu didn't work on Win32)

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
        
 
70
        # Set initial state
 
71
        self.entry_location.set_sensitive(0)
 
72
        self.check_remember.set_sensitive(0)
 
73
        self.check_create.set_sensitive(0)
 
74
                
65
75
        # Get stored location
66
76
        self.notbranch = False
67
77
        try:
85
95
    
86
96
    def stored_toggled(self, widget):
87
97
        if widget.get_active():
88
 
            self.entry_stored.show()
89
 
            self.entry_location.hide()
90
 
            self.check_remember.hide()
91
 
            self.check_create.hide()
92
 
            self.window.resize(self.width, self.height)
 
98
            self.entry_stored.set_sensitive(1)
 
99
            self.entry_location.set_sensitive(0)
 
100
            self.check_remember.set_sensitive(0)
 
101
            self.check_create.set_sensitive(0)
93
102
        else:
94
 
            self.entry_stored.hide()
95
 
            self.entry_location.show()
96
 
            self.check_remember.show()
97
 
            self.check_create.show()
 
103
            self.entry_stored.set_sensitive(0)
 
104
            self.entry_location.set_sensitive(1)
 
105
            self.check_remember.set_sensitive(1)
 
106
            self.check_create.set_sensitive(1)
98
107
    
99
108
    def specific_toggled(self, widget):
100
109
        if widget.get_active():
101
 
            self.entry_stored.hide()
102
 
            self.entry_location.show()
103
 
            self.check_remember.show()
104
 
            self.check_create.show()
 
110
            self.entry_stored.set_sensitive(0)
 
111
            self.entry_location.set_sensitive(1)
 
112
            self.check_remember.set_sensitive(1)
 
113
            self.check_create.set_sensitive(1)
105
114
        else:
106
 
            self.entry_stored.show()
107
 
            self.entry_location.hide()
108
 
            self.check_remember.hide()
109
 
            self.check_create.hide()
 
115
            self.entry_stored.set_sensitive(1)
 
116
            self.entry_location.set_sensitive(0)
 
117
            self.check_remember.set_sensitive(0)
 
118
            self.check_create.set_sensitive(0)
110
119
    
111
120
    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
121
        revs = 0
116
122
        self.comm.set_busy(self.window)
117
 
        if radio_stored.get_active():
 
123
        if self.radio_stored.get_active():
118
124
            try:
119
125
                revs = commit.push(self.comm.get_path(),
120
126
                                   overwrite=self.check_overwrite.get_active())
136
142
                return
137
143
            except:
138
144
                raise
139
 
        elif radio_specific.get_active():
 
145
        elif self.radio_specific.get_active():
140
146
            location = self.entry_location.get_text()
141
147
            if location == '':
142
148
                self.dialog.error_dialog(_('No location specified'),
178
184
        self.dialog.info_dialog(_('Push successful'),
179
185
                                _('%d revision(s) pushed.') % revs)
180
186
    
 
187
    def test(self, widget):
 
188
        """ Test if write access possible. """
 
189
        import re
 
190
        _urlRE = re.compile(r'^(?P<proto>[^:/\\]+)://(?P<path>.*)$')
 
191
        
 
192
        if self.radio_stored.get_active():
 
193
            url = self.entry_stored.get_text()
 
194
        elif self.radio_specific.get_active():
 
195
            url = self.entry_location.get_text()
 
196
        
 
197
        m = _urlRE.match(url)
 
198
        if m:
 
199
            proto = m.groupdict()['proto']
 
200
            if (proto == 'sftp') or (proto == 'file') or (proto == 'ftp'):
 
201
                # have write acces (most probably)
 
202
                self.image_test.set_from_stock(gtk.STOCK_YES, 4)
 
203
                self.label_test.set_markup(_('<b>Write access is probably available</b>'))
 
204
            else:
 
205
                # no write access
 
206
                self.image_test.set_from_stock(gtk.STOCK_NO, 4)
 
207
                self.label_test.set_markup(_('<b>No write access</b>'))
 
208
        else:
 
209
            # couldn't determine
 
210
            self.image_test.set_from_stock(gtk.STOCK_DIALOG_QUESTION, 4)
 
211
            self.label_test.set_markup(_('<b>Could not determine</b>'))
 
212
    
181
213
    def close(self, widget=None):
182
214
        self.window.destroy()