File: gtk-hello.scm

package info (click to toggle)
gauche-c-wrapper 0.5.4-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,892 kB
  • ctags: 2,869
  • sloc: ansic: 14,863; sh: 14,017; lisp: 6,822; asm: 6,456; makefile: 541; exp: 194; cpp: 157; objc: 144; perl: 2
file content (34 lines) | stat: -rw-r--r-- 988 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(use c-wrapper)

(c-load "gtk/gtk.h"
        :cppflags-cmd "pkg-config gtk+-2.0 --cflags-only-I"
        :cflags-cmd   "pkg-config gtk+-2.0 --cflags-only-other"
        :libs-cmd     "pkg-config gtk+-2.0 --libs"
        :import '(#/^gtk_/ #/^GTK_/ NULL)
        :compiled-lib "gtklib")

(define (main args)
  (let ((argc (make <c-int>)))
    (gtk_init (ptr argc) (make-null-ptr)))
  (let1 window (gtk_window_new GTK_WINDOW_TOPLEVEL)
    (gtk_signal_connect window
			"destroy"
			(lambda _
			  (format #t "Destroying\n")
			  (gtk_main_quit)
                          NULL)
			(make-null-ptr))
    (gtk_container_set_border_width window 10)
    (let1 button (gtk_button_new_with_label "Hello world")
      (gtk_signal_connect button
			  "clicked"
			  (lambda _
			      (format #t "Hello world\n")
                              NULL)
			  (make-null-ptr))
      (gtk_container_add window button)
      (gtk_widget_show button)
      (gtk_widget_show window)
      ))
  (gtk_main)
  0)