1 ;;; x-win.el --- parse relevant switches and set up for X -*- lexical-binding:t -*-
3 ;; Copyright (C) 1993-1994, 2001-2016 Free Software Foundation, Inc.
6 ;; Keywords: terminals, i18n
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;; X-win.el: this file defines functions to initialize the X window
26 ;; system and process X-specific command line parameters before
27 ;; creating the first X frame.
29 ;; Beginning in Emacs 23, the act of loading this file should not have
30 ;; the side effect of initializing the window system or processing
31 ;; command line arguments (this file is now loaded in loadup.el). See
32 ;; `handle-args-function' and `window-system-initialization' for more details.
34 ;; startup.el will then examine startup files, and eventually call the hooks
35 ;; which create the first window(s).
39 ;; These are the standard X switches from the Xt Initialize.c file of
42 ;; Command line Resource Manager string
45 ;; +synchronous *synchronous
46 ;; -background *background
49 ;; -bordercolor *borderColor
50 ;; -borderwidth .borderWidth
56 ;; -foreground *foreground
57 ;; -geometry .geometry
60 ;; -reverse *reverseVideo
62 ;; -selectionTimeout .selectionTimeout
63 ;; -synchronous *synchronous
66 ;; An alist of X options and the function which handles them. See
69 (eval-when-compile (require 'cl-lib
))
71 (if (not (fboundp 'x-create-frame
))
72 (error "%s: Loading x-win.el but not compiled for X" (invocation-name)))
74 (require 'term
/common-win
)
84 (defvar x-invocation-args
)
85 (defvar x-keysym-table
)
86 (defvar x-selection-timeout
)
88 (defvar x-session-previous-id
)
90 (defun x-handle-no-bitmap-icon (_switch)
91 (setq default-frame-alist
(cons '(icon-type) default-frame-alist
)))
93 ;; Handle the --parent-id option.
94 (defun x-handle-parent-id (switch)
95 (or (consp x-invocation-args
)
96 (error "%s: missing argument to `%s' option" (invocation-name) switch
))
97 (setq initial-frame-alist
(cons
99 (string-to-number (car x-invocation-args
)))
101 x-invocation-args
(cdr x-invocation-args
)))
103 ;; Handle the --smid switch. This is used by the session manager
104 ;; to give us back our session id we had on the previous run.
105 (defun x-handle-smid (switch)
106 (or (consp x-invocation-args
)
107 (error "%s: missing argument to `%s' option" (invocation-name) switch
))
108 (setq x-session-previous-id
(car x-invocation-args
)
109 x-invocation-args
(cdr x-invocation-args
)))
111 (defvar emacs-save-session-functions nil
112 "Special hook run when a save-session event occurs.
113 The functions do not get any argument.
114 Functions can return non-nil to inform the session manager that the
115 window system shutdown should be aborted.
117 See also `emacs-session-save'.")
119 (defun emacs-session-filename (session-id)
120 "Construct a filename to save the session in based on SESSION-ID.
121 Return a filename in `user-emacs-directory', unless the session file
122 already exists in the home directory."
123 (let ((basename (concat "session." session-id
)))
124 (locate-user-emacs-file basename
125 (concat ".emacs-" basename
))))
127 (defun emacs-session-save ()
128 "This function is called when the window system is shutting down.
129 If this function returns non-nil, the window system shutdown is canceled.
131 When a session manager tells Emacs that the window system is shutting
132 down, this function is called. It calls the functions in the hook
133 `emacs-save-session-functions'. Functions are called with the current
134 buffer set to a temporary buffer. Functions should use `insert' to insert
135 lisp code to save the session state. The buffer is saved in a file in the
136 home directory of the user running Emacs. The file is evaluated when
137 Emacs is restarted by the session manager.
139 If any of the functions returns non-nil, no more functions are called
140 and this function returns non-nil. This will inform the session manager
141 that it should abort the window system shutdown."
142 (let ((filename (emacs-session-filename x-session-id
))
143 (buf (get-buffer-create (concat " *SES " x-session-id
))))
144 (when (file-exists-p filename
)
145 (delete-file filename
))
146 (with-current-buffer buf
147 (let ((cancel-shutdown (condition-case nil
148 ;; A return of t means cancel the shutdown.
149 (run-hook-with-args-until-success
150 'emacs-save-session-functions
)
152 (unless cancel-shutdown
153 (write-file filename
))
157 (defun emacs-session-restore (previous-session-id)
158 "Restore the Emacs session if started by a session manager.
159 The file saved by `emacs-session-save' is evaluated and deleted if it
161 (let ((filename (emacs-session-filename previous-session-id
)))
162 (when (file-exists-p filename
)
164 (delete-file filename
)
165 (message "Restored session data"))))
171 ;; Standard X cursor shapes, courtesy of Mr. Fox, who wanted ALL of them.
174 (defconst x-pointer-X-cursor
0)
175 (defconst x-pointer-arrow
2)
176 (defconst x-pointer-based-arrow-down
4)
177 (defconst x-pointer-based-arrow-up
6)
178 (defconst x-pointer-boat
8)
179 (defconst x-pointer-bogosity
10)
180 (defconst x-pointer-bottom-left-corner
12)
181 (defconst x-pointer-bottom-right-corner
14)
182 (defconst x-pointer-bottom-side
16)
183 (defconst x-pointer-bottom-tee
18)
184 (defconst x-pointer-box-spiral
20)
185 (defconst x-pointer-center-ptr
22)
186 (defconst x-pointer-circle
24)
187 (defconst x-pointer-clock
26)
188 (defconst x-pointer-coffee-mug
28)
189 (defconst x-pointer-cross
30)
190 (defconst x-pointer-cross-reverse
32)
191 (defconst x-pointer-crosshair
34)
192 (defconst x-pointer-diamond-cross
36)
193 (defconst x-pointer-dot
38)
194 (defconst x-pointer-dotbox
40)
195 (defconst x-pointer-double-arrow
42)
196 (defconst x-pointer-draft-large
44)
197 (defconst x-pointer-draft-small
46)
198 (defconst x-pointer-draped-box
48)
199 (defconst x-pointer-exchange
50)
200 (defconst x-pointer-fleur
52)
201 (defconst x-pointer-gobbler
54)
202 (defconst x-pointer-gumby
56)
203 (defconst x-pointer-hand1
58)
204 (defconst x-pointer-hand2
60)
205 (defconst x-pointer-heart
62)
206 (defconst x-pointer-icon
64)
207 (defconst x-pointer-iron-cross
66)
208 (defconst x-pointer-left-ptr
68)
209 (defconst x-pointer-left-side
70)
210 (defconst x-pointer-left-tee
72)
211 (defconst x-pointer-leftbutton
74)
212 (defconst x-pointer-ll-angle
76)
213 (defconst x-pointer-lr-angle
78)
214 (defconst x-pointer-man
80)
215 (defconst x-pointer-middlebutton
82)
216 (defconst x-pointer-mouse
84)
217 (defconst x-pointer-pencil
86)
218 (defconst x-pointer-pirate
88)
219 (defconst x-pointer-plus
90)
220 (defconst x-pointer-question-arrow
92)
221 (defconst x-pointer-right-ptr
94)
222 (defconst x-pointer-right-side
96)
223 (defconst x-pointer-right-tee
98)
224 (defconst x-pointer-rightbutton
100)
225 (defconst x-pointer-rtl-logo
102)
226 (defconst x-pointer-sailboat
104)
227 (defconst x-pointer-sb-down-arrow
106)
228 (defconst x-pointer-sb-h-double-arrow
108)
229 (defconst x-pointer-sb-left-arrow
110)
230 (defconst x-pointer-sb-right-arrow
112)
231 (defconst x-pointer-sb-up-arrow
114)
232 (defconst x-pointer-sb-v-double-arrow
116)
233 (defconst x-pointer-shuttle
118)
234 (defconst x-pointer-sizing
120)
235 (defconst x-pointer-spider
122)
236 (defconst x-pointer-spraycan
124)
237 (defconst x-pointer-star
126)
238 (defconst x-pointer-target
128)
239 (defconst x-pointer-tcross
130)
240 (defconst x-pointer-top-left-arrow
132)
241 (defconst x-pointer-top-left-corner
134)
242 (defconst x-pointer-top-right-corner
136)
243 (defconst x-pointer-top-side
138)
244 (defconst x-pointer-top-tee
140)
245 (defconst x-pointer-trek
142)
246 (defconst x-pointer-ul-angle
144)
247 (defconst x-pointer-umbrella
146)
248 (defconst x-pointer-ur-angle
148)
249 (defconst x-pointer-watch
150)
250 (defconst x-pointer-xterm
152)
251 (defconst x-pointer-invisible
255)
256 (defun vendor-specific-keysyms (vendor)
257 "Return the appropriate value of `system-key-alist' for VENDOR.
258 VENDOR is a string containing the name of the X Server's vendor,
259 as returned by `x-server-vendor'."
260 (cond ((or (string-equal vendor
"Hewlett-Packard Incorporated")
261 (string-equal vendor
"Hewlett-Packard Company"))
262 '(( 168 . mute-acute
)
264 ( 170 . mute-asciicircum
)
265 ( 171 . mute-diaeresis
)
266 ( 172 . mute-asciitilde
)
280 (65397 . kp-backtab
)))
281 ;; Fixme: What about non-X11/NeWS sun server?
282 ((or (string-equal vendor
"X11/NeWS - Sun Microsystems Inc.")
283 (string-equal vendor
"X Consortium"))
287 ;; These are for Sun under X11R6
295 ;; This is used by DEC's X server.
296 '((65280 . remove
)))))
301 (puthash i i x-keysym-table
)
304 ;; Table from Kuhn's proposed additions to the `KEYSYM Encoding'
305 ;; appendix to the X protocol definition.
1126 (puthash (car pair
) (cdr pair
) x-keysym-table
))
1128 ;; The following keysym codes for graphics are listed in the document
1129 ;; as not having unicodes available:
1131 ;; #x08b1 TOP LEFT SUMMATION Technical
1132 ;; #x08b2 BOTTOM LEFT SUMMATION Technical
1133 ;; #x08b3 TOP VERTICAL SUMMATION CONNECTOR Technical
1134 ;; #x08b4 BOTTOM VERTICAL SUMMATION CONNECTOR Technical
1135 ;; #x08b5 TOP RIGHT SUMMATION Technical
1136 ;; #x08b6 BOTTOM RIGHT SUMMATION Technical
1137 ;; #x08b7 RIGHT MIDDLE SUMMATION Technical
1138 ;; #x0aac SIGNIFICANT BLANK SYMBOL Publish
1139 ;; #x0abd DECIMAL POINT Publish
1140 ;; #x0abf MARKER Publish
1141 ;; #x0acb TRADEMARK SIGN IN CIRCLE Publish
1142 ;; #x0ada HEXAGRAM Publish
1143 ;; #x0aff CURSOR Publish
1144 ;; #x0dde THAI MAIHANAKAT Thai
1149 (define-obsolete-function-alias 'x-cut-buffer-or-selection-value
1150 'x-selection-value
"24.1")
1152 ;; Arrange for the kill and yank functions to set and check the clipboard.
1154 (defun x-clipboard-yank ()
1155 "Insert the clipboard contents, or the last stretch of killed text."
1156 (declare (obsolete clipboard-yank
"25.1"))
1158 (let ((clipboard-text (gui--selection-value-internal 'CLIPBOARD
))
1159 (select-enable-clipboard t
))
1160 (if (and clipboard-text
(> (length clipboard-text
) 0))
1161 (kill-new clipboard-text
))
1164 (declare-function accelerate-menu
"xmenu.c" (&optional frame
) t
)
1166 (defun x-menu-bar-open (&optional frame
)
1167 "Open the menu bar if it is shown.
1168 `popup-menu' is used if it is off."
1171 ((and (not (zerop (or (frame-parameter nil
'menu-bar-lines
) 0)))
1172 (fboundp 'accelerate-menu
))
1173 (accelerate-menu frame
))
1175 (popup-menu (mouse-menu-bar-map) last-nonmenu-event
))))
1178 ;;; Window system initialization.
1180 (defun x-win-suspend-error ()
1181 "Report an error when a suspend is attempted.
1182 This returns an error if any Emacs frames are X frames."
1183 ;; Don't allow suspending if any of the frames are X frames.
1184 (if (memq 'x
(mapcar #'window-system
(frame-list)))
1185 (error "Cannot suspend Emacs while running under X")))
1187 (defvar x-initialized nil
1188 "Non-nil if the X window system has been initialized.")
1190 (declare-function x-open-connection
"xfns.c"
1191 (display &optional xrm-string must-succeed
))
1192 (declare-function x-server-max-request-size
"xfns.c" (&optional terminal
))
1193 (declare-function x-get-resource
"frame.c"
1194 (attribute class
&optional component subclass
))
1195 (declare-function x-parse-geometry
"frame.c" (string))
1196 (defvar x-resource-name
)
1197 (defvar x-display-name
)
1198 (defvar x-command-line-resources
)
1200 (cl-defmethod window-system-initialization (&context
(window-system x
)
1202 "Initialize Emacs for X frames and open the first connection to an X server."
1203 (cl-assert (not x-initialized
))
1205 ;; Make sure we have a valid resource name.
1206 (or (stringp x-resource-name
)
1208 (setq x-resource-name
(invocation-name))
1210 ;; Change any . or * characters in x-resource-name to hyphens,
1211 ;; so as not to choke when we use it in X resource queries.
1212 (while (setq i
(string-match "[.*]" x-resource-name
))
1213 (aset x-resource-name i ?-
))))
1215 (x-open-connection (or display
1216 (setq x-display-name
(or (getenv "DISPLAY" (selected-frame))
1217 (getenv "DISPLAY"))))
1218 x-command-line-resources
1219 ;; Exit Emacs with fatal error if this fails and we
1220 ;; are the initial display.
1221 (eq initial-window-system
'x
))
1223 ;; Create the default fontset.
1224 (create-default-fontset)
1226 ;; Create the standard fontset.
1228 (create-fontset-from-fontset-spec standard-fontset-spec t
)
1229 (error (display-warning
1231 (format "Creation of the standard fontset failed: %s" err
)
1234 ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
1235 (create-fontset-from-x-resource)
1237 ;; Set scroll bar mode to right if set by X resources. Default is left.
1238 (if (equal (x-get-resource "verticalScrollBars" "ScrollBars") "right")
1239 (customize-set-variable 'scroll-bar-mode
'right
))
1241 ;; Apply a geometry resource to the initial frame. Put it at the end
1242 ;; of the alist, so that anything specified on the command line takes
1244 (let* ((res-geometry (x-get-resource "geometry" "Geometry"))
1248 (setq parsed
(x-parse-geometry res-geometry
))
1249 ;; If the resource specifies a position,
1250 ;; call the position and size "user-specified".
1251 (if (or (assq 'top parsed
) (assq 'left parsed
))
1252 (setq parsed
(cons '(user-position . t
)
1253 (cons '(user-size . t
) parsed
))))
1254 ;; All geometry parms apply to the initial frame.
1255 (setq initial-frame-alist
(append initial-frame-alist parsed
))
1256 ;; The size parms apply to all frames. Don't set it if there are
1257 ;; sizes there already (from command line).
1258 (if (and (assq 'height parsed
)
1259 (not (assq 'height default-frame-alist
)))
1260 (setq default-frame-alist
1261 (cons (cons 'height
(cdr (assq 'height parsed
)))
1262 default-frame-alist
)))
1263 (if (and (assq 'width parsed
)
1264 (not (assq 'width default-frame-alist
)))
1265 (setq default-frame-alist
1266 (cons (cons 'width
(cdr (assq 'width parsed
)))
1267 default-frame-alist
))))))
1269 ;; Check the reverseVideo resource.
1270 (let ((case-fold-search t
))
1271 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
1273 (string-match "^\\(true\\|yes\\|on\\)$" rv
))
1274 (setq default-frame-alist
1275 (cons '(reverse . t
) default-frame-alist
)))))
1277 ;; Set x-selection-timeout, measured in milliseconds.
1278 (let ((res-selection-timeout (x-get-resource "selectionTimeout"
1279 "SelectionTimeout")))
1280 (setq x-selection-timeout
1281 (if res-selection-timeout
1282 (string-to-number res-selection-timeout
)
1285 ;; Don't let Emacs suspend under X.
1286 (add-hook 'suspend-hook
'x-win-suspend-error
)
1288 ;; During initialization, we defer sending size hints to the window
1289 ;; manager, because that can induce a race condition:
1290 ;; http://lists.gnu.org/archive/html/emacs-devel/2008-10/msg00033.html
1291 ;; Send the size hints once initialization is done.
1292 (add-hook 'after-init-hook
'x-wm-set-size-hint
)
1294 ;; Turn off window-splitting optimization; X is usually fast enough
1295 ;; that this is only annoying.
1296 (setq split-window-keep-point t
)
1298 ;; Motif direct handling of f10 wasn't working right,
1299 ;; So temporarily we've turned it off in lwlib-Xm.c
1300 ;; and turned the Emacs f10 back on.
1301 ;; ;; Motif normally handles f10 itself, so don't try to handle it a second time.
1302 ;; (if (featurep 'motif)
1303 ;; (global-set-key [f10] 'ignore))
1305 ;; Enable CLIPBOARD copy/paste through menu bar commands.
1306 (menu-bar-enable-clipboard)
1308 ;; ;; Override Paste so it looks at CLIPBOARD first.
1309 ;; (define-key menu-bar-edit-menu [paste]
1310 ;; (append '(menu-item "Paste" x-clipboard-yank
1311 ;; :enable (not buffer-read-only)
1312 ;; :help "Paste (yank) text most recently cut/copied")
1315 (x-apply-session-resources)
1316 (setq x-initialized t
))
1318 (declare-function x-own-selection-internal
"xselect.c"
1319 (selection value
&optional frame
))
1320 (declare-function x-disown-selection-internal
"xselect.c"
1321 (selection &optional time-object terminal
))
1322 (declare-function x-selection-owner-p
"xselect.c"
1323 (&optional selection terminal
))
1324 (declare-function x-selection-exists-p
"xselect.c"
1325 (&optional selection terminal
))
1326 (declare-function x-get-selection-internal
"xselect.c"
1327 (selection-symbol target-type
&optional time-stamp terminal
))
1329 (add-to-list 'display-format-alist
'("\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" . x
))
1330 (cl-defmethod handle-args-function (args &context
(window-system x
))
1331 (x-handle-args args
))
1333 (cl-defmethod frame-creation-function (params &context
(window-system x
))
1334 (x-create-frame-with-faces params
))
1336 (cl-defmethod gui-backend-set-selection (selection value
1337 &context
(window-system x
))
1338 (if value
(x-own-selection-internal selection value
)
1339 (x-disown-selection-internal selection
)))
1341 (cl-defmethod gui-backend-selection-owner-p (selection
1342 &context
(window-system x
))
1343 (x-selection-owner-p selection
))
1345 (cl-defmethod gui-backend-selection-exists-p (selection
1346 &context
(window-system x
))
1347 (x-selection-exists-p selection
))
1349 (cl-defmethod gui-backend-get-selection (selection-symbol target-type
1350 &context
(window-system x
)
1351 &optional time-stamp terminal
)
1352 (x-get-selection-internal selection-symbol target-type time-stamp terminal
))
1354 ;; Initiate drag and drop
1355 (add-hook 'after-make-frame-functions
'x-dnd-init-frame
)
1356 (define-key special-event-map
[drag-n-drop
] 'x-dnd-handle-drag-n-drop-event
)
1358 (defcustom x-gtk-stock-map
1359 (mapcar (lambda (arg)
1360 (cons (purecopy (car arg
)) (purecopy (cdr arg
))))
1362 ("etc/images/new" .
("document-new" "gtk-new"))
1363 ("etc/images/open" .
("document-open" "gtk-open"))
1364 ("etc/images/diropen" .
"n:system-file-manager")
1365 ("etc/images/close" .
("window-close" "gtk-close"))
1366 ("etc/images/save" .
("document-save" "gtk-save"))
1367 ("etc/images/saveas" .
("document-save-as" "gtk-save-as"))
1368 ("etc/images/undo" .
("edit-undo" "gtk-undo"))
1369 ("etc/images/cut" .
("edit-cut" "gtk-cut"))
1370 ("etc/images/copy" .
("edit-copy" "gtk-copy"))
1371 ("etc/images/paste" .
("edit-paste" "gtk-paste"))
1372 ("etc/images/search" .
("edit-find" "gtk-find"))
1373 ("etc/images/print" .
("document-print" "gtk-print"))
1374 ("etc/images/preferences" .
("preferences-system" "gtk-preferences"))
1375 ("etc/images/help" .
("help-browser" "gtk-help"))
1376 ("etc/images/left-arrow" .
("go-previous" "gtk-go-back"))
1377 ("etc/images/right-arrow" .
("go-next" "gtk-go-forward"))
1378 ("etc/images/home" .
("go-home" "gtk-home"))
1379 ("etc/images/jump-to" .
("go-jump" "gtk-jump-to"))
1380 ("etc/images/index" .
"gtk-index")
1381 ("etc/images/exit" .
("application-exit" "gtk-quit"))
1382 ("etc/images/cancel" .
"gtk-cancel")
1383 ("etc/images/info" .
("dialog-information" "gtk-info"))
1384 ("etc/images/bookmark_add" .
"n:bookmark_add")
1385 ;; Used in Gnus and/or MH-E:
1386 ("etc/images/attach" .
"gtk-attach")
1387 ("etc/images/connect" .
"gtk-connect")
1388 ("etc/images/contact" .
"gtk-contact")
1389 ("etc/images/delete" .
("edit-delete" "gtk-delete"))
1390 ("etc/images/describe" .
("document-properties" "gtk-properties"))
1391 ("etc/images/disconnect" .
"gtk-disconnect")
1392 ;; ("etc/images/exit" . "gtk-exit")
1393 ("etc/images/lock-broken" .
"gtk-lock_broken")
1394 ("etc/images/lock-ok" .
"gtk-lock_ok")
1395 ("etc/images/lock" .
"gtk-lock")
1396 ("etc/images/next-page" .
"gtk-next-page")
1397 ("etc/images/refresh" .
("view-refresh" "gtk-refresh"))
1398 ("etc/images/sort-ascending" .
("view-sort-ascending" "gtk-sort-ascending"))
1399 ("etc/images/sort-column-ascending" .
"gtk-sort-column-ascending")
1400 ("etc/images/sort-criteria" .
"gtk-sort-criteria")
1401 ("etc/images/sort-descending" .
("view-sort-descending"
1402 "gtk-sort-descending"))
1403 ("etc/images/sort-row-ascending" .
"gtk-sort-row-ascending")
1404 ("images/gnus/toggle-subscription" .
"gtk-task-recurring")
1405 ("images/mail/compose" .
"gtk-mail-compose")
1406 ("images/mail/copy" .
"gtk-mail-copy")
1407 ("images/mail/forward" .
"gtk-mail-forward")
1408 ("images/mail/inbox" .
"gtk-inbox")
1409 ("images/mail/move" .
"gtk-mail-move")
1410 ("images/mail/not-spam" .
"gtk-not-spam")
1411 ("images/mail/outbox" .
"gtk-outbox")
1412 ("images/mail/reply-all" .
"gtk-mail-reply-to-all")
1413 ("images/mail/reply" .
"gtk-mail-reply")
1414 ("images/mail/save-draft" .
"gtk-mail-handling")
1415 ("images/mail/send" .
"gtk-mail-send")
1416 ("images/mail/spam" .
"gtk-spam")
1417 ;; Used for GDB Graphical Interface
1418 ("images/gud/break" .
"gtk-no")
1419 ("images/gud/recstart" .
("media-record" "gtk-media-record"))
1420 ("images/gud/recstop" .
("media-playback-stop" "gtk-media-stop"))
1421 ;; No themed versions available:
1422 ;; mail/preview (combining stock_mail and stock_zoom)
1423 ;; mail/save (combining stock_mail, stock_save and stock_convert)
1425 "How icons for tool bars are mapped to Gtk+ stock items.
1426 Emacs must be compiled with the Gtk+ toolkit for this to have any effect.
1427 A value that begins with n: denotes a named icon instead of a stock icon."
1429 :type
'(choice (repeat
1431 (cons (string :tag
"Emacs icon")
1432 (choice (group (string :tag
"Named")
1433 (string :tag
"Stock"))
1434 (string :tag
"Stock/named"))))))
1437 (defcustom icon-map-list
'(x-gtk-stock-map)
1438 "A list of alists that map icon file names to stock/named icons.
1439 The alists are searched in the order they appear. The first match is used.
1440 The keys in the alists are file names without extension and with two directory
1441 components. For example, to map /usr/share/emacs/22.1.1/etc/images/open.xpm
1442 to stock item gtk-open, use:
1444 (\"etc/images/open\" . \"gtk-open\")
1446 Themes also have named icons. To map to one of those, use n: before the name:
1448 (\"etc/images/diropen\" . \"n:system-file-manager\")
1450 The list elements are either the symbol name for the alist or the
1453 If you don't want stock icons, set the variable to nil."
1455 :type
'(choice (const :tag
"Don't use stock icons" nil
)
1456 (repeat (choice symbol
1457 (cons (string :tag
"Emacs icon")
1458 (string :tag
"Stock/named")))))
1461 (defconst x-gtk-stock-cache
(make-hash-table :weakness t
:test
'equal
))
1463 (defun x-gtk-map-stock (file)
1464 "Map icon with file name FILE to a Gtk+ stock name.
1465 This uses `icon-map-list' to map icon file names to stock icon names."
1466 (when (stringp file
)
1467 (or (gethash file x-gtk-stock-cache
)
1471 (let* ((file-sans (file-name-sans-extension file
))
1472 (key (and (string-match "/\\([^/]+/[^/]+/[^/]+$\\)"
1474 (match-string 1 file-sans
)))
1475 (icon-map icon-map-list
)
1477 (while (and (null value
) icon-map
)
1478 (setq elem
(car icon-map
)
1479 value
(assoc-string (or key file-sans
)
1483 icon-map
(cdr icon-map
)))
1484 (and value
(cdr value
))))
1485 x-gtk-stock-cache
))))
1487 (global-set-key [XF86WakeUp] 'ignore)
1490 (provide 'term/x-win)
1492 ;;; x-win.el ends here