File: gtk-hello.scm

package info (click to toggle)
gauche-c-wrapper 0.6.1-18
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,440 kB
  • sloc: ansic: 17,899; sh: 14,025; asm: 6,456; lisp: 5,485; yacc: 2,109; makefile: 520; exp: 194; cpp: 157; objc: 144; perl: 2
file content (45 lines) | stat: -rw-r--r-- 1,373 bytes parent folder | download | duplicates (7)
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
35
36
37
38
39
40
41
42
43
44
45
(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_init 
                  gtk_window_new
                  GTK_WINDOW_TOPLEVEL
                  gtk_signal_connect
                  gtk_main_quit
                  gtk_container_set_border_width
                  gtk_button_new_with_label
                  gtk_container_add
                  gtk_widget_show
                  gtk_main
                  NULL)
        ;;         :import '(#/^gtk_/i 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)