;;;; ;;;; 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) (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 :border-width 10)) (input-field (make-instance 'gtk-entry)) (outer-box (make-instance 'gtk-box :orientation :vertical :spacing 5)) (scroller (make-instance 'gtk-scrolled-window :hscrollbar-policy :automatic :vscrollbar-policy :automatic)) (inner-box (make-instance 'gtk-box :orientation :vertical :valign :start :border-width 5 :spacing 2))) (g-signal-connect input-field "activate" #'(lambda (field) (add-task! (gtk-entry-text field)) (create-task-widgets task-list inner-box) (setf (gtk-entry-text field) ""))) (gtk-container-add outer-box input-field) (gtk-container-add scroller (create-task-widgets task-list inner-box)) (gtk-box-pack-start outer-box scroller) (gtk-container-add window outer-box) ;;TODO undecorate (gtk-widget-show-all window)))) (defun create-task-widgets (task-list box) "Create a check button widget for each task in the given gtk-box" ;;XXX This would probably be neater with LOOP (do* ((tl task-list (cdr tl)) (task (car tl) (car tl)) (task-button (when task (gtk-check-button-new-with-label task)) (when task (gtk-check-button-new-with-label task)))) ((null task) box) (g-signal-connect task-button "clicked" #'(lambda (button) (gtk-container-remove box button) (remove-task! task))) (gtk-box-pack-start box task-button))) ;;TODO undo delete? ;;TODO help window