1 ;;; xwem-appcollect.el --- Collect an applications.
3 ;; Copyright (C) 2004,2005 by XWEM Org.
5 ;; Author: Zajcev Evgeny <zevlg@yandex.ru>
6 ;; Created: Fri Oct 29 04:35:18 MSD 2004
8 ;; X-CVS: $Id: xwem-appcollect.el,v 1.2 2005-04-04 19:54:10 lg Exp $
10 ;; This file is part of XWEM.
12 ;; XWEM is free software; you can redistribute it and/or modify it
13 ;; under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; XWEM is distributed in the hope that it will be useful, but WITHOUT
18 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
20 ;; License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 ;;; Synched up with: Not in FSF
31 ;; Helpfull util to create `xwem-applications-alist'.
34 ;; (xwem-appcollect '("xterm" "mozilla"))
36 ;; (xwem-appcollect '("xterm" "mozilla") '(name class) 'or)
38 ;; (xwem-appcollect '("xterm" "mozilla") '(command) 'or)
43 (require 'xwem-manage)
44 (require 'xwem-launcher)
46 (define-xwem-method manage appcollect (cl)
47 "Manage method when collecting info about applications."
48 (declare (special xwem-app-collection))
49 (declare (special xwem-app-collect-wait))
51 (let ((app-name (xwem-cl-get-prop cl 'xwem-appcollect-app-name))
52 (op (xwem-cl-get-prop cl 'xwem-appcollect-op))
53 (params (xwem-cl-get-prop cl 'xwem-appcollect-params))
56 (setq mspec (list op))
58 (cond ((eq par 'class)
59 (push `(and (class-inst ,(concat "^" (car (xwem-hints-wm-class (xwem-cl-hints cl))) "$"))
60 (class-name ,(concat "^" (cdr (xwem-hints-wm-class (xwem-cl-hints cl))) "$")))
63 (push `(name ,(concat "^" (xwem-hints-wm-name (xwem-cl-hints cl)) "$"))
66 (push `(command ,(concat "^" (xwem-hints-wm-command (xwem-cl-hints cl)) "$"))
69 (setq mspec (nreverse mspec))
71 (setq xwem-app-collection (put-alist app-name (list mspec) xwem-app-collection))
72 (xwem-client-kill cl t)
73 (setq xwem-app-collect-wait nil)))
75 ;;;###autoload(autoload 'xwem-appcollect "xwem-appcollect" nil nil)
76 (defun xwem-appcollect (app-names &optional params operation)
77 "Collect and return applications manage specs.
78 APP-NAMES is a list of applications to collect.
80 PARAMS is a list of elements where each element is one of:
81 `class' - Include class-inst/class-name into mspec.
82 `name' - Include app name into mspec.
83 `command' - Include command into mspec."
84 (let ((xwem-app-collection nil))
85 (declare (special xwem-app-collection))
88 (let ((cmd (xwem-launcher-normalize-cmd app))
89 (xwem-app-collect-wait t))
90 (declare (special xwem-app-collect-wait))
91 (xwem-manda-add-expectance
92 `(appcollect (xwem-appcollect-op ,(or operation 'and) xwem-appcollect-params ,(or params '(class))
93 xwem-appcollect-app-name ,app)
95 (xwem-execute-program cmd)
96 (while xwem-app-collect-wait
97 (dispatch-event (next-event)))))
100 (nreverse xwem-app-collection)))
103 (provide 'xwem-appcollect)
105 ;;; xwem-appcollect.el ends here