Re: automation
- From: Scott Lanning <lannings who int>
- To: gtk-perl-list gnome org
- Cc: muppet <scott asofyet org>
- Subject: Re: automation
- Date: Sun, 18 Sep 2005 15:49:40 +0200 (CEST)
On Fri, 16 Sep 2005, muppet wrote:
In the Gtk2 et al test suites, we usually use single-shot idles to handle
this sort of thing.
Glib::Idle->add (sub {
$button->clicked;
Gtk2->main_quit;
FALSE;
});
Gtk2->main;
You can get pretty nutty when you start nesting and chaining these things,
so i recommend creating a wrapper API for it. In Gtk2::TestHelper there are
run_main(), ok_idle() and is_idle() for this purpose.
Thanks, but I'm having trouble with `run_main' (Gtk2::TestHelper),
because it just opens the window without allowing the widget inside
to display. I figured out that it's because Gtk2->main_quit is being
called before enough iterations of the main loop are done. For example,
putting this after `main_quit' allows it to display fully:
$n = 1000; # 500 was insufficient, though
Gtk2->main_iteration_do(0) while $n-- > 0;
I don't want to guess how many iterations need to be done, though.
I tried following `run_main' with another one-shot, thinking it would
wait until it was idle again before quitting,
Glib::Idle->add(sub {
Gtk2->main_quit;
FALSE;
});
Gtk2->main;
and sometimes it works, but sometimes it doesn't... :/
sub run_main (;&) {
my $callback = shift;
Glib::Idle->add(sub {
if ($callback) {
print "Entering run_main shutdown callback\n";
$callback->();
print "Leaving run_main shutdown callback\n";
}
print "Doing main_quit\n";
Gtk2->main_quit;
FALSE; # uninstall this callback
});
print "Entering main loop\n";
Gtk2->main;
print "Leaving main loop\n";
# Try to let the display complete
Glib::Idle->add(sub {
print "Doing main_quit again\n";
Gtk2->main_quit;
FALSE;
});
print "Entering main loop again\n";
Gtk2->main;
print "Leaving main loop again\n";
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]