annotate lisp/w3/w3-toolbar.el @ 80:1ce6082ce73f r20-0b90

Import from CVS: tag r20-0b90
author cvs
date Mon, 13 Aug 2007 09:06:37 +0200
parents 131b0175ea99
children 6a378aca36af
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1 ;;; w3-toolbar.el --- Toolbar functions for emacs-w3
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Author: wmperry
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
3 ;; Created: 1996/12/30 16:04:40
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
4 ;; Version: 1.6
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: mouse, toolbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
8 ;;; Copyright (c) 1995, 1996 by William M. Perry (wmperry@cs.indiana.edu)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
9 ;;; Copyright (c) 1996 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; You should have received a copy of the GNU General Public License
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
24 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
25 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
26 ;;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Toolbar specific function for XEmacs 19.12+
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
32 (condition-case ()
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
33 (progn
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
34 (require 'xpm-button)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
35 (require 'xbm-button))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
36 (error nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (defvar w3-toolbar-icon-directory nil "Where the toolbar icons for w3 are.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (defvar w3-toolbar-back-icon nil "Toolbar icon for back")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (defvar w3-toolbar-forw-icon nil "Toolbar icon for forward")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (defvar w3-toolbar-home-icon nil "Toolbar icon for home")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (defvar w3-toolbar-reld-icon nil "Toolbar icon for reload")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (defvar w3-toolbar-imag-icon nil "Toolbar icon for images")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (defvar w3-toolbar-open-icon nil "Toolbar icon for open url")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (defvar w3-toolbar-print-icon nil "Toolbar icon for printing")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (defvar w3-toolbar-find-icon nil "Toolbar icon for find")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (defvar w3-toolbar-stop-icon nil "Toolbar icon for stop")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (defvar w3-toolbar-help-icon nil "Toolbar icon for help")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (defvar w3-toolbar-hotl-icon nil "Toolbar icon for hotlist")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (defvar w3-link-toolbar-orientation 'bottom
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 "*Where to put the document specific toolbar. Must be one of these symbols:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 default -- place at location specified by `default-toolbar-position'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 top -- place along the top of the frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 bottom -- place along the bottom of the frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 right -- place along the right edge of the frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 left -- place along the left edge of the frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 none -- no toolbar")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defvar w3-toolbar-orientation 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 "*Where to put the w3 toolbar. Must be one of these symbols:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 default -- place at location specified by `default-toolbar-position'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 top -- place along the top of the frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 bottom -- place along the bottom of the frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 right -- place along the right edge of the frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 left -- place along the left edge of the frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 none -- no toolbar")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defvar w3-toolbar-type 'both
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 "*What the toolbar looks like. Must be one of these symbols:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 pictures -- Show icons (without captions if in XEmacs 19.13)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 both -- Show icons (with captions if in XEmacs 19.13)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 text -- Show only text buttons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 Only has any meaning in XEmacs 19.12 when w3-toolbar-orientation is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 not `none'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (defvar w3-toolbar
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
82 '([w3-toolbar-back-icon w3-backward-in-history t "Back in history"]
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
83 [w3-toolbar-forw-icon w3-forward-in-history t "Forward in history"]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 [w3-toolbar-home-icon w3 t "Go home"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 [:style 2d :size 5]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 [w3-toolbar-reld-icon w3-reload-document t "Reload document"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 [w3-toolbar-hotl-icon w3-show-hotlist t "View hotlist"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 [w3-toolbar-imag-icon w3-load-delayed-images w3-delayed-images
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 "Load images"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 [toolbar-file-icon w3-fetch t "Fetch a URL"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 [toolbar-printer-icon w3-mouse-print-this-url t "Print document"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 [w3-toolbar-find-icon w3-search-forward t "Search"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;[w3-toolbar-stop-icon keyboard-quit t "Stop transaction"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 [w3-toolbar-help-icon w3-show-info-node t "Help"])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 "The toolbar for w3")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (defun w3-toolbar-make-captioned-buttons ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (let* ((ext (if (featurep 'xpm) ".xpm" ".xbm"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (base w3-toolbar-icon-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (up (expand-file-name (concat x "-up" ext) base))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (dn (expand-file-name (concat x "-dn" ext) base))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (no (expand-file-name (concat x "-no" ext) base))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (cap-up (expand-file-name (concat x "-cap-up" ext) base))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (cap-dn (expand-file-name (concat x "-cap-dn" ext) base))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (cap-no (expand-file-name (concat x "-cap-no" ext) base))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (var (intern (concat "w3-toolbar-" x "-icon"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (set var
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (toolbar-make-button-list up dn no cap-up cap-dn cap-no)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 '("back" "help" "find" "forw" "home" "hotl" "stop" "imag" "reld")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (defun w3-make-text-toolbar-button (text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (let ((bgcol (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (cdr-safe (assq 'background-toolbar-color (frame-parameters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 "#befbbefbbefb")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (if (featurep 'xpm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (mapcar 'make-glyph (xpm-button-create text 0 "black" bgcol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (xbm-button-create text 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (defun w3-toolbar-make-text-buttons ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (let ((bgcol (or (cdr-safe (assq 'background-toolbar-color
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (frame-parameters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 "#befbbefbbefb")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (setq w3-toolbar-back-icon (w3-make-text-toolbar-button "Back")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 w3-toolbar-forw-icon (w3-make-text-toolbar-button "Forward")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 w3-toolbar-home-icon (w3-make-text-toolbar-button "Home")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 w3-toolbar-reld-icon (w3-make-text-toolbar-button "Reload")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 w3-toolbar-hotl-icon (w3-make-text-toolbar-button "Hotlist")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 w3-toolbar-imag-icon (w3-make-text-toolbar-button "Images")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 w3-toolbar-open-icon (w3-make-text-toolbar-button "Open")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 w3-toolbar-print-icon (w3-make-text-toolbar-button "Print")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 w3-toolbar-find-icon (w3-make-text-toolbar-button "Find")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 w3-toolbar-help-icon (w3-make-text-toolbar-button "Help!"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (defun w3-toolbar-make-picture-buttons ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (let* ((ext (if (featurep 'xpm) ".xpm" ".xbm"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (base w3-toolbar-icon-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (up (expand-file-name (concat x "-cap-up" ext) base))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (dn (expand-file-name (concat x "-cap-dn" ext) base))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (no (expand-file-name (concat x "-cap-no" ext) base))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (var (intern (concat "w3-toolbar-" x "-icon"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (set var
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ((and (file-exists-p up) (file-exists-p dn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (file-exists-p no))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (toolbar-make-button-list up dn no))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ((file-exists-p up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (toolbar-make-button-list up))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (t nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 '("back" "help" "find" "forw" "home" "hotl" "imag" "reld")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (defun w3-toolbar-make-buttons ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (if (not w3-toolbar-icon-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (setq w3-toolbar-icon-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (file-name-as-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (expand-file-name "w3" data-directory))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ((not (file-exists-p w3-toolbar-icon-directory))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
166 (w3-warn 'files "Toolbar directory does not exist."))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ((not (fboundp 'toolbar-make-button-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ((eq w3-toolbar-type 'text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (w3-toolbar-make-text-buttons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ((boundp 'toolbar-buttons-captioned-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (w3-toolbar-make-captioned-buttons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (w3-toolbar-make-picture-buttons))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (defun w3-link-is-defined (rel &optional rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (or
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
178 (cdr-safe (assoc rel (cdr-safe (assq 'rel w3-current-links))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
179 (cdr-safe (assoc (or rev rel) (cdr-safe (assq 'rev w3-current-links))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;; Need to create w3-toolbar-glos-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;; w3-toolbar-toc-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; w3-toolbar-copy-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (defvar w3-link-toolbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 '([info::toolbar-prev-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (w3-fetch (w3-link-is-defined "previous" "next"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (w3-link-is-defined "previous" "next")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 "Back"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 [info::toolbar-next-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (w3-fetch (w3-link-is-defined "next" "previous"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (w3-link-is-defined "next" "previous")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 "Next"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 [info::toolbar-up-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (w3-fetch (w3-link-is-defined "up" "down"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (w3-link-is-defined "up" "down")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 "Up"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 [w3-toolbar-home-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (w3-fetch (w3-link-is-defined "home"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (w3-link-is-defined "home")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 "Home"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 [w3-toolbar-toc-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (w3-fetch (w3-link-is-defined "toc"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (w3-link-is-defined "toc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 "Contents"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 [w3-toolbar-find-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (w3-fetch (w3-link-is-defined "index"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (w3-link-is-defined "index")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 "Index"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 [w3-toolbar-glos-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (w3-fetch (w3-link-is-defined "glossary"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (w3-link-is-defined "glossary")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 "Glossary"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 [w3-toolbar-copy-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (w3-fetch (w3-link-is-defined "copyright"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (w3-link-is-defined "copyright")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 "Copyright"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 [w3-toolbar-hotl-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (w3-fetch (w3-link-is-defined "bookmark"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (w3-link-is-defined "bookmark")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 "Bookmarks"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 [w3-toolbar-help-icon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (w3-fetch (w3-link-is-defined "help"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (w3-link-is-defined "help")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 "Help"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (defun w3-toolbar-from-orientation (orientation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ((eq 'default w3-toolbar-orientation) default-toolbar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ((eq 'bottom w3-toolbar-orientation) bottom-toolbar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ((eq 'top w3-toolbar-orientation) top-toolbar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ((eq 'left w3-toolbar-orientation) left-toolbar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ((eq 'right w3-toolbar-orientation) right-toolbar)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (defun w3-toolbar-dimension-from-orientation (orientation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ((eq 'default w3-toolbar-orientation) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ((eq 'bottom w3-toolbar-orientation) bottom-toolbar-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ((eq 'top w3-toolbar-orientation) top-toolbar-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ((eq 'left w3-toolbar-orientation) left-toolbar-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ((eq 'right w3-toolbar-orientation) right-toolbar-width)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (defun w3-ensure-toolbar-visible (orientation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;; Make sure a certain toolbar is visible if necessary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;; This can modify frame parameters, so watch out.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (let ((dimension (w3-toolbar-dimension-from-orientation orientation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (toolbar (w3-toolbar-from-orientation orientation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (dimensions nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (widths nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (heights nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (needs nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (has nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (if (and dimension toolbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (setq toolbar (specifier-instance toolbar)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (setq dimensions (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (lambda (glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (and (glyphp glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (cons (glyph-width glyph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (glyph-height glyph)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (mapcar 'car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (delq nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (function (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (and x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (symbol-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (aref x 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 toolbar))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 widths (sort (mapcar 'car dimensions) '>=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 heights (sort (mapcar 'cdr dimensions) '>=)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 needs (+ 7 (if (memq orientation '(top bottom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (car heights)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (car widths)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 has (specifier-instance dimension))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (if (<= has needs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (set-specifier dimension (cons (selected-frame) needs)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (defun w3-toolbar-active ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (let ((toolbar (w3-toolbar-from-orientation w3-toolbar-orientation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (if (and toolbar (specifier-instance toolbar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (defun w3-toggle-link-toolbar ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (require 'info) ; For some toolbar buttons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (let* ((w3-toolbar-orientation w3-link-toolbar-orientation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (toolbar (w3-toolbar-from-orientation w3-toolbar-orientation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (if toolbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (if (w3-toolbar-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (set-specifier toolbar (cons (current-buffer) nil))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
295 (set-specifier toolbar w3-link-toolbar (current-buffer))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (defun w3-toggle-toolbar ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (if (eq major-mode 'w3-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (let ((toolbar (w3-toolbar-from-orientation w3-toolbar-orientation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ((w3-toolbar-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (set-specifier toolbar (cons (current-buffer) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (toolbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (set-specifier toolbar (cons (current-buffer) w3-toolbar)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (setq w3-toolbar-orientation 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 toolbar (w3-toolbar-from-orientation w3-toolbar-orientation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (and toolbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (set-specifier toolbar (cons (current-buffer) w3-toolbar))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (if (not (eq w3-toolbar-orientation 'none))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (setq w3-toolbar-orientation 'none)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (setq w3-toolbar-orientation 'default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (defun w3-show-info-node ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (Info-goto-node "(w3.info)Top"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (defun w3-mouse-print-this-url (&optional e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (let ((descr '("Print document as"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ["PostScript" (w3-print-this-url nil "PostScript") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ["Formatted Text" (w3-print-this-url nil "Formatted Text") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ["HTML Source" (w3-print-this-url nil "HTML Source") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ["LaTeX'd" (w3-print-this-url nil "LaTeX'd") t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ["Cancel" (beep) t])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (popup-dialog-box descr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (defun w3-add-toolbar-to-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (if (not (featurep 'toolbar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (let ((toolbar (w3-toolbar-from-orientation w3-toolbar-orientation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (if toolbar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (set-specifier toolbar (cons (current-buffer) w3-toolbar))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (set-specifier toolbar-buttons-captioned-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (cons (current-buffer) (eq w3-toolbar-type 'both)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (provide 'w3-toolbar)