public inbox for guile-gtk@sourceware.org
 help / color / mirror / Atom feed
* gtk-standalone-main
@ 2001-08-21 17:17 David Pirotte
  0 siblings, 0 replies; 7+ messages in thread
From: David Pirotte @ 2001-08-21 17:17 UTC (permalink / raw)
  To: guile-gtk, guile-user

well,

now that i use

	guile 1.5.1
	gnome-guile-0.21pre2

and since compiling/installing gnome-guile-0.21pre2 does not produce a
guile-gtk binary, i am facing and 'old problem':
	
	guile requires the use of (gtk-standalone-main window) in order to 
	properly realize the window

	but that is incompatible with a devel cycle, since destroying the
	window also destroys the environment ...

so, what can i do? Marius suggested once to use
	
	(use-modules (gtk threads))
    	(gtk-threads-ensure-handler)

but i first of all it is broken (see below) and second, i don't know 
where to use (gtk-threads-ensure-handler), if it should be in the gui
code or typed in the guile listener ?

so, thanks for some hints on this one
david

;;
david@faust:~/alto/projects/guile/share/alto 31 $ guile
guile> (use-modules (gtk threads))
guile> (gtk-threads-ensure-handler)
/usr/local/share/guile/gtk/threads.scm:15:7: In expression (call-with-new-thread (lambda () #) %thread-handler):
/usr/local/share/guile/gtk/threads.scm:15:7: Unbound variable: call-with-new-thread
ABORT: (unbound-variable)

Type "(backtrace)" to get more information or "(debug)" to enter the debugger.
guile>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gtk-standalone-main
  2001-04-18  8:10       ` gtk-standalone-main David Pirotte
@ 2001-04-20 10:20         ` Marius Vollmer
  0 siblings, 0 replies; 7+ messages in thread
From: Marius Vollmer @ 2001-04-20 10:20 UTC (permalink / raw)
  To: David Pirotte; +Cc: guile-gtk

David Pirotte <david@altosw.be> 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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gtk-standalone-main
  2001-04-17 21:29     ` gtk-standalone-main Ariel Rios
@ 2001-04-18  8:10       ` David Pirotte
  2001-04-20 10:20         ` gtk-standalone-main Marius Vollmer
  0 siblings, 1 reply; 7+ messages in thread
From: David Pirotte @ 2001-04-18  8:10 UTC (permalink / raw)
  To: Ariel Rios; +Cc: rm, guile-gtk

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1803 bytes --]

Ariel Rios wrote:
> 
> El 17 Apr 2001 22:57:33 +0200, rm@mamma.varadinet.de escribió:
> > On Tue, Apr 17, 2001 at 01:01:54PM -0400, Ariel Rios wrote:
> 
> > Not on my system, unfortunately ;-(
> > The call to gtk-widget-show-all will return 1 but
> > no widget apears on the screen. Only after the call
> > to gtk-standalone-main does the widget show.
> Which is your platform, guile-gtk and guile's version?

I had exactly the same problem and I was going to post a message, as I now
understand why I was unabble to discover by myself the solution Ariel proposed

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

hope it helps
david


;; assuming the module (alto test) contains the following
(define-module (alto test)

  ;; from distribution
  ;; :use-module (database postgres)
  ;; :use-module (ice-9 format)
  :use-module (gtk gtk)

  ;; from alto
  ;; :use-module (alto gtk-utils)

  )

(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)
    ))

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gtk-standalone-main
       [not found]   ` <20010417225733.A20322@mail.aura.de>
@ 2001-04-17 21:29     ` Ariel Rios
  2001-04-18  8:10       ` gtk-standalone-main David Pirotte
  0 siblings, 1 reply; 7+ messages in thread
From: Ariel Rios @ 2001-04-17 21:29 UTC (permalink / raw)
  To: rm; +Cc: guile-gtk

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 384 bytes --]

El 17 Apr 2001 22:57:33 +0200, rm@mamma.varadinet.de escribió:
> On Tue, Apr 17, 2001 at 01:01:54PM -0400, Ariel Rios wrote:

> Not on my system, unfortunately ;-(
> The call to gtk-widget-show-all will return 1 but
> no widget apears on the screen. Only after the call
> to gtk-standalone-main does the widget show.
Which is your platform, guile-gtk and guile's version?

ariel
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gtk-standalone-main
  2001-04-17 11:56 ` gtk-standalone-main Ariel Rios
@ 2001-04-17 13:59   ` David Pirotte
       [not found]   ` <20010417225733.A20322@mail.aura.de>
  1 sibling, 0 replies; 7+ messages in thread
From: David Pirotte @ 2001-04-17 13:59 UTC (permalink / raw)
  To: Ariel Rios; +Cc: guile-gtk

Ariel Rios wrote:

> ...
> Which enables you to play w/guile-gtk from your guile prompt

many thanks
david

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gtk-standalone-main
  2001-04-17  1:27 gtk-standalone-main David Pirotte
@ 2001-04-17 11:56 ` Ariel Rios
  2001-04-17 13:59   ` gtk-standalone-main David Pirotte
       [not found]   ` <20010417225733.A20322@mail.aura.de>
  0 siblings, 2 replies; 7+ messages in thread
From: Ariel Rios @ 2001-04-17 11:56 UTC (permalink / raw)
  To: David Pirotte; +Cc: guile-gtk

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1170 bytes --]

El 17 Apr 2001 11:28:38 +0200, David Pirotte escribió:
 
> I'd like to launch guile (or guile-gtk) 'manually', in order to
> have a listener that remains active while I am working and:
> 
>       1. launching a little gtk app in a way that I can still
>          type things in the listener from where I launched it
>          so I can 'get 'set widgets and learn ...
>          (is there another way then: gtk-standalone-main ?)
> 
>       2. avoiding that hitting the 'destroy provoques the guile
>          listener exit as well: I tried the following:
> 
>          (gtk-signal-connect window "destroy" gtk-false)
> 
>          but as the little app is launched with gtk-standalone-main,
>          it appears not to be sufficient
In this case, avoid using gtk-standalone-main.
You can do, for eg:

(define window (gtk-window-new 'toplevel))
(define button (gtk-button-new-with-label "Hello"))
(gtk-container-add window button)
(gtk-widget-show-all window)
(gtk-widget-hide-all window)
(gtk-signal-connect button "clicked" (lambda () (gtk-widget-destroy
window))
(gtk-widget-show-all window)

Which enables you to play w/guile-gtk from your guile prompt

ariel  

^ permalink raw reply	[flat|nested] 7+ messages in thread

* gtk-standalone-main
@ 2001-04-17  1:27 David Pirotte
  2001-04-17 11:56 ` gtk-standalone-main Ariel Rios
  0 siblings, 1 reply; 7+ messages in thread
From: David Pirotte @ 2001-04-17  1:27 UTC (permalink / raw)
  To: guile-gtk

Hello,

Could someone be kind enough to help me with the following beginner
request:

I'd like to launch guile (or guile-gtk) 'manually', in order to
have a listener that remains active while I am working and:

	1. launching a little gtk app in a way that I can still
	   type things in the listener from where I launched it
	   so I can 'get 'set widgets and learn ...
	   (is there another way then: gtk-standalone-main ?)

	2. avoiding that hitting the 'destroy provoques the guile
	   listener exit as well: I tried the following:

	   (gtk-signal-connect window "destroy" gtk-false)

	   but as the little app is launched with gtk-standalone-main,
	   it appears not to be sufficient

Thanks a lot
david

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2001-08-21 17:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-21 17:17 gtk-standalone-main David Pirotte
  -- strict thread matches above, loose matches on Subject: below --
2001-04-17  1:27 gtk-standalone-main David Pirotte
2001-04-17 11:56 ` gtk-standalone-main Ariel Rios
2001-04-17 13:59   ` gtk-standalone-main David Pirotte
     [not found]   ` <20010417225733.A20322@mail.aura.de>
2001-04-17 21:29     ` gtk-standalone-main Ariel Rios
2001-04-18  8:10       ` gtk-standalone-main David Pirotte
2001-04-20 10:20         ` gtk-standalone-main Marius Vollmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).