def confirmation_alert(self, msg, title=None, confirmation_cb=None): alert = ConfirmationAlert() alert.props.title = title alert.props.msg = msg alert.pydebug_cb = confirmation_cb alert.connect('response', self._alert_response_cb) self._activity.add_alert(alert) return alert
def _overwrite_bookmarklet_cb(self, store, name, url): '''Ask for confirmation''' alert = ConfirmationAlert() alert.props.title = _('Add bookmarklet') alert.props.msg = _('"%s" already exists. Overwrite?') % name alert.connect('response', self._overwrite_bookmarklet_response_cb) # send the arguments through the alert object alert._bm = (name, url) self.add_alert(alert)
def _userscript_found_cb(self, listener, location): '''Ask user whether to install the userscript''' alert = ConfirmationAlert() alert.props.title = _('Add userscript') if usercode.script_exists(location): alert.props.msg = _('Userscript already exists. Overwrite?') else: alert.props.msg = _('Do you want to add this userscript?') alert.connect('response', self._userscript_found_response_cb) # send the argument through the alert object alert._location = location self.add_alert(alert)
def _downgrade_option_alert(bundle): alert = ConfirmationAlert() alert.props.title = _('Older Version Of %s Activity') % (bundle.get_name()) alert.props.msg = _('Do you want to downgrade to version %s') % \ bundle.get_activity_version() alert.connect('response', _downgrade_alert_response_cb, bundle) journalwindow.get_journal_window().add_alert(alert) alert.show()
def confirmation_alert(self, title, msg, cb, *cb_args): """Raise standard confirmation alert""" alert = ConfirmationAlert(title=title, msg=msg) def response(alert, response_id, self, cb, *cb_args): self.remove_alert(alert) if response_id is gtk.RESPONSE_OK: cb(*cb_args) alert.connect('response', response, self, cb, *cb_args) alert.show_all() self.add_alert(alert)
def _onMessageCb(self, bus, message): t = message.type if t == gst.MESSAGE_EOS: if self._eos_cb: cb = self._eos_cb self._eos_cb = None cb() elif t == gst.MESSAGE_ELEMENT: s = message.structure if s.has_name("barcode"): self.stop() self.window.hide() aplay.play(Constants.sound_click) self.last_detection = s['symbol'] parsedurl = urlparse.urlparse(s['symbol']) if parsedurl.scheme in self.recognized_schemes: alert = TimeoutAlert(60) alert.remove_button(gtk.RESPONSE_CANCEL) alert.props.title = 'Direccion detectada!' alert.props.msg = 'La dirección fue copiada al ' +\ 'portatapeles. Acceda al ' +\ 'marco de Sugar y haga click sobre ' +\ 'ella para abrirla en el navegador.' alert.connect('response', self._alert_uri_response_cb) self.ca.add_alert(alert) self._copyURIToClipboard() self.ca.alert.show() else: alert = ConfirmationAlert() alert.props.title = 'Texto detectado. ' +\ '¿Desea copiarlo al portapapeles?' alert.props.msg = s['symbol'] alert.connect('response', self._alert_text_response_cb) self.ca.add_alert(alert) self.ca.alert.show() elif t == gst.MESSAGE_ERROR: #todo: if we come out of suspend/resume with errors, then get us # back up and running... #todo: handle "No space left on the resource.gstfilesink.c" #err, debug = message.parse_error() pass
import gtk from sugar.graphics.alert import ConfirmationAlert window = gtk.Window() box = gtk.VBox() window.add(box) def _alert_response_cb(alert, response_id, entry): print entry.get_text() if response_id is gtk.RESPONSE_OK: print 'Ok' elif response_id is gtk.RESPONSE_CANCEL: print 'Cancel' box.remove(alert) gtk.main_quit() alert = ConfirmationAlert() alert.props.title = 'Title of ConfirmationAlert' alert.props.msg = 'Text of confirmation alert, either button will quit' box.add(alert) entry = alert.add_entry() entry.set_text('this entry') alert.connect('response', _alert_response_cb, entry) window.show_all() gtk.main()
import gtk from sugar.graphics.alert import ConfirmationAlert window = gtk.Window() box = gtk.VBox() window.add(box) def _alert_response_cb(alert, response_id, entry): print entry.get_text() if response_id is gtk.RESPONSE_OK: print 'Ok' elif response_id is gtk.RESPONSE_CANCEL: print 'Cancel' box.remove(alert) gtk.main_quit() alert = ConfirmationAlert() alert.props.title='Title of ConfirmationAlert' alert.props.msg = 'Text of confirmation alert, either button will quit' box.add(alert) entry = alert.add_entry() entry.set_text('this entry') alert.connect('response', _alert_response_cb, entry) window.show_all() gtk.main()