… | |
… | |
3 | |
3 | |
4 | SYNOPSIS |
4 | SYNOPSIS |
5 | use Glib::Event; |
5 | use Glib::Event; |
6 | |
6 | |
7 | # example with Gtk2: |
7 | # example with Gtk2: |
8 | use Gtk2; |
8 | use Gtk2 -init; |
9 | use Glib::Event; |
9 | use Glib::Event; |
10 | use Event; # any order |
10 | use Event; # any order |
11 | Event->timer (after => 1, interval => 1, cb => sub { print "I am here!\n" }); |
11 | Event->timer (after => 1, interval => 1, cb => sub { print "I am here!\n" }); |
12 | main Gtk2; |
12 | main Gtk2; |
13 | # etc., it just works |
13 | # etc., it just works |
|
|
14 | |
|
|
15 | # You can even move the glib mainloop into a coroutine: |
|
|
16 | use Gtk2 -init; |
|
|
17 | use Coro; |
|
|
18 | use Coro::Event; |
|
|
19 | use Glib::Event; |
|
|
20 | async { main Gtk2 }; |
|
|
21 | # ... do other things |
14 | |
22 | |
15 | DESCRIPTION |
23 | DESCRIPTION |
16 | This module coerces the Glib event loop to use the Event module as |
24 | This module coerces the Glib event loop to use the Event module as |
17 | underlying event loop, i.e. Event will be used by Glib for all events. |
25 | underlying event loop, i.e. Event will be used by Glib for all events. |
18 | |
26 | |
… | |
… | |
26 | |
34 | |
27 | * The default context will be changed when the module is loaded. |
35 | * The default context will be changed when the module is loaded. |
28 | Loading this module will automatically "patch" the default context |
36 | Loading this module will automatically "patch" the default context |
29 | of libglib, so normally nothing more is required. |
37 | of libglib, so normally nothing more is required. |
30 | |
38 | |
|
|
39 | * Glib does not allow recursive invocations. |
|
|
40 | This means that none of your event watchers might call into Glib |
|
|
41 | functions or functions that might call glib functions (basically all |
|
|
42 | Gtk2 functions). It might work, but that's your problem.... |
|
|
43 | |
31 | BUGS |
44 | BUGS |
32 | * No documented API to patch other main contexts. |
45 | * No documented API to patch other main contexts. |
33 | * Uses one_event, which is inefficient. |
46 | * Uses one_event, which is inefficient. |
34 | |
47 | |
35 | SEE ALSO |
48 | SEE ALSO |