annotate lisp/w3/w3-toolbar.el @ 0:376386a54a3c r19-14

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