diff --git a/cl-todo.lisp b/cl-todo.lisp index d805769..314a07f 100644 --- a/cl-todo.lisp +++ b/cl-todo.lisp @@ -14,7 +14,7 @@ (defun launch () (setf *task-list* (load-task-file)) - (make-gui *task-list*) + (make-gui) ;;TODO ) @@ -39,7 +39,8 @@ (defun add-task! (task) "Append a task to the task list and save to file" (setf *task-list* (append *task-list* (list task))) - (write-task-list)) + (format t "~&~S" *task-list*)) + ;;(write-task-list)) (defun remove-task! (task) "Remove a task from the list and save to file" diff --git a/cl-todo.lisp b/cl-todo.lisp index d805769..314a07f 100644 --- a/cl-todo.lisp +++ b/cl-todo.lisp @@ -14,7 +14,7 @@ (defun launch () (setf *task-list* (load-task-file)) - (make-gui *task-list*) + (make-gui) ;;TODO ) @@ -39,7 +39,8 @@ (defun add-task! (task) "Append a task to the task list and save to file" (setf *task-list* (append *task-list* (list task))) - (write-task-list)) + (format t "~&~S" *task-list*)) + ;;(write-task-list)) (defun remove-task! (task) "Remove a task from the list and save to file" diff --git a/gtk-ui.lisp b/gtk-ui.lisp index dba0779..6415886 100644 --- a/gtk-ui.lisp +++ b/gtk-ui.lisp @@ -8,11 +8,12 @@ (in-package :cl-todo) -(defun make-gui (task-list) +(defun make-gui (&optional (decorated NIL)) (within-main-loop (let ((window (make-instance 'gtk-window :type :toplevel :title "cl-todo" ;;remove when undecorating + :window-position :center :default-width 300 :default-height 200 :border-width 10)) @@ -31,20 +32,25 @@ (g-signal-connect input-field "activate" #'(lambda (field) (add-task! (gtk-entry-text field)) - (create-task-widgets task-list inner-box) + (create-task-widgets 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-container-add scroller (create-task-widgets inner-box)) (gtk-box-pack-start outer-box scroller) (gtk-container-add window outer-box) - ;;TODO undecorate + (g-signal-connect window "key-press-event" + #'(lambda (window event) + (when (equalp (gdk-keyval-name (gdk-event-key-keyval event)) "Escape") + (gtk-widget-destroy window) + (leave-gtk-main)))) + (setf (gtk-window-decorated window) decorated) (gtk-widget-show-all window)))) -(defun create-task-widgets (task-list box) +(defun create-task-widgets (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)) + (do* ((tl *task-list* (cdr tl)) (task (car tl) (car tl)) (task-button (when task (gtk-check-button-new-with-label task)) @@ -57,4 +63,5 @@ (gtk-box-pack-start box task-button))) ;;TODO undo delete? -;;TODO help window +;;TODO help window (gtk-shortcuts-window) +;;TODO undecorate