Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
;;; xwem-icons.el --- Icons handling routines.
;; Copyright (C) 2003 by Free Software Foundation, Inc.
;; Author: Zajcev Evgeny <zevlg@yandex.ru>
;; Created: Sat Dec 27 15:38:24 MSK 2003
;; Keywords: xwem
;; X-CVS: $Id$
;; This file is part of XWEM.
;; XWEM is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; XWEM is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
;; License for more details.
;; You should have received a copy of the GNU General Public License
;; along with XEmacs; see the file COPYING. If not, write to the Free
;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
;; 02111-1307, USA.
;;; Synched up with: Not in FSF
;;; Commentary:
;; Icons support.
;;; Code:
(require 'xlib-xpm)
(defvar xwem-icons-dir (locate-data-directory "xwem")
"Directory where icons for use by XWEM lies.")
(defvar xwem-icons-list nil
"List of already loaded icons.")
;;;###autoload
(defvar xwem-icons-alist
;; [ wm-name wm-class-name wm-class-instance ] . icon-name
'(([".*" ".term" ".Term"] . "mini-term.xpm")
([".*" "xclock" "XClock"] . "mini-clock.xpm")
([".*" "xload" "XLoad"] . "mini-measure.xpm")
([".*" "xcalc" "XCalc"] . "mini-calc.xpm")
([".*" "xkeycaps" "XKeyCaps"] . "mini-xkeycaps.xpm")
([".*" "xdvi" "XDvi"] . "mini-xdvi.xpm")
([".*" "xv" "XV.*"] . "mini-xv.xpm")
([".*" ".*" "AcroRead"] . "mini-acroread.xpm")
([".*" ".*" "Xpdf"] . "mini-acroread.xpm")
([".*" ".*" "Xman"] . "mini-info.xpm")
([".*" "Mozilla" ".*"] . "mini-mozilla.xpm")
([".*" "gv" "GV"] . "mini-gv.xpm")
([".*" "ghostview" "Ghostview"] . "mini-gv.xpm")
([".*" "xfig" "Fig"] . "mini-xfig.xpm")
([".*" "ethereal" "Ethereal"] . "mini-ethereal.xpm")
([".*" "xfd" "Xfd"] . "mini-font.xpm")
([".*" "xfontsel" "XFontSel"] . "mini-font.xpm")
([".*" "xconsole" "XConsole"] . "mini-sh1.xpm")
([".*" "xcolors" "Xcolors"] . "mini-colors.xpm")
([".*" ".*" "X-Chat"] . "mini-xchat.xpm")
;; Match by WM_NAME since WM_CLASS is not setuped
(["Lupe" ".*" ".*"] . "mini-zoom.xpm")
(["xcmap" "" ".*"] . "mini-colors.xpm")
;; EMACS
([".*\\.tex.*" "emacs" "Emacs"] . "mini-xemacstex.xpm")
([".*\\.c.*" "emacs" "Emacs"] . "mini-xemacsC.xpm")
([".*\\.py.*" "emacs" "Emacs"] . "mini-xemacspy.xpm")
([".*\\(Group\\|Summary\\|Article\\).*" "emacs" "Emacs"] . "mini-xemacsgnus.xpm")
([".*\\*info\\*.*" "emacs" "Emacs"] . "mini-xemacsinfo.xpm")
([".*" "emacs" "Emacs"] . "mini-xemacs.xpm")
([".*" ".*" ".*"] . "mini-x2.xpm")))
(defun xwem-icons-cl-icon-name (cl)
"Return icon name for CL."
(let* ((hints (xwem-cl-hints cl))
(wm-name (xwem-hints-wm-name hints))
(wm-class (xwem-hints-wm-class hints))
(class-name (or (car wm-class) ""))
(class-inst (or (cadr wm-class) ""))
(ialist xwem-icons-alist))
(while (and ialist
(not (and (string-match (aref (car (car ialist)) 0) wm-name)
(string-match (aref (car (car ialist)) 1) class-name)
(string-match (aref (car (car ialist)) 2) class-inst))))
(setq ialist (cdr ialist)))
(cdr (car ialist))))
;;;###autoload
(defun xwem-icons-cl-icon (cl)
"Get X-Image of CL's icon.
Return cons cell where car is X-Pixmap of icon and cdr is X-Pixmap
where mask for icon is stored."
(let ((iname (xwem-icons-cl-icon-name cl))
fname ximg ximg-mask-pixmap)
(when iname
(setq ximg (plist-get xwem-icons-list iname))
(unless ximg
(setq fname (concat xwem-icons-dir "/" iname))
(setq ximg (X:xpm-pixmap-from-file (xwem-dpy) (XDefaultRootWindow (xwem-dpy)) fname))
(setq ximg-mask-pixmap (X:xpm-pixmap-from-file (xwem-dpy) (XDefaultRootWindow (xwem-dpy)) fname t))
(setq xwem-icons-list (plist-put xwem-icons-list iname (cons ximg ximg-mask-pixmap)))
(setq ximg (plist-get xwem-icons-list iname)))
ximg)))
(provide 'xwem-icons)
;;; xwem-icons.el ends here