| 1 |
=head1 NAME |
| 2 |
|
| 3 |
EV::Glib - Embed the glib main loop into EV |
| 4 |
|
| 5 |
=head1 SYNOPSIS |
| 6 |
|
| 7 |
use EV::Glib; |
| 8 |
|
| 9 |
=head1 DESCRIPTION |
| 10 |
|
| 11 |
If you want to use EV in a Glib/Gtk+ program, then you need to look at |
| 12 |
the Glib::EV module, not this one, as this module requires you to run EV |
| 13 |
in your main program. |
| 14 |
|
| 15 |
If you want to use Glib/Gtk+ in an EV program, you are at the right place |
| 16 |
here. |
| 17 |
|
| 18 |
This module embeds the Glib main loop into EV, that is, EV will also handle |
| 19 |
Glib events. |
| 20 |
|
| 21 |
This makes Glib compatible to EV. Calls into the EV main loop are more |
| 22 |
or less equivalent to calls to Glib::MainLoop (but not vice versa, you |
| 23 |
I<have> to use the EV loop functions). |
| 24 |
|
| 25 |
=over 4 |
| 26 |
|
| 27 |
=item * The Glib perl module is not used. |
| 28 |
|
| 29 |
This module has no dependency on the existing Glib perl interface, as it |
| 30 |
uses glib directly. The Glib module can, however, be used without any |
| 31 |
problems (as long as everybody uses shared libraries to keep everybody |
| 32 |
else happy). |
| 33 |
|
| 34 |
=item * The default context will be added to EV when the module is loaded. |
| 35 |
|
| 36 |
Loading this module will automatically integrate the default context into |
| 37 |
EV, so normally nothing else is required. |
| 38 |
|
| 39 |
=item * There will be no g_main_loop or gtk_main loop available. |
| 40 |
|
| 41 |
The EV event loop is not the gtk+ main loop. That means that things like |
| 42 |
C<gtk_main_quit> will not work at all, as there is no glib mainloop. You |
| 43 |
I<have> to use EV's equivalents, i.e. C<EV::unloop>. |
| 44 |
|
| 45 |
=item * You cannot call any glib loop functions while its context is active. |
| 46 |
|
| 47 |
This module uses a prepare watcher at lowest priority to dispatch glib |
| 48 |
events and activate the main context. The context will be deactivated in a |
| 49 |
check watcher of highest priority. |
| 50 |
|
| 51 |
That means that glib events will be dispatched with lowest priority, and |
| 52 |
that you cannot call any glib main functions (or functions calling it) on |
| 53 |
the default mainloop in highest-priority watchers and in lowest-priority |
| 54 |
prepare watchers. |
| 55 |
|
| 56 |
=item * EV::Glib watchers will (currently) keep the mainloop alive. |
| 57 |
|
| 58 |
That means that, after loading this module, C<EV::loop> calls will never |
| 59 |
return unless you call C<EV::unloop> explicitly. Future versions might fix |
| 60 |
this problem so that Glib keeps the EV loop alive only when it has active |
| 61 |
events waiting. |
| 62 |
|
| 63 |
=cut |
| 64 |
|
| 65 |
package EV::Glib; |
| 66 |
|
| 67 |
use Carp (); |
| 68 |
use EV (); |
| 69 |
|
| 70 |
BEGIN { |
| 71 |
$VERSION = '2.01'; |
| 72 |
|
| 73 |
require XSLoader; |
| 74 |
XSLoader::load (EV::Glib, $VERSION); |
| 75 |
|
| 76 |
install (undef); |
| 77 |
} |
| 78 |
|
| 79 |
=back |
| 80 |
|
| 81 |
=cut |
| 82 |
|
| 83 |
=head1 BUGS |
| 84 |
|
| 85 |
* No documented API to use other main contexts. |
| 86 |
|
| 87 |
=head1 SEE ALSO |
| 88 |
|
| 89 |
L<EV>, L<Glib::EV>, L<Glib>, L<Glib::MainLoop>. |
| 90 |
|
| 91 |
=head1 AUTHOR |
| 92 |
|
| 93 |
Marc Lehmann <schmorp@schmorp.de> |
| 94 |
http://home.schmorp.de/ |
| 95 |
|
| 96 |
=cut |
| 97 |
|
| 98 |
1 |
| 99 |
|