Newer
Older
cl-todo / gtk-ui.lisp
;;;;
;;;; A simple TODO app for the GNOME desktop
;;;; (mainly written to try out GTK+Lisp)
;;;;
;;;; (c) Daniel Vedder 2020
;;;; Licensed under the terms of the MIT license
;;;;

(in-package :cl-todo)

(defvar *widget-list*)

(defun make-gui (task-list)
	(within-main-loop
		(let ((window (make-instance 'gtk-window
						  :type :toplevel
						  :title "cl-todo" ;;remove when undecorating
						  :default-width 300
						  :default-height 200))
				 (box (make-instance 'gtk-box
						  :orientation :vertical
						  :spacing 10))
				 ;;TODO input pane and scratchpad
				 (input-pane NIL) ;(make-instance 'gtk-text-field))
				 (scratch-pad NIL)
				 (task-buttons (create-widget-list task-list)))
			;;(gtk-box-pack-start input-pane)
			(dolist (tb task-buttons)
				(gtk-box-pack-start tb))
			(gtk-container-add window box)
			;;TODO undecorate
			(gtk-widget-show-all window))))


(defun create-widget-list (task-list)
	"Create a check button widget for each task"
	;;XXX This would probably be neater with LOOP
	(do* ((tl task-list (cdr tl))
			 (task-button
				 (gtk-check-button-new-with-label (car tl))
				 (gtk-check-button-new-with-label (car tl)))
			 (task-button-list nil))
		((null task) task-button-list)
		(g-signal-connect task-button "clicked"
			#'(lambda (button)
				  ;;TODO also remove the button from the UI
				  (remove-task! (gtk-check-button-label button))))
		(setf task-button-list
			(append task-button-list (list task-button)))))