File: radiobuttons.scm

package info (click to toggle)
gauche-gtk 0.6%2Bgit20160927-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,452 kB
  • sloc: ansic: 7,097; lisp: 5,659; sh: 2,829; makefile: 338
file content (52 lines) | stat: -rw-r--r-- 1,993 bytes parent folder | download | duplicates (3)
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
46
47
48
49
50
51
52
;;
;; Simple example, ported from the one in Gtk+2.0 tutorial.
;;
;; $Id: radiobuttons.scm,v 1.2 2007/01/13 01:36:30 maruska Exp $

(use gtk)

(define (main args)
  (gtk-init args)
  (let1 window (gtk-window-new GTK_WINDOW_TOPLEVEL)
    (g-signal-connect window "delete_event" (lambda _ (gtk-main-quit)))
    (gtk-window-set-title window "radio buttons")
    (gtk-container-set-border-width window 0)
    
    (let1 box1 (gtk-vbox-new #f 0)
      (gtk-container-add window box1)
      (gtk-widget-show box1)
      (let1 box2 (gtk-vbox-new #f 10)
        (gtk-container-set-border-width box2 10)
        (gtk-box-pack-start box1 box2 #t #t 0)
        (gtk-widget-show box2)
        (let1 button1 (gtk-radio-button-new-with-label #f "button1")
          (gtk-box-pack-start box2 button1 #t #t 0)
          (gtk-widget-show button1)
          (let* ((group (gtk-radio-button-get-group button1))
                 (button2 (gtk-radio-button-new-with-label group "button2")))
            (gtk-toggle-button-set-active button2 #t)
            (gtk-box-pack-start box2 button2 #t #t 0)
            (gtk-widget-show button2)
            (let1 button3 (gtk-radio-button-new-with-label-from-widget
                           button2 "button3")
              (gtk-box-pack-start box2 button3 #t #t 0)
              (gtk-widget-show button3))
            )
          )
        )
      (let1 separator (gtk-hseparator-new)
        (gtk-box-pack-start box1 separator #f #t 0)
        (gtk-widget-show separator))
      (let1 box2 (gtk-vbox-new #f 10)
        (gtk-container-set-border-width box2 10)
        (gtk-box-pack-start box1 box2 #f #t 0)
        (gtk-widget-show box2)
        (let1 button (gtk-button-new-with-label "close")
          (g-signal-connect button "clicked" (lambda _ (gtk-main-quit)))
          (gtk-box-pack-start box2 button #t #t 0)
          (gtk-widget-set-flags button GTK_CAN_DEFAULT)
          (gtk-widget-show button)))
      )
    (gtk-widget-show window))
  (gtk-main)
  0)