~ubuntu-branches/ubuntu/lucid/gauche-c-wrapper/lucid

« back to all changes in this revision

Viewing changes to examples/gtk/gtk-hello.scm

  • Committer: Bazaar Package Importer
  • Author(s): NIIBE Yutaka
  • Date: 2008-04-07 09:15:03 UTC
  • Revision ID: james.westby@ubuntu.com-20080407091503-wu0h414koe95kj4i
Tags: upstream-0.5.2
ImportĀ upstreamĀ versionĀ 0.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(use c-wrapper)
 
2
 
 
3
(c-load "gtk/gtk.h"
 
4
        :cppflags-cmd "pkg-config gtk+-2.0 --cflags-only-I"
 
5
        :cflags-cmd   "pkg-config gtk+-2.0 --cflags-only-other"
 
6
        :libs-cmd     "pkg-config gtk+-2.0 --libs"
 
7
        :import '(#/^gtk_/ #/^GTK_/ NULL)
 
8
        :compiled-lib "gtklib")
 
9
 
 
10
(define (main args)
 
11
  (let ((argc (make <c-int>)))
 
12
    (gtk_init (ptr argc) (make-null-ptr)))
 
13
  (let1 window (gtk_window_new GTK_WINDOW_TOPLEVEL)
 
14
    (gtk_signal_connect window
 
15
                        "destroy"
 
16
                        (lambda _
 
17
                          (format #t "Destroying\n")
 
18
                          (gtk_main_quit)
 
19
                          NULL)
 
20
                        (make-null-ptr))
 
21
    (gtk_container_set_border_width window 10)
 
22
    (let1 button (gtk_button_new_with_label "Hello world")
 
23
      (gtk_signal_connect button
 
24
                          "clicked"
 
25
                          (lambda _
 
26
                              (format #t "Hello world\n")
 
27
                              NULL)
 
28
                          (make-null-ptr))
 
29
      (gtk_container_add window button)
 
30
      (gtk_widget_show button)
 
31
      (gtk_widget_show window)
 
32
      ))
 
33
  (gtk_main)
 
34
  0)