[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Perlpanel-devel] catching applet exceptions
From: |
Moshe Kaminsky |
Subject: |
Re: [Perlpanel-devel] catching applet exceptions |
Date: |
Mon, 12 Jul 2004 23:51:29 +0300 |
User-agent: |
Mutt/1.5.6i |
Hi,
* Gavin Brown <address@hidden> [12/07/04 14:57]:
> Moshe wrote:
>
> > As I wrote in another mail, I think perlpanel has a problem with
> > exceptions caused in the applets code.
> > Naturally, not all applets handle all exceptions that arise in their
> > code. When such an exception happens, it crashes the whole panel. This
> > is unfortunate, especially since there is always new applet code to
> > test.
>
> I think this is less of a problem for a "standard user", who will only
> use the applets that ship with PerlPanel.
Is that really the way you would like it to be? I thought there would be
some web location where people could contribute their applets. Writing
an applet is an easy task, probably many would be contributed by various
people.
> It is my hope and aim that all
> the applets behave well regarding exceptions, so that such a user will
> never see one.
This might not be that easy. After all, it's interactive. It is
certainly not the situation today.
>
> As for those people testing new applet code, I hope they'd find the
> crashes annoying enough to fix the code :p
>
> > I believe there is a way to solve it, but I don't know enough about
> > gtk/glib to know for sure: As far as I understand, all applets are
> > children of an hbox. What I thought is to put this hbox inside a
> > Gtk2::EventBox. Now, this widget has a method set_above_child, which
> > allows it (as I understand it) to get all signals (button clicks, etc.),
> > instead of the hbox. This EventBox will then pass the signal to the hbox
> > child inside an eval block, thus trapping exceptions that occur in the
> > callbacks. In addition, all methods such as configure,
> > get_default_config, etc. should also, of course, be called inside an
> > eval.
>
> I agree absolutely about the configure() and get_default_config() calls,
> and I will probably sort that out today.
>
> As for the event box magic, I'm pretty sure that your proposal wouldn't
> reliably work, since an error be raised at any moment (due to a
> Glib::Timeout, or a thread or any other of the asynchronous ways that
> Perl can do stuff) and might not necessarily be captured by gtk2-perl's
> exception system.
I guess it won't cover all cases, but I think that typically you'll
either have a signal or a timeout. For the timeouts, I think the
simplest is to add a timeout method to PerlPanel::Applet, and ask applet
writers to use it for timeouts. This will solve the exceptions problem,
and will also give a slightly higher level layer above Glib. (By the
way, is it true that applets are supposed to derive from
PerlPanel::Applet?)
>
> It's definitely something worth thinking about though. gnome-panel's
> approach is to run a lot of the applets as separate processes and use
> XEMBED, but I'm not a big fan of that technique, since it clutters up
> 'ps'.
>
> > The only thing is, I don't know if it's possible to install a "universal
> > callback" for all signals, and how can one pass the signal to another
> > widget.
>
> There is the 'event' signal, but I've never been able to do anything
> useful with it. Attaching a handler to it just seems to freeze the
> application.
I guess that actually, taking over a few signals, such as the button
clicks and button strokes should be enough. Of course, if someone really
wants to break the application, he probably can.
BTW, I think that the method that can be used for passing the signal to
the child is Glib::Object->signal_emit (is there some searchable version
of the glib/gtk docs?).
I've just stumbled upon the Glib::Signal manpage. It appears there is a
builtin way of doing all of this, using Glib->install_exception_handler
(at least that's how it reads to me). I wasn't able to get it to work,
though.
Moshe
>
> Gavin.
>
> --
> Gavin Brown
> e: address@hidden
> w: http://jodrell.net/
> PGP/GPG key ID: 891D8FCA
>
>
>
> _______________________________________________
> Perlpanel-devel mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/perlpanel-devel
>
--
I love deadlines. I like the whooshing sound they make as they fly by.
-- Douglas Adams
Moshe Kaminsky <address@hidden>
Home: 08-9456841
pgpnCjOkxu5js.pgp
Description: PGP signature