From a7c9287064776dc0f4680db2d80d094b70a1c549 Mon Sep 17 00:00:00 2001 From: Dmitry Kalyanov Date: Sat, 29 Aug 2009 22:53:46 +0400 Subject: [PATCH] Added test-custom-window that demonstrates usage of a custom Lisp widget not registered with GObject --- gtk/gtk.demo.lisp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/gtk/gtk.demo.lisp b/gtk/gtk.demo.lisp index 98866dc..fa7b74a 100644 --- a/gtk/gtk.demo.lisp +++ b/gtk/gtk.demo.lisp @@ -23,7 +23,8 @@ #:test-builder #:demo-text-editor #:demo-class-browser - #:demo-treeview-tree)) + #:demo-treeview-tree + #:test-custom-window)) (in-package :gtk-demo) @@ -765,3 +766,33 @@ (print (tree-view-column-tree-view column)) (print (tree-view-column-cell-renderers column))) (widget-show window)))) + +(defclass custom-window (gtk-window) + ((label :initform (make-instance 'label :label "A label text") :reader custom-window-label) + (button :initform (make-instance 'button :label "Click me!") :reader custom-window-button)) + (:metaclass gobject-class) + (:default-initargs :title "Custom window with default initargs" :default-width 320 :default-height 240)) + +(defun custom-window-label-text (w) + (label-label (custom-window-label w))) + +(defun (setf custom-window-label-text) (new-value w) + (setf (label-label (custom-window-label w)) new-value)) + +(defmethod initialize-instance :after ((w custom-window) &key &allow-other-keys) + (let ((box (make-instance 'v-box))) + (box-pack-start box (custom-window-label w)) + (box-pack-start box (custom-window-button w) :expand nil) + (container-add w box)) + (connect-signal (custom-window-button w) "clicked" (lambda (b) + (declare (ignore b)) + (custom-window-button-clicked w)))) + +(defun custom-window-button-clicked (w) + (setf (custom-window-label-text w) + (format nil "Now is: ~A~%" (get-internal-run-time)))) + +(defun test-custom-window () + (within-main-loop + (let ((w (make-instance 'custom-window))) + (widget-show w)))) -- 1.7.10.4