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
def shutter_sound(self, done_cb=None): aplay.play('photoShutter.wav', done_cb)