From c587e2ec28a818ce251ec9adc847348726312177 Mon Sep 17 00:00:00 2001 From: Dmitry Kalyanov Date: Tue, 17 Mar 2009 11:10:18 +0300 Subject: [PATCH] simple demo for toolbar --- gtk/gtk.demo.lisp | 48 ++++++++++++++---------------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/gtk/gtk.demo.lisp b/gtk/gtk.demo.lisp index 23fd000..b924d57 100644 --- a/gtk/gtk.demo.lisp +++ b/gtk/gtk.demo.lisp @@ -11,7 +11,8 @@ #:test-text-view #:demo-code-editor #:test-treeview-list - #:test-combobox)) + #:test-combobox + #:test-toolbar)) (in-package :gtk-demo) @@ -298,41 +299,20 @@ (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)) +(defun test-toolbar () + (let* ((window (make-instance 'gtk-window :type :toplevel :title "Toolbar")) (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)) + (toolbar (make-instance 'toolbar))) (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)) + (box-pack-start v-box toolbar :expand nil) + (box-pack-start v-box (make-instance 'label :text "Label")) + (let ((b (make-instance 'tool-button :stock-id "gtk-connect"))) + (g-signal-connect b "clicked" (lambda (b) + (format t "clicked on ~A~%" b) + (let ((d (make-instance 'message-dialog :message-type :info :text (format nil "clicked on ~A" b) :buttons :ok))) + (dialog-run d) + (object-destroy d)))) + (toolbar-insert toolbar b -1)) (gtk-widget-show-all window) (gtk-main))) \ No newline at end of file -- 1.7.10.4