modular Smoke kdeui
Annotate for file /src/application.lisp
2010-04-03 tobias 1 (in-package :cl-smoke.kde.ui)
2009-04-05 tobias 2
2010-04-03 tobias 3 (defun kde:app ()
17:29:08 ' 4 (assert (kde:app-p))
2009-04-05 tobias 5 (qt:app))
15:36:16 ' 6
2010-04-03 tobias 7 (defun kde:app-p ()
2009-04-05 tobias 8 (and (qt:app-p)
2010-04-03 tobias 9 (typep (qt:app) (find-class 'kde:application))))
2009-04-05 tobias 10
2010-04-03 tobias 11 (defun kde:make-aboutdata (app-name program-name version)
2009-04-05 tobias 12 (let ((app-name (make-instance 'qt:byte-array :args (list app-name)))
15:36:16 ' 13 (catalog-name (make-instance 'qt:byte-array))
' 14 (program-name (kde:ki18n program-name))
' 15 (version (make-instance 'qt:byte-array :args (list version))))
2010-04-03 tobias 16 (make-instance 'kde:about-data :args (list app-name catalog-name
17:29:08 ' 17 program-name version))))
2009-04-05 tobias 18
15:36:16 ' 19 (let ((argv))
2010-04-03 tobias 20 (defun ensure-app (about-data &optional (application 'kde:application)
2009-04-05 tobias 21 (args #+sbcl sb-ext:*posix-argv*
15:36:16 ' 22 #-sbcl (list "lisp")))
' 23 (if (qt:app-p)
' 24 (progn
2010-04-03 tobias 25 (assert (typep (qt:app) (find-class 'kde:application))
2009-04-05 tobias 26 ()
15:36:16 ' 27 "The existing application object ~A is
' 28 not of type ~A." (qt:app) (find-class application))
' 29 (values (qt:app) nil))
' 30 (let ((args (append (list (first args))
' 31 '("--nocrashhandler") (rest args))))
' 32 (unless (null argv)
' 33 (foreign-free argv)
' 34 (setf argv (null-pointer)))
' 35
' 36 (setf argv (foreign-alloc :string :initial-contents args))
' 37 (kde:cmd-line-args.init (length args) argv about-data)
2010-04-03 tobias 38 (values (make-instance 'kde:application) t))))
2009-04-05 tobias 39 (defun kill-app ()
15:36:16 ' 40 (qt:application.close-all-windows)
2010-04-03 tobias 41 (setf cl-smoke.qt.gui::*widgets* nil)
2009-04-05 tobias 42 ;; FIXME make it work without mem-faults
2010-04-03 tobias 43 (trivial-garbage:cancel-finalization (kde:app))
17:29:08 ' 44 (cxx:delete-later (kde:app))
2009-05-24 tobias 45 ;(smoke::delete-pointer (smoke::pointer (app)) (class-of (app)))
2010-04-03 tobias 46 (setf (slot-value (kde:app) 'pointer) (null-pointer))))
2009-04-05 tobias 47
2010-04-03 tobias 48 (defmacro kde:with-app (about-data &body body)
17:29:08 ' 49 `(cl-smoke.qt.core::with-application ((ensure-app ,about-data)
2009-04-05 tobias 50 (kill-app))
15:36:16 ' 51 ,@body))
' 52
2010-04-03 tobias 53 (defmacro kde:with-kde ((app-name program-name version) &body body)
2009-04-05 tobias 54 (let ((about-data (gensym)))
2010-04-03 tobias 55 `(let ((,about-data (kde:make-aboutdata ,app-name ,program-name ,version)))
17:29:08 ' 56 (kde:with-app ,about-data
' 57 ,@body))))