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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
;;
;; Simple example, ported from the one in Gtk+2.0 tutorial.
;;
;; $Id: buttonbox.scm,v 1.2 2007/01/13 01:36:30 maruska Exp $
(use gtk)
(define (create-bbox horizontal? title spacing child-w child-h layout)
(let ((frame (gtk-frame-new title))
(bbox (if horizontal? (gtk-hbutton-box-new) (gtk-vbutton-box-new))))
(gtk-container-set-border-width bbox 5)
(gtk-container-add frame bbox)
(gtk-button-box-set-layout bbox layout)
(gtk-box-set-spacing bbox spacing)
(let1 button (gtk-button-new-from-stock GTK_STOCK_OK)
(gtk-container-add bbox button))
(let1 button (gtk-button-new-from-stock GTK_STOCK_CANCEL)
(gtk-container-add bbox button))
(let1 button (gtk-button-new-from-stock GTK_STOCK_HELP)
(gtk-container-add bbox button))
frame))
(define (main args)
(gtk-init args)
(let1 window (gtk-window-new GTK_WINDOW_TOPLEVEL)
(gtk-window-set-title window "Button Boxes")
(g-signal-connect window "destroy" (lambda _ (gtk-main-quit)))
(gtk-container-set-border-width window 10)
(let1 main-vbox (gtk-vbox-new #f 0)
(gtk-container-add window main-vbox)
(let1 frame-horz (gtk-frame-new "Horizontal Button Boxes")
(gtk-box-pack-start main-vbox frame-horz #t #t 10)
(let1 vbox (gtk-vbox-new #f 0)
(gtk-container-set-border-width vbox 10)
(gtk-container-add frame-horz vbox)
(gtk-box-pack-start vbox
(create-bbox #t "Spread (spacing 40)" 40 85 20
GTK_BUTTONBOX_SPREAD)
#t #t 0)
(gtk-box-pack-start vbox
(create-bbox #t "Edge (spacing 30)" 30 85 20
GTK_BUTTONBOX_EDGE)
#t #t 5)
(gtk-box-pack-start vbox
(create-bbox #t "Start (spacing 20)" 20 85 20
GTK_BUTTONBOX_START)
#t #t 5)
(gtk-box-pack-start vbox
(create-bbox #t "End (spacing 10)" 10 85 20
GTK_BUTTONBOX_END)
#t #t 5)
))
(let1 frame-vert (gtk-frame-new "Vertical Button Boxes")
(gtk-box-pack-start main-vbox frame-vert #t #t 10)
(let1 hbox (gtk-hbox-new #f 0)
(gtk-container-set-border-width hbox 10)
(gtk-container-add frame-vert hbox)
(gtk-box-pack-start hbox
(create-bbox #f "Spread (spacing 5)" 5 85 20
GTK_BUTTONBOX_SPREAD)
#t #t 0)
(gtk-box-pack-start hbox
(create-bbox #f "Edge (spacing 30)" 30 85 20
GTK_BUTTONBOX_EDGE)
#t #t 5)
(gtk-box-pack-start hbox
(create-bbox #f "Start (spacing 20)" 20 85 20
GTK_BUTTONBOX_START)
#t #t 5)
(gtk-box-pack-start hbox
(create-bbox #f "End (spacing 10)" 20 85 20
GTK_BUTTONBOX_END)
#t #t 5)
))
(gtk-widget-show-all window)))
(gtk-main)
0)
|