From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marius Vollmer To: David Pirotte Cc: guile-gtk@sourceware.cygnus.com Subject: Re: gtk-standalone-main Date: Fri, 20 Apr 2001 10:20:00 -0000 Message-id: <87u23jtvzc.fsf@zagadka.ping.de> References: <3ADC0CC6.24373634@altosw.be> <987526914.1339.1.camel@soleil> <20010417225733.A20322@mail.aura.de> <987561319.1538.6.camel@soleil> <3ADDBCDC.5CC236D0@altosw.be> X-SW-Source: 2001-q2/msg00020.html David Pirotte writes: > I think there is a little difference between launching guile and loading the > module gtk or launching guile-gtk. here is an example of what happens on my > machine: > > 1. ;; first launching guile-gtk > david@faust:~/alto/projects/guile/tactus 95 $ guile-gtk > gtk> (use-modules (alto test)) > gtk> (test-gui) > gtk> > > ==> ;; the window is realized and comes to the display normally > > > 2. ;; launching guile > david@faust:~/alto/projects/guile/tactus 93 $ guile > guile> (use-modules (alto test)) > guile> (test-gui) > > ==> ;; nothing happens, until I exit guile > guile> (exit) > ==> ;; the window is realized but of course only remains a fraction > ;; of a second on the screen Yes, this is the intended behaviour. (Or rather, this is what is supposed to happen; it can certainly be improved upon...) `gtk-standalone-main' is supposed to be used by programs that want to start their own event-loop, but only when there isn't one running already. Here are some docs from the NEWS file: * New Scheme function `gtk-standalone?' that returns whether the Guile interpreter is running a Gtk-aware read-eval-print-loop or not. When `(gtk-standalone?)' returns true you should call `gtk-main' or `gtk-exit' from your script at the approriate times. When it returns false, you can assume that someone else will take care of running the Gtk event loops and quitting the interpreter. It would be ideal to arrange things so that gtk-standalone could always return false. I'm not at all sure how to achieve this, tho. * New Scheme function `gtk-standalone-main' that can be used to conditionally run a stand-alone session. gtk-standalone-main TOPLEVEL When (gtk-standlone?) is true: connect gtk-exit to the "destroy" signal of TOPLEVEL and call gtk-main. That is, you would use `gtk-standalone-main' in your code like this: (define-module (alto test) :use-module (gtk gtk)) (export test-gui) (define (test-gui) (let ((window (gtk-window-new 'toplevel)) (button (gtk-button-new-with-label "Hello"))) (gtk-container-add window button) (gtk-signal-connect button "clicked" (lambda () (gtk-widget-destroy window))) (gtk-widget-show-all window) (gtk-standalone-main window))) Alternatively, you can also start the event-loop in its own background thread via (use-modules (gtk threads)) (gtk-threads-ensure-handler) This will launch the event-repl in the background if it isn't running already.