diff --git a/cl-todo.lisp b/cl-todo.lisp index 32212da..f876765 100644 --- a/cl-todo.lisp +++ b/cl-todo.lisp @@ -14,7 +14,8 @@ (defun launch () (setf *task-list* (load-task-file)) - (make-gui)) + (make-gui) + (bt:join-thread (gtk-thread))) (defun load-task-file (&optional (file-name *runfile*)) "Load a list of (task) strings from the run file" diff --git a/cl-todo.lisp b/cl-todo.lisp index 32212da..f876765 100644 --- a/cl-todo.lisp +++ b/cl-todo.lisp @@ -14,7 +14,8 @@ (defun launch () (setf *task-list* (load-task-file)) - (make-gui)) + (make-gui) + (bt:join-thread (gtk-thread))) (defun load-task-file (&optional (file-name *runfile*)) "Load a list of (task) strings from the run file" diff --git a/gtk-ui.lisp b/gtk-ui.lisp index 0461be7..795e138 100644 --- a/gtk-ui.lisp +++ b/gtk-ui.lisp @@ -9,8 +9,9 @@ (in-package :cl-todo) (defun make-gui (&optional (decorated NIL)) + ;;TODO split up this function + ;;initialise widgets (within-main-loop - ;;initialise widgets (let ((window (make-instance 'gtk-window :type :toplevel :title "cl-todo" @@ -74,5 +75,11 @@ (gtk-box-pack-start box task-button) task-button)) +(defun gtk-thread () + "Return the thread object running the GTK main loop" + (dolist (th (bt:all-threads)) + (when (equalp (bt:thread-name th) "cl-cffi-gtk main thread") + (return-from gtk-thread th)))) + ;;TODO two-step delete? ;;TODO help window (gtk-shortcuts-window) diff --git a/cl-todo.lisp b/cl-todo.lisp index 32212da..f876765 100644 --- a/cl-todo.lisp +++ b/cl-todo.lisp @@ -14,7 +14,8 @@ (defun launch () (setf *task-list* (load-task-file)) - (make-gui)) + (make-gui) + (bt:join-thread (gtk-thread))) (defun load-task-file (&optional (file-name *runfile*)) "Load a list of (task) strings from the run file" diff --git a/gtk-ui.lisp b/gtk-ui.lisp index 0461be7..795e138 100644 --- a/gtk-ui.lisp +++ b/gtk-ui.lisp @@ -9,8 +9,9 @@ (in-package :cl-todo) (defun make-gui (&optional (decorated NIL)) + ;;TODO split up this function + ;;initialise widgets (within-main-loop - ;;initialise widgets (let ((window (make-instance 'gtk-window :type :toplevel :title "cl-todo" @@ -74,5 +75,11 @@ (gtk-box-pack-start box task-button) task-button)) +(defun gtk-thread () + "Return the thread object running the GTK main loop" + (dolist (th (bt:all-threads)) + (when (equalp (bt:thread-name th) "cl-cffi-gtk main thread") + (return-from gtk-thread th)))) + ;;TODO two-step delete? ;;TODO help window (gtk-shortcuts-window) diff --git a/package.lisp b/package.lisp index 1c48a26..a5663dc 100644 --- a/package.lisp +++ b/package.lisp @@ -9,5 +9,5 @@ (defpackage :cl-todo (:documentation "A simple TODO widget for the GNOME desktop") (:nicknames :todo) - (:use :common-lisp :gtk :gdk :gobject :glib) ;;XXX pare down + (:use :common-lisp :bordeaux-threads :gtk :gdk :gobject :glib) ;;XXX pare down (:export launch +runfile+))