diff --git a/cl-todo.lisp b/cl-todo.lisp index 314a07f..32212da 100644 --- a/cl-todo.lisp +++ b/cl-todo.lisp @@ -14,9 +14,7 @@ (defun launch () (setf *task-list* (load-task-file)) - (make-gui) - ;;TODO - ) + (make-gui)) (defun load-task-file (&optional (file-name *runfile*)) "Load a list of (task) strings from the run file" @@ -32,20 +30,19 @@ (defun write-task-list (&optional (lst *task-list*) (filename *runfile*)) "Write the task list to file, one entry per line." - (let ((f (open filename :direction :output))) - (dolist (i lst) (format f "~&~S" i)) + (let ((f (open filename :direction :output :if-exists :supersede))) + (dolist (i lst) (format f "~&~A" i)) (close f))) (defun add-task! (task) "Append a task to the task list and save to file" (setf *task-list* (append *task-list* (list task))) - (format t "~&~S" *task-list*)) - ;;(write-task-list)) + (write-task-list)) (defun remove-task! (task) "Remove a task from the list and save to file" (setf *task-list* (remove-if #'(lambda (s) (equalp s task)) - *task-list* :count 1))) - ;;(write-task-list)) ;;FIXME caused a file-access error + *task-list* :count 1)) + (write-task-list)) diff --git a/cl-todo.lisp b/cl-todo.lisp index 314a07f..32212da 100644 --- a/cl-todo.lisp +++ b/cl-todo.lisp @@ -14,9 +14,7 @@ (defun launch () (setf *task-list* (load-task-file)) - (make-gui) - ;;TODO - ) + (make-gui)) (defun load-task-file (&optional (file-name *runfile*)) "Load a list of (task) strings from the run file" @@ -32,20 +30,19 @@ (defun write-task-list (&optional (lst *task-list*) (filename *runfile*)) "Write the task list to file, one entry per line." - (let ((f (open filename :direction :output))) - (dolist (i lst) (format f "~&~S" i)) + (let ((f (open filename :direction :output :if-exists :supersede))) + (dolist (i lst) (format f "~&~A" i)) (close f))) (defun add-task! (task) "Append a task to the task list and save to file" (setf *task-list* (append *task-list* (list task))) - (format t "~&~S" *task-list*)) - ;;(write-task-list)) + (write-task-list)) (defun remove-task! (task) "Remove a task from the list and save to file" (setf *task-list* (remove-if #'(lambda (s) (equalp s task)) - *task-list* :count 1))) - ;;(write-task-list)) ;;FIXME caused a file-access error + *task-list* :count 1)) + (write-task-list)) diff --git a/gtk-ui.lisp b/gtk-ui.lisp index 45d4298..0461be7 100644 --- a/gtk-ui.lisp +++ b/gtk-ui.lisp @@ -10,6 +10,7 @@ (defun make-gui (&optional (decorated NIL)) (within-main-loop + ;;initialise widgets (let ((window (make-instance 'gtk-window :type :toplevel :title "cl-todo" @@ -29,27 +30,30 @@ :valign :start :border-width 5 :spacing 2))) + ;;ENTER adds a new task from the input field (g-signal-connect input-field "activate" #'(lambda (field) (add-task! (gtk-entry-text field)) (gtk-widget-show (new-task-widget (gtk-entry-text field) inner-box)) (setf (gtk-entry-text field) ""))) + ;;set up the layout (gtk-container-add outer-box input-field) (gtk-container-add scroller (create-task-widgets inner-box)) (gtk-box-pack-start outer-box scroller) (gtk-container-add window outer-box) + ;;ESCAPE quits the program (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)))) + ;;show the window (setf (gtk-window-decorated window) decorated) (gtk-widget-show-all window)))) (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)) (task (car tl) (car tl)) (task-button @@ -64,9 +68,11 @@ #'(lambda (button) (gtk-container-remove box button) (remove-task! task))) + ;; (gtk-label-set-markup + ;; (gtk-button-label task-button) + ;; (format nil "~A" task)) (gtk-box-pack-start box task-button) task-button)) -;;TODO undo delete? +;;TODO two-step delete? ;;TODO help window (gtk-shortcuts-window) -;;TODO undecorate