Re: gtk2-perl
- From: Guillaume Cottenceau <gc mandrakesoft com>
- To: muppet <scott asofyet org>
- Cc: gtk-perl-list gnome org
- Subject: Re: gtk2-perl
- Date: 17 Oct 2002 10:14:03 +0200
muppet <scott asofyet org> writes:
[*] When clicking on the button of "compile-widgets.pl", the
application doesn't quit; it prints:
(compile-widgets.pl:30122): Gtk-CRITICAL **: file ../../gtk/gtkmain.c: line 994 (gtk_main_quit): assertion
`main_loops != NULL' failed
it's just the way the events are being handled. i have some code
that uses gtk in a single-threaded, non-event-loop-driven
environment (gtk for visualization of algorithm development...
it's not pretty, but it gets the job done), and i get that a lot.
you clicked on the button while the event loop was not active,
namely, while the app was busy compiling.
Ok, I got it now. Sorry. It's just because gtk_main_quit() is not
called from within a gtk_main() call, that's all :).
So the compile-widgets.pl could maybe be modified with the
following patch (it's maybe a bit tricky to redefine a function
but hey we're using perl ;p):
--- /tmp/compile-widgets.pl 2002-10-17 10:12:14.000000000 +0200
+++ compile-widgets.pl 2002-10-17 10:12:43.000000000 +0200
@@ -26,9 +26,13 @@
sub FALSE { 0 }
sub TRUE { 1 }
+# we use two functions so that we can redefine the implementation when compilation is finished
+sub real_close_app {
+ print "- interrupted\n";
+ exit 0;
+}
sub close_application {
- Gtk2->quit;
- return FALSE;
+ real_close_app();
}
Gtk2->init(\ ARGV);
@@ -46,8 +50,8 @@
$label->show;
Gtk2::GSignal->connect($button, "clicked", \&close_application);
-Gtk2::GSignal->connect($window, "destroy", sub { Gtk2->quit; }, 0);
-Gtk2::GSignal->connect($window, "delete_event", sub { Gtk2->quit; }, 0);
+Gtk2::GSignal->connect($window, "destroy", \&close_application);
+Gtk2::GSignal->connect($window, "delete_event", \&close_application);
$window->show;
@@ -69,6 +73,8 @@
print " - DONE\n";
$button->set_label("All widgets are compiled - click to quit");
+undef *real_close_app;
+*real_close_app = sub { Gtk2->quit };
# Rest in gtk_main and wait for the fun to begin!
Gtk2->main;
0;
--
Guillaume Cottenceau - http://people.mandrakesoft.com/~gc/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]