How to use the gbulb.glib_events.GLibEventLoopPolicy function in gbulb

To help you get started, we’ve selected a few gbulb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github davidedmundson / telepathy-hangups / gbulb / glib_events.py View on Github external
return self._default_loop

    def _new_default_loop(self):
        return GLibEventLoop(GLib.main_context_default())


if Gtk:
    class GtkEventLoopPolicy(GLibEventLoopPolicy):
        def __init__(self, *, full=False, threads=True):
            super().__init__ (default=True, full=full, threads=threads)

        def _new_default_loop(self):
            return GLibEventLoop(gtk=True)

class GApplicationEventLoopPolicy(GLibEventLoopPolicy):
    def __init__(self, *, full=False, threads=True):
        super().__init__ (default=True, full=full, threads=threads)

class wait_signal (futures.Future):
    def __init__(self, obj, name, *, loop=None):
        super().__init__(loop=loop)
        self._obj = obj
        #FIXME: use  a weakref ?
        self._hnd = obj.connect(name, self._signal_callback)

    def _signal_callback(self, *k):
        self._obj.disconnect(self._hnd)
        self.set_result(k)

    def cancel(self):
        super().cancel()
github davidedmundson / telepathy-hangups / gbulb / glib_events.py View on Github external
def get_default_loop(self):

        if not self._default_loop:
            if not self._default:
                raise RuntimeError("%s configured not to used a default loop" % self.__class__.__name__)

            self._default_loop = self._new_default_loop()

        return self._default_loop

    def _new_default_loop(self):
        return GLibEventLoop(GLib.main_context_default())


if Gtk:
    class GtkEventLoopPolicy(GLibEventLoopPolicy):
        def __init__(self, *, full=False, threads=True):
            super().__init__ (default=True, full=full, threads=threads)

        def _new_default_loop(self):
            return GLibEventLoop(gtk=True)

class GApplicationEventLoopPolicy(GLibEventLoopPolicy):
    def __init__(self, *, full=False, threads=True):
        super().__init__ (default=True, full=full, threads=threads)

class wait_signal (futures.Future):
    def __init__(self, obj, name, *, loop=None):
        super().__init__(loop=loop)
        self._obj = obj
        #FIXME: use  a weakref ?
        self._hnd = obj.connect(name, self._signal_callback)