1#! /bin/sh 2# -*- scheme -*- 3exec guile-gnome-2 -s $0 "$@" 4!# 5;; guile-gnome 6;; Copyright (C) 2003,2004 Free Software Foundation, Inc. 7 8;; This program is free software; you can redistribute it and/or 9;; modify it under the terms of the GNU General Public License as 10;; published by the Free Software Foundation; either version 2 of 11;; the License, or (at your option) any later version. 12;; 13;; This program is distributed in the hope that it will be useful, 14;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16;; GNU General Public License for more details. 17;; 18;; You should have received a copy of the GNU General Public License 19;; along with this program; if not, contact: 20;; 21;; Free Software Foundation Voice: +1-617-542-5942 22;; 59 Temple Place - Suite 330 Fax: +1-617-542-2652 23;; Boston, MA 02111-1307, USA gnu@gnu.org 24 25 26(use-modules (oop goops) (gnome gobject) (gnome gtk)) 27 28;; define the hello as a function -- there are many other ways to do this, 29;; of course... 30(define (hello) 31 ;; we can make new widgets just like we make goops objects -- there is 32 ;; a corresponding goops class for every GType we know about. the 33 ;; arguments to make, after the class, are interpreted as properties 34 ;; to set. in this case we make a toplevel window and a button with 35 ;; the label, "Hello, World!". 36 (let* ((window (make <gtk-window> #:type 'toplevel)) 37 (button (make <gtk-button> #:label "Hello, World!"))) 38 39 ;; there are scheme functions corresponding to all of the c ones... 40 ;; and of course we don't have to cast anything. 41 (gtk-container-set-border-width window 10) 42 (gtk-container-add window button) 43 44 ;; and of course you can attach a lambda to a signal :-) 45 (gtype-instance-signal-connect button 'clicked (lambda (b) (gtk-main-quit))) 46 47 (gtk-widget-show-all window) 48 49 ;; this will block until gtk-main-quit is called... 50 (gtk-main))) 51 52;; meaning this blocks until the button is clicked. 53(hello) 54