Ejemplo n.º 1
0
    def _on_device_state_changed(self, device, new_state, old_state, reason):
        new = NM.DeviceState(new_state)
        old = NM.DeviceState(old_state)
        state_reason = NM.DeviceStateReason(reason)
        logging.debug(
            f"New: {new.value_nick} Old: {old.value_nick} Reason: {state_reason.value_nick}"
        )

        error_msg = None
        reply_msg = None

        if new == NM.DeviceState.FAILED:
            error_msg = f"Connection failed with reason: {state_reason.value_nick}"
        elif new == NM.DeviceState.ACTIVATED:
            reply_msg = 'Connection sucesfully activated'
        elif (new <= NM.DeviceState.DISCONNECTED or new == NM.DeviceState.DEACTIVATING) and \
                (NM.DeviceState.DISCONNECTED < old <= NM.DeviceState.ACTIVATED):
            error_msg = f"Connection disconnected with reason {state_reason.value_nick}"
        else:
            return  # Keep checking the state changes

        # We are done with state changes
        GObject.signal_handler_disconnect(device, self._statehandler)
        if error_msg is None:
            self._return_or_reply_handler(reply_msg)
        else:
            logging.debug(error_msg)
            self._raise_or_error_handler(NMConnectionError(error_msg))
    def __clip_dialog_cb(self, widget, clip):
        clip = clip.bClip
        asset = clip.get_asset()
        filename = GLib.filename_from_uri(clip.props.uri)[0]

        self.__current_builder = Gtk.Builder()
        self.__current_builder.add_from_file(os.path.join(here, 'clip-dialog.ui'))
        self.__current_builder.connect_signals(self)
        self.__current_builder.get_object('step-spinner').set_range(1, 100)
        dialog = self.__current_builder.get_object('clip-dialog')
        dialog.set_transient_for(self.app.gui)

        self.__analyse_track(filename, self.__display_track_analysis,
                (self.__current_builder, asset, filename,))

        res = dialog.run()
        # We gud
        dialog.destroy()

        self.__add_markers_to_timeline(clip)

        self.__clap_mixer.reset()

        for handler_id in self.__clap_mixer_handlers:
            GObject.signal_handler_disconnect(self.__clap_mixer.pipeline,
                    handler_id)

        self.__clap_mixer_handlers = []
        self.__current_builder = None
        self.__selected_beats = None
Ejemplo n.º 3
0
 def handle_registration(self, framer, event):
     if isinstance(event, RegisterEvent):
         pended = self.pending.pop(id(framer))
         if pended:
             for msg_id in pended[1:]:
                 GObject.signal_handler_disconnect(framer, msg_id)
         ExtensionController(self.controllers, framer, event.extension_id)
     else:
         logger.debug("Unhandled message received: %s", event)
Ejemplo n.º 4
0
    def __exit__(self, etype, evalue, etraceback):
        if etype is not None:
            return False
        while not self.matched:
            self.loop.run_checked()

        GLib.source_remove(self.timeout_id)
        GObject.signal_handler_disconnect(self.notifier, self.signal_id)

        return True
Ejemplo n.º 5
0
    def __exit__(self, etype, evalue, etraceback):
        if etype is not None:
            return False

        while self.result.urn is None:
            self.loop.run_checked()
            log.debug("Got urn %s", self.result.urn)

        GLib.source_remove(self.timeout_id)
        GObject.signal_handler_disconnect(self.notifier, self.signal_id)

        return True
Ejemplo n.º 6
0
    def set_key_events_handlers(self, press=None, release=None):
        if self._press_signal_id:
            GObject.signal_handler_disconnect(self, self._press_signal_id)
            self._press_signal_id = None

        if self._release_signal_id:
            GObject.signal_handler_disconnect(self, self._release_signal_id)
            self._release_signal_id = None

        if press:
            self._press_signal_id = self.connect('key-press-event', press)

        if release:
            self._release_signal_id = self.connect('key-release-event',
                                                   release)
Ejemplo n.º 7
0
    def resize_paned(paned, rect, relpos):
        """ Resize `~paned` to have its handle at `~relpos`, then disconnect this signal handler.
        Called from the :func:`Gtk.Widget.signals.size_allocate` signal.

        Args:
            paned (:class:`~Gtk.Paned`): Panel whose size has just been allocated, and whose handle needs initial placement.
            rect (:class:`~Gdk.Rectangle`): The rectangle specifying the size that has just been allocated to `~paned`
            relpos (`float`): A number between `0.` and `1.` that specifies the handle position

        Returns:
            `True`
        """
        size = rect.width if paned.get_orientation(
        ) == Gtk.Orientation.HORIZONTAL else rect.height
        handle_pos = int(round(relpos * size))
        GLib.idle_add(paned.set_position, handle_pos)

        sig = GObject.signal_lookup('size-allocate', Gtk.Paned)
        hnd = GObject.signal_handler_find(paned, GObject.SignalMatchType.ID,
                                          sig, 0, None, None, None)
        GObject.signal_handler_disconnect(paned, hnd)
        return True
Ejemplo n.º 8
0
 def stop(self):
     if self.properties_changed_signal:
         GObject.signal_handler_disconnect(self.proxy,
                                           self.properties_changed_signal)
         self.properties_changed_signal = None
     self.proxy = None