From: Dmitry Kalyanov Date: Tue, 17 Mar 2009 00:06:15 +0000 (+0300) Subject: Added demo of combobox X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=01671fa9688673f48baf52ccbc20c93c40b5db28;p=cl-gtk2.git Added demo of combobox --- diff --git a/gtk/gtk.demo.lisp b/gtk/gtk.demo.lisp index c0fc691..23fd000 100644 --- a/gtk/gtk.demo.lisp +++ b/gtk/gtk.demo.lisp @@ -10,7 +10,8 @@ #:test-scale-button #:test-text-view #:demo-code-editor - #:test-treeview-list)) + #:test-treeview-list + #:test-combobox)) (in-package :gtk-demo) @@ -295,4 +296,43 @@ (print (tree-view-column-tree-view column)) (print (tree-view-column-cell-renderers column))) (gtk-widget-show-all window) + (gtk-main))) + +(defun test-combobox () + (let* ((window (make-instance 'gtk-window :type :toplevel :title "Treeview (list)")) + (model (make-instance 'array-list-store)) + (combobox (make-instance 'combo-box :model model)) + (h-box (make-instance 'h-box)) + (v-box (make-instance 'v-box)) + (title-entry (make-instance 'entry)) + (value-entry (make-instance 'entry)) + (button (make-instance 'button :label "Add"))) + (store-add-column model "gchararray" #'tvi-title) + (store-add-column model "gint" #'tvi-value) + (store-add-item model (make-tvi :title "Monday" :value 1)) + (store-add-item model (make-tvi :title "Tuesday" :value 2)) + (store-add-item model (make-tvi :title "Wednesday" :value 3)) + (store-add-item model (make-tvi :title "Thursday" :value 4)) + (store-add-item model (make-tvi :title "Friday" :value 5)) + (store-add-item model (make-tvi :title "Saturday" :value 6)) + (store-add-item model (make-tvi :title "Sunday" :value 7)) + (gobject:g-signal-connect window "destroy" (lambda (w) (gobject:release w) (gtk-main-quit))) + (gobject:g-signal-connect button "clicked" (lambda (b) (gobject:release b) + (store-add-item model (make-tvi :title (entry-text title-entry) + :value (or (parse-integer (entry-text value-entry) + :junk-allowed t) + 0))))) + (container-add window v-box) + (box-pack-start v-box h-box :expand nil) + (box-pack-start h-box title-entry :expand nil) + (box-pack-start h-box value-entry :expand nil) + (box-pack-start h-box button :expand nil) + (container-add v-box combobox) + (let ((renderer (make-instance 'cell-renderer-text :xalign 0.0))) + (cell-layout-pack-start combobox renderer) + (cell-layout-add-attribute combobox renderer "text" 0)) + (let ((renderer (make-instance 'cell-renderer-text :xalign 1.0))) + (cell-layout-pack-start combobox renderer) + (cell-layout-add-attribute combobox renderer "text" 1)) + (gtk-widget-show-all window) (gtk-main))) \ No newline at end of file