Created
March 13, 2019 20:55
-
-
Save AstraLuma/0391fcacea394ec86836b045ac93fa31 to your computer and use it in GitHub Desktop.
Gio Weirdness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
from gi.repository import GObject | |
from gi.repository import Gio | |
from gi.repository import GLib | |
def runloop(func): | |
@functools.wraps(func) | |
def wrapped(*pargs, **kwargs): | |
func(None) | |
mc = GLib.main_context_default() | |
print(mc) | |
ml = GLib.MainLoop.new(mc, True) | |
print(ml) | |
print("run") | |
ml.run() | |
return wrapped | |
@runloop | |
def main(loop): | |
print("main") | |
vm = Gio.VolumeMonitor.get() | |
for sig in GObject.signal_list_names(Gio.VolumeMonitor): | |
print(sig) | |
vm.connect(sig, functools.partial(print, sig)) | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
from gi.repository import GObject | |
from gi.repository import Gio | |
from gi.repository import GLib | |
def runloop(func): | |
@functools.wraps(func) | |
def wrapped(*pargs, **kwargs): | |
mc = GLib.main_context_default() | |
print(mc) | |
ml = GLib.MainLoop.new(mc, True) | |
print(ml) | |
GLib.idle_add(lambda: func(ml, *pargs, **kwargs)) | |
print("run") | |
ml.run() | |
return wrapped | |
@runloop | |
def main(loop): | |
print("main") | |
vm = Gio.VolumeMonitor.get() | |
for sig in GObject.signal_list_names(Gio.VolumeMonitor): | |
print(sig) | |
vm.connect(sig, functools.partial(print, sig)) | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
from gi.repository import GObject | |
from gi.repository import Gio | |
from gi.repository import GLib | |
def runloop(func): | |
@functools.wraps(func) | |
def wrapped(*pargs, **kwargs): | |
GLib.idle_add(lambda: func(ml, *pargs, **kwargs)) | |
mc = GLib.main_context_default() | |
print(mc) | |
ml = GLib.MainLoop.new(mc, True) | |
print(ml) | |
print("run") | |
ml.run() | |
return wrapped | |
@runloop | |
def main(loop): | |
print("main") | |
vm = Gio.VolumeMonitor.get() | |
for sig in GObject.signal_list_names(Gio.VolumeMonitor): | |
print(sig) | |
vm.connect(sig, functools.partial(print, sig)) | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
from gi.repository import GObject | |
from gi.repository import Gio | |
from gi.repository import GLib | |
vm = Gio.VolumeMonitor.get() | |
for sig in GObject.signal_list_names(Gio.VolumeMonitor): | |
print(sig) | |
vm.connect(sig, functools.partial(print, sig)) | |
mc = GLib.main_context_default() | |
print(mc) | |
ml = GLib.MainLoop.new(mc, True) | |
print(ml) | |
print("run") | |
ml.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment