XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL

Brian J. Tarricone bjt23 at cornell.edu
Mon Sep 26 08:33:06 CEST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Erik Harrison wrote:
> For the new panel, is it necessary to have the plugin author drag in
> all of stdlib just to get exit()? Wouldn't it be better to simply
> gtk_main_quit() and fall off of main()? Something like
> 
> void xfce_panel_plugin_exit () {
>     while (gtk_main_level()) {
>         gtk_main_quit();
> }
> 
> and register that as the callback instead of exit().
> 
> The only advantage I see to using exit directly is that the plugin
> author can register stuff to run atexit - but that's a little hacky to
> me anyway, since it doesn't work for internal plugins. A "finalize"
> signal or similar might be better - which could eliminate the loop
> with gtk_main_level by giving plugin authors the chance to kill any
> additional mainloops themselves, and just use gtk_main_quit() as the
> callback directly.

I acutally suggested Jasper change it from using simply gtk_main_quit()
to use exit(), since if the plugin is using, say, gtk_dialog_run() to
show another dialog when the panel tries to exit, the inner main loop
will only quit, and the plugin won't exit.

Using the while() loop won't work either, because gtk_main_quit()
doesn't actually quit the main loop, it just tells it to quit.  So when
gtk_main_level() is called the second time, it'll still have the same
value as it was run the previous time.  I suppose something like:

for(i = 0; i < gtk_main_level(); i++)
    gtk_main_quit();

would work, though.

The problem with using exit(), however, rather than some other means, is
that the plugin itself can't catch its own destruction and do something
interesting (which may not be a bad thing).

Really, though, what's wrong with pulling in stdlib.h?  It adds perhaps
a couple milliseconds to the build process.

	-brian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDN5Yi6XyW6VEeAnsRAr25AJ9CPLiWp3d8YiPIxTrADZpteEFuAACeNoUS
dEqxjDEHUiBQLgdseomimPU=
=ibeq
-----END PGP SIGNATURE-----



More information about the Xfce4-dev mailing list