miscellaneous classes, containers, child properties
[cl-gtk2.git] / gtk / gtk.demo.lisp
1 (defpackage :gtk-demo
2   (:use :cl :gtk :gdk :gobject :anaphora :iter)
3   (:export #:test
4            #:test-entry
5            #:table-packing
6            #:test-pixbuf
7            #:test-image
8            #:test-progress-bar
9            #:test-status-bar
10            #:test-scale-button
11            #:test-text-view
12            #:demo-code-editor
13            #:test-treeview-list
14            #:test-combobox
15            #:test-toolbar
16            #:test-ui-manager
17            #:test-color-button
18            #:test-color-selection
19            #:test-file-chooser
20            #:test-font-chooser
21            #:test-notebook
22            #:test-calendar
23            #:test-box-child-property))
24
25 (in-package :gtk-demo)
26
27 (defun test ()
28   (let ((window (make-instance 'gtk-window :type :toplevel :app-paintable t))
29         x y)
30     (g-signal-connect window "destroy" (lambda (widget)
31                                          (release widget)
32                                          (gtk-main-quit)))
33     (g-signal-connect window "motion-notify-event" (lambda (widget event)
34                                                      (release widget)
35                                                      (setf x (event-motion-x event)
36                                                            y (event-motion-y event))
37                                                      (gtk-widget-queue-draw window)))
38     (g-signal-connect window "expose-event"
39                       (lambda (widget event)
40                         (declare (ignore event))
41                         (release widget)
42                         ;(print event)
43                         (using* ((gdk-window (widget-window window))
44                                  (gc (gdk-gc-new gdk-window))
45                                  (layout (gtk-widget-create-pango-layout window (format nil "X: ~F~%Y: ~F" x y))))
46                           (gdk-draw-layout gdk-window gc 0 0 layout)
47                           (gdk-gc-set-rgb-fg-color gc (make-color :red 65535 :green 0 :blue 0))
48                           (multiple-value-bind (x y) (drawable-get-size gdk-window)
49                             (gdk-draw-line gdk-window gc 0 0 x y)))))
50     (g-signal-connect window "configure-event"
51                       (lambda (widget event)
52                         (declare (ignore event))
53                         (release widget)
54                         (gtk-widget-queue-draw window)))
55     (gtk-widget-show-all window)
56     (push :pointer-motion-mask (gdk-window-events (widget-window window)))
57     (gtk-main)
58     (release window)))
59
60 (defun test-entry ()
61   (using* ((window (make-instance 'gtk-window :type :toplevel :title "Testing entry" :border-width 10))
62            (box (make-instance 'v-box))
63            (entry (make-instance 'entry))
64            (button (make-instance 'button :label "OK"))
65            (text-buffer (make-instance 'text-buffer))
66            (text-view (make-instance 'text-view :buffer text-buffer))
67            (button-select (make-instance 'button :label "Select"))
68            (button-insert (make-instance 'button :label "Insert")))
69     (box-pack-start box (make-instance 'label :label "Enter <b>anything</b> you wish:" :use-markup t) :expand nil)
70     (box-pack-start box entry :expand nil)
71     (box-pack-start box button :expand nil)
72     (box-pack-start box button-select :expand nil)
73     (box-pack-start box button-insert :expand nil)
74     (using* ((w (make-instance 'scrolled-window)))
75       (box-pack-start box w)
76       (container-add w text-view))
77     (container-add window box)
78     (g-signal-connect window "destroy" (lambda (widget) (release widget) (gtk-main-quit)))
79     (g-signal-connect window "delete-event" (lambda (widget event)
80                                               (declare (ignore event))
81                                               (release widget)
82                                               (using (dlg (make-instance 'message-dialog :text "Are you sure?" :buttons :yes-no))
83                                                 (let ((response (dialog-run dlg)))
84                                                   (object-destroy dlg)
85                                                   (not (eq :yes response))))))
86     (g-signal-connect button "clicked" (lambda (button) (release button)
87                                                (setf (text-buffer-text text-buffer)
88                                                      (format nil "~A~%~A" (text-buffer-text text-buffer) (entry-text entry))
89                                                      (entry-text entry) "")))
90     (g-signal-connect button-select "clicked" (lambda (button) (release button)
91                                                (editable-select-region entry 5 10)))
92     (g-signal-connect button-insert "clicked" (lambda (button) (release button)
93                                                       (editable-insert-text entry "hello" 2)))
94     (gtk-widget-show-all window)
95     (gtk-main)))
96
97 (defun table-packing ()
98   (using* ((window (make-instance 'gtk-window :type :toplevel :title "Table packing" :border-width 20))
99            (table (make-instance 'table :n-rows 2 :n-columns 2 :homogeneous t))
100            (button-1 (make-instance 'button :label "Button 1"))
101            (button-2 (make-instance 'button :label "Button 2"))
102            (button-q (make-instance 'button :label "Quit")))
103     (container-add window table)
104     (table-attach table button-1 0 1 0 1)
105     (table-attach table button-2 1 2 0 1)
106     (table-attach table button-q 0 2 1 2)
107     (g-signal-connect window "destroy" (lambda (w) (release w) (gtk-main-quit)))
108     (g-signal-connect button-q "clicked" (lambda (b) (release b) (object-destroy window)))
109     (gtk-widget-show-all window)
110     (gtk-main)))
111
112 (defun test-pixbuf ()
113   (using* ((window (make-instance 'gtk-window :title "Test pixbuf" :request-width 600 :request-height 240))
114            (vbox (make-instance 'v-box))
115            (eventbox (make-instance 'event-box))
116            (vbox-1 (make-instance 'v-box)))
117     (container-add window vbox)
118     (box-pack-start vbox (make-instance 'label :text "Placing bg image" :font "Times New Roman Italic 10" :color "#00f" :request-height 40))
119     (g-signal-connect window "destroy" (lambda (w) (release w) (gtk-main-quit)))
120     (box-pack-start vbox eventbox)
121     (container-add eventbox vbox-1)
122     (box-pack-start vbox-1 (make-instance 'label :text "This is the eventbox"))
123     (box-pack-start vbox-1 (make-instance 'label :text "The green ball is the bg"))
124     (gtk-widget-show-all window)
125     (gtk-main)))
126
127 (defun test-image ()
128   (using*((window (make-instance 'gtk-window :title "Test images"))
129           (image (make-instance 'image :icon-name "applications-development" :icon-size 6)))
130     (container-add window image)
131     (g-signal-connect window "destroy" (lambda (w) (release w) (gtk-main-quit)))
132     (gtk-widget-show-all window)
133     (gtk-main)))
134
135 (defun test-progress-bar ()
136   (using* ((window (make-instance 'gtk-window :title "Test progress bar"))
137            (v-box (make-instance 'v-box))
138            (p-bar (make-instance 'progress-bar :test "A process"))
139            (button-pulse (make-instance 'button :label "Pulse"))
140            (button-set (make-instance 'button :label "Set"))
141            (entry (make-instance 'entry)))
142     (g-signal-connect window "destroy" (lambda (w) (release w) (gtk-main-quit)))
143     (container-add window v-box)
144     (box-pack-start v-box p-bar)
145     (box-pack-start v-box button-pulse)
146     (box-pack-start v-box button-set)
147     (box-pack-start v-box entry)
148     (g-signal-connect button-pulse "clicked" (lambda (w) (release w) (progress-bar-pulse p-bar)))
149     (g-signal-connect button-set "clicked" (lambda (w) (release w)
150                                                    (setf (progress-bar-fraction p-bar)
151                                                          (coerce (read-from-string (entry-text entry)) 'real))))
152     (gtk-widget-show-all window)
153     (gtk-main)))
154
155 (defun test-status-bar ()
156   (using* ((window (make-instance 'gtk-window :title "Text status bar"))
157            (v-box (make-instance 'v-box))
158            (h-box (make-instance 'h-box))
159            (label (make-instance 'label :label "Test of status bar" :xalign 0.5 :yalign 0.5))
160            (status-bar (make-instance 'statusbar :has-resize-grip t))
161            (button-push (make-instance 'button :label "Push"))
162            (button-pop (make-instance 'button :label "Pop"))
163            (entry (make-instance 'entry))
164            (icon (make-instance 'status-icon :icon-name "applications-development")))
165     (set-status-icon-tooltip icon "An icon from lisp program")
166     (g-signal-connect window "destroy" (lambda (w) (release w)
167                                                #+ (or) (setf (status-icon-visible icon) nil)
168                                                (gtk-main-quit)))
169     (g-signal-connect button-push "clicked" (lambda (b) (release b) (status-bar-push status-bar "lisp-prog" (entry-text entry))))
170     (g-signal-connect button-pop "clicked" (lambda (b) (release b) (status-bar-pop status-bar "lisp-prog")))
171     (g-signal-connect icon "activate" (lambda (i) (release i)
172                                               (using (message-dialog (make-instance 'message-dialog :buttons :ok :text "You clicked on icon!"))
173                                                 (dialog-run message-dialog)
174                                                 (object-destroy message-dialog))))
175     (container-add window v-box)
176     (box-pack-start v-box h-box :expand nil)
177     (box-pack-start h-box entry)
178     (box-pack-start h-box button-push :expand nil)
179     (box-pack-start h-box button-pop :expand nil)
180     (box-pack-start v-box label)
181     (box-pack-start v-box status-bar :expand nil)
182     (gtk-widget-show-all window)
183     (setf (status-icon-screen icon) (gtk-window-screen window))
184     (gtk-main)))
185
186 (defun test-scale-button ()
187   (using* ((window (make-instance 'gtk-window :type :toplevel :title "Testing scale button"))
188            (button (make-instance 'scale-button :icons (list "media-seek-backward" "media-seek-forward" "media-playback-stop" "media-playback-start") :adjustment (make-instance 'adjustment :lower -40 :upper 50 :value 20))))
189     (g-signal-connect window "destroy" (lambda (w) (release w) (gtk-main-quit)))
190     (container-add window button)
191     (gtk-widget-show-all window)
192     (gtk-main)))
193
194 (defun test-text-view ()
195   (using* ((window (make-instance 'gtk-window :type :toplevel :title "Testing text view" :width-request 400 :height-request 300))
196            (button (make-instance 'button :label "Do"))
197            (bold-btn (make-instance 'button :label "Bold"))
198            (buffer (make-instance 'text-buffer :text "Some text buffer with some text inside"))
199            (v (make-instance 'text-view :buffer buffer :wrap-mode :word))
200            (box (make-instance 'v-box))
201            (scrolled (make-instance 'scrolled-window :hscrollbar-policy :automatic :vscrollbar-policy :automatic)))
202     (g-signal-connect window "destroy" (lambda (w) (release w) (gtk-main-quit)))
203     (g-signal-connect button "clicked" (lambda (b)
204                                          (release b)
205                                          (using* ((i1 (make-instance 'text-iter))
206                                                   (i2 (make-instance 'text-iter)))
207                                            (multiple-value-bind (i1 i2) (text-buffer-get-selection-bounds buffer)
208                                              (when (and i1 i2)
209                                                (using* ((i1 i1) (i2 i2)
210                                                         (dialog (make-instance 'message-dialog :buttons :ok)))
211                                                  (setf (message-dialog-text dialog) (format nil "selection: from (~A,~A) to (~A,~A)"
212                                                                                             (text-iter-line i1) (text-iter-line-offset i1)
213                                                                                             (text-iter-line i2) (text-iter-line-offset i2)))
214                                                  (dialog-run dialog)
215                                                  (object-destroy dialog)))))))
216     (g-signal-connect bold-btn "clicked" (Lambda (b)
217                                            (release b)
218                                            (multiple-value-bind (start end) (text-buffer-get-selection-bounds buffer)
219                                              (when (and start end)
220                                                (using* ((start start) (end end) (tag (text-tag-table-lookup (text-buffer-tag-table buffer) "bold")))
221                                                  (if (text-iter-has-tag start tag)
222                                                      (text-buffer-remove-tag buffer tag start end)
223                                                      (text-buffer-apply-tag buffer tag start end)))))))
224     (let ((tag (make-instance 'text-tag :name "bold" :weight 700)))
225       (text-tag-table-add (text-buffer-tag-table buffer) tag)
226       (g-signal-connect tag "event"
227                         (lambda (tag object event iter)
228                           (declare (ignore tag object iter))
229                           (when (eq (event-type event) :button-release)
230                             (using (dlg (make-instance 'message-dialog :text "You clicked on bold text." :buttons :ok))
231                               (dialog-run dlg)
232                               (object-destroy dlg))))))
233     (container-add window box)
234     (container-add scrolled v)
235     (box-pack-start box button :expand nil)
236     (box-pack-start box bold-btn :expand nil)
237     (box-pack-start box scrolled)
238     (gtk-widget-show-all window)
239     (gtk-main)))
240
241 (defun demo-code-editor ()
242   (using* ((window (make-instance 'gtk-window :type :toplevel :title "Code editor" :width-request 400 :height-request 400 :window-position :center))
243            (scrolled (make-instance 'scrolled-window :hscrollbar-policy :automatic :vscrollbar-policy :automatic))
244            (buffer (make-instance 'text-buffer))
245            (view (make-instance 'text-view :buffer buffer)))
246     (g-signal-connect window "destroy" (lambda (w) (release w) (gtk-main-quit)))
247     (container-add window scrolled)
248     (container-add scrolled view)
249     (gtk-widget-show-all window)
250     (g-signal-connect buffer "insert-text" (lambda (buffer location text len)
251                                              (using* ((buffer buffer) (location location))
252                                                (format t "~A~%" (list buffer location text len)))))
253     (gtk-main)))
254
255 (defstruct tvi title value)
256
257 (defun test-treeview-list ()
258   (let* ((window (make-instance 'gtk-window :type :toplevel :title "Treeview (list)"))
259          (model (make-instance 'array-list-store))
260          (scroll (make-instance 'scrolled-window :hscrollbar-policy :automatic :vscrollbar-policy :automatic))
261          (tv (make-instance 'tree-view :headers-visible t :width-request 100 :height-request 400 :rules-hint t))
262          (h-box (make-instance 'h-box))
263          (v-box (make-instance 'v-box))
264          (title-entry (make-instance 'entry))
265          (value-entry (make-instance 'entry))
266          (button (make-instance 'button :label "Add")))
267     (store-add-column model "gchararray" #'tvi-title)
268     (store-add-column model "gint" #'tvi-value)
269     (store-add-item model (make-tvi :title "Monday" :value 1))
270     (store-add-item model (make-tvi :title "Tuesday" :value 2))
271     (store-add-item model (make-tvi :title "Wednesday" :value 3))
272     (store-add-item model (make-tvi :title "Thursday" :value 4))
273     (store-add-item model (make-tvi :title "Friday" :value 5))
274     (store-add-item model (make-tvi :title "Saturday" :value 6))
275     (store-add-item model (make-tvi :title "Sunday" :value 7))
276     (setf (tree-view-model tv) model (tree-view-tooltip-column tv) 0)
277     (gobject:g-signal-connect window "destroy" (lambda (w) (gobject:release w) (gtk-main-quit)))
278     (gobject:g-signal-connect button "clicked" (lambda (b) (gobject:release b) 
279                                                        (store-add-item model (make-tvi :title (entry-text title-entry)
280                                                                                        :value (or (parse-integer (entry-text value-entry) 
281                                                                                                                  :junk-allowed t)
282                                                                                                   0)))))
283     (g-signal-connect tv "row-activated" (lambda (tv path column)
284                                            (release* tv path column)
285                                            (format t "You clicked on row ~A~%" (tree-path-indices path))))
286     (container-add window v-box)
287     (box-pack-start v-box h-box :expand nil)
288     (box-pack-start h-box title-entry :expand nil)
289     (box-pack-start h-box value-entry :expand nil)
290     (box-pack-start h-box button :expand nil)
291     (box-pack-start v-box scroll)
292     (container-add scroll tv)
293     (let ((column (make-instance 'tree-view-column :title "Title" :sort-column-id 0))
294           (renderer (make-instance 'cell-renderer-text :text "A text")))
295       (tree-view-column-pack-start column renderer)
296       (tree-view-column-add-attribute column renderer "text" 0)
297       (tree-view-append-column tv column)
298       (print (tree-view-column-tree-view column))
299       (print (tree-view-column-cell-renderers column)))
300     (let ((column (make-instance 'tree-view-column :title "Value"))
301           (renderer (make-instance 'cell-renderer-text :text "A text")))
302       (tree-view-column-pack-start column renderer)
303       (tree-view-column-add-attribute column renderer "text" 1)
304       (tree-view-append-column tv column)
305       (print (tree-view-column-tree-view column))
306       (print (tree-view-column-cell-renderers column)))
307     (gtk-widget-show-all window)
308     (gtk-main)))
309
310 (defun test-toolbar ()
311   (let* ((window (make-instance 'gtk-window :type :toplevel :title "Toolbar" :width-request 200 :height-request 100 :window-position :center))
312          (v-box (make-instance 'v-box))
313          (toolbar (make-instance 'toolbar :toolbar-style :icons :icon-size :small-toolbar :icon-size-set t))
314          (l (make-instance 'label :label "Toolbar demo")))
315     (gobject:g-signal-connect window "destroy" (lambda (w) (gobject:release w) (gtk-main-quit)))
316     (container-add window v-box)
317     (box-pack-start v-box toolbar :expand nil)
318     (box-pack-start v-box l)
319     (let ((b (make-instance 'tool-button :stock-id "gtk-connect")))
320       (g-signal-connect b "clicked" (lambda (b)
321                                       (setf (tool-button-stock-id b)
322                                             (if (string= (tool-button-stock-id b) "gtk-connect")
323                                                 (prog1 "gtk-disconnect" (setf (label-label l) "Disconnected"))
324                                                 (prog1 "gtk-connect" (setf (label-label l) "Connected"))))))
325       (toolbar-insert toolbar b -1))
326     (toolbar-insert toolbar (make-instance 'separator-tool-item) -1)
327     (toolbar-insert toolbar (make-instance 'tool-button :stock-id "gtk-undo" :sensitive nil) -1)
328     (toolbar-insert toolbar (make-instance 'tool-button :stock-id "gtk-redo") -1)
329     (gtk-widget-show-all window)
330     (gtk-main)))
331
332 (defun test-ui-manager ()
333   (let* ((window (make-instance 'gtk-window :type :toplevel :title "UI Manager" :default-width 200 :default-height 100 :window-position :center))
334          (ui-manager (make-instance 'ui-manager))
335          (print-confirmation t))
336     (ui-manager-add-ui-from-string ui-manager
337                                    "
338 <ui>
339   <toolbar action='toolbar1'>
340       <separator/>
341       <toolitem name='Left' action='justify-left'/>
342       <toolitem name='Center' action='justify-center'/>
343       <toolitem name='Right' action='justify-right'/>
344       <toolitem name='Zoom in' action='zoom-in' />
345       <toolitem name='print-confirm' action='print-confirm' />
346       <separator/>
347   </toolbar>
348 </ui>")
349     (gobject:g-signal-connect window "destroy" (lambda (w) (gobject:release w) (gtk-main-quit)))
350     (iter (with fn = (lambda (action) (when print-confirmation (format t "Action ~A with name ~A activated~%" action (action-name action)))))
351           (with action-group = (make-instance 'action-group :name "Actions"))
352           (finally (let ((a (make-instance 'toggle-action :name "print-confirm" :label "Print" :stock-id "gtk-print-report" :active t)))
353                      (g-signal-connect a "toggled" (lambda (action) (setf print-confirmation (toggle-action-active action))))
354                      (action-group-add-action action-group a))
355                    (ui-manager-insert-action-group ui-manager action-group 0))
356           (for (name stock-id) in '(("justify-left" "gtk-justify-left")
357                                     ("justify-center" "gtk-justify-center")
358                                     ("justify-right" "gtk-justify-right")
359                                     ("zoom-in" "gtk-zoom-in")))
360           (for action = (make-instance 'action :name name :stock-id stock-id))
361           (g-signal-connect action "activate" fn)
362           (action-group-add-action action-group action))
363     (awhen (ui-manager-widget ui-manager "/toolbar1")
364       (container-add window it))
365     (gtk-widget-show-all window)
366     (gtk-main)))
367
368 (defun test-color-button ()
369   (let ((window (make-instance 'gtk-window :title "Color button" :type :toplevel :window-position :center :width-request 100 :height-request 100))
370         (button (make-instance 'color-button :title "Color button")))
371     (g-signal-connect window "destroy" (lambda (w) (release w) (gtk-main-quit)))
372     (g-signal-connect button "color-set" (lambda (b) (release b) (format t "Chose color ~A~%" (color-button-color button))))
373     (container-add window button)
374     (gtk-widget-show-all window)
375     (gtk-main)))
376
377 (defun test-color-selection ()
378   (let ((window (make-instance 'gtk-window :title "Color selection" :type :toplevel :window-position :center))
379         (selection (make-instance 'color-selection :has-opacity-control t)))
380     (g-signal-connect window "destroy" (lambda (w) (declare (ignore w)) (gtk-main-quit)))
381     (g-signal-connect selection "color-changed" (lambda (s) (declare (ignore s)) (unless (color-selection-adjusting-p selection) (format t "color: ~A~%" (color-selection-current-color selection)))))
382     (container-add window selection)
383     (gtk-widget-show-all window)
384     (gtk-main)))
385
386 (defun test-file-chooser ()
387   (let ((window (make-instance 'gtk-window :title "file chooser" :type :toplevel :window-position :center :default-width 100 :default-height 100))
388         (v-box (make-instance 'v-box))
389         (button (make-instance 'file-chooser-button :action :open))
390         (b (make-instance 'button :label "Choose for save" :stock-id "gtk-save")))
391     (g-signal-connect window "destroy" (lambda (w) (declare (ignore w)) (gtk-main-quit)))
392     (g-signal-connect button "file-set" (lambda (b) (declare (ignore b)) (format t "File set: ~A~%" (file-chooser-filename button))))
393     (g-signal-connect b "clicked" (lambda (b)
394                                     (declare (ignore b))
395                                     (let ((d (make-instance 'file-chooser-dialog :action :save :title "Choose file to save")))
396                                       (dialog-add-button d "gtk-save" :accept)
397                                       (dialog-add-button d "gtk-cancel" :cancel)
398                                       (when (eq (dialog-run d) :accept)
399                                         (format t "saved to file ~A~%" (file-chooser-filename d)))
400                                       (object-destroy d))))
401     (container-add window v-box)
402     (box-pack-start v-box button)
403     (box-pack-start v-box b)
404     (gtk-widget-show-all window)
405     (gtk-main)))
406
407 (defun test-font-chooser ()
408   (let ((window (make-instance 'gtk-window :title "fonts" :type :toplevel :window-position :center :default-width 100 :default-height 100))
409         (v-box (make-instance 'v-box))
410         (button (make-instance 'font-button :title "Choose font" :font-name "Sans 10")))
411     (g-signal-connect window "destroy" (lambda (w) (declare (ignore w)) (gtk-main-quit)))
412     (g-signal-connect button "font-set" (lambda (b) (declare (ignore b)) (format t "Chose font ~A~%" (font-button-font-name button))))
413     (container-add window v-box)
414     (box-pack-start v-box button)
415     (gtk-widget-show-all window)
416     (gtk-main)))
417
418 (defun test-notebook ()
419   (let ((window (make-instance 'gtk-window :title "Notebook" :type :toplevel :window-position :center :default-width 100 :default-height 100))
420         (expander (make-instance 'expander :expanded t :label "notebook"))
421         (notebook (make-instance 'notebook :enable-popup t)))
422     (g-signal-connect window "destroy" (lambda (w) (declare (ignore w)) (gtk-main-quit)))
423     (iter (for i from 0 to 5)
424           (for page = (make-instance 'label :label (format nil "Label for page ~A" i)))
425           (for tab-label = (make-instance 'label :label (format nil "Tab ~A" i)))
426           (for tab-button = (make-instance 'button :use-stock t :label "gtk-close" :relief :none))
427           (for tab-hbox = (make-instance 'h-box))
428           (box-pack-start tab-hbox tab-label)
429           (box-pack-start tab-hbox tab-button)
430           (gtk-widget-show-all tab-hbox)
431           (notebook-add-page notebook page tab-hbox))
432     (container-add window expander)
433     (container-add expander notebook)
434     (gtk-widget-show-all window)
435     (gtk-main)))
436
437 (defun calendar-detail (calendar year month day)
438   (declare (ignore calendar year month))
439   (when (= day 23)
440     "!"))
441
442 (defun test-calendar ()
443   (let ((window (make-instance 'gtk-window :title "Calendar" :type :toplevel :window-position :center :default-width 100 :default-height 100))
444         (calendar (make-instance 'calendar :detail-function #'calendar-detail)))
445     (g-signal-connect window "destroy" (lambda (w) (declare (ignore w)) (gtk-main-quit)))
446     (g-signal-connect calendar "day-selected" (lambda (c) (declare (ignore c)) (format t "selected: year ~A month ~A day ~A~%"
447                                                                                        (calendar-year calendar)
448                                                                                        (calendar-month calendar)
449                                                                                        (calendar-day calendar))))
450     (container-add window calendar)
451     (gtk-widget-show-all window)
452     (gtk-main)))
453
454 (defun test-box-child-property ()
455   (let ((window (make-instance 'gtk-window :title "Text box child property" :type :toplevel :window-position :center :width-request 200 :height-request 200))
456         (box (make-instance 'h-box))
457         (button (make-instance 'toggle-button :active t :label "Expand")))
458     (g-signal-connect window "destroy" (lambda (w) (declare (ignore w)) (gtk-main-quit)))
459     (g-signal-connect button "toggled" (lambda (b) (declare (ignore b)) (setf (box-child-expand box button) (toggle-button-active button))))
460     (container-add window box)
461     (box-pack-start box button)
462     (gtk-widget-show-all window)
463     (gtk-main)))