diff --git a/gtk-ui.lisp b/gtk-ui.lisp index 6415886..45d4298 100644 --- a/gtk-ui.lisp +++ b/gtk-ui.lisp @@ -12,7 +12,7 @@ (within-main-loop (let ((window (make-instance 'gtk-window :type :toplevel - :title "cl-todo" ;;remove when undecorating + :title "cl-todo" :window-position :center :default-width 300 :default-height 200 @@ -32,7 +32,8 @@ (g-signal-connect input-field "activate" #'(lambda (field) (add-task! (gtk-entry-text field)) - (create-task-widgets inner-box) + (gtk-widget-show + (new-task-widget (gtk-entry-text field) inner-box)) (setf (gtk-entry-text field) ""))) (gtk-container-add outer-box input-field) (gtk-container-add scroller (create-task-widgets inner-box)) @@ -46,21 +47,25 @@ (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 - (when task (gtk-check-button-new-with-label task)) - (when task (gtk-check-button-new-with-label task)))) - ((null task) box) + (when task (new-task-widget task box)) + (when task (new-task-widget task box)))) + ((null task) box))) + +(defun new-task-widget (task box) + "Create a single check box widget with the specified task in the box" + (let ((task-button (gtk-check-button-new-with-label task))) (g-signal-connect task-button "clicked" #'(lambda (button) (gtk-container-remove box button) (remove-task! task))) - (gtk-box-pack-start box task-button))) + (gtk-box-pack-start box task-button) + task-button)) ;;TODO undo delete? ;;TODO help window (gtk-shortcuts-window)