diff options
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/net/eudc-bob.el | 128 |
2 files changed, 89 insertions, 47 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 01bd57f25c9..e457a2271b3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2000-01-13 Gerd Moellmann <gerd@gnu.org> | ||
| 2 | |||
| 3 | * net/eudc-bob.el (eudc-bob-play-sound-at-point): Play sounds | ||
| 4 | for Emacs. | ||
| 5 | (eudc-bob-can-display-inline-images): Extend for Emacs. | ||
| 6 | (eudc-bob-toggle-inline-display): Ditto. | ||
| 7 | (eudc-bob-display-jpeg): Ditto. | ||
| 8 | |||
| 1 | 2000-01-12 Gerd Moellmann <gerd@gnu.org> | 9 | 2000-01-12 Gerd Moellmann <gerd@gnu.org> |
| 2 | 10 | ||
| 3 | * net/eudc-bob.el, net/eudc-export.el, net/eudc-hotlist.el, | 11 | * net/eudc-bob.el, net/eudc-export.el, net/eudc-hotlist.el, |
diff --git a/lisp/net/eudc-bob.el b/lisp/net/eudc-bob.el index f2bd4eb62eb..e27aa4e7c0a 100644 --- a/lisp/net/eudc-bob.el +++ b/lisp/net/eudc-bob.el | |||
| @@ -37,7 +37,7 @@ | |||
| 37 | "Keymap for inline images.") | 37 | "Keymap for inline images.") |
| 38 | 38 | ||
| 39 | (defvar eudc-bob-sound-keymap nil | 39 | (defvar eudc-bob-sound-keymap nil |
| 40 | "Keymap for inline images.") | 40 | "Keymap for inline sounds.") |
| 41 | 41 | ||
| 42 | (defvar eudc-bob-url-keymap nil | 42 | (defvar eudc-bob-url-keymap nil |
| 43 | "Keymap for inline images.") | 43 | "Keymap for inline images.") |
| @@ -84,10 +84,11 @@ | |||
| 84 | 84 | ||
| 85 | (defun eudc-bob-can-display-inline-images () | 85 | (defun eudc-bob-can-display-inline-images () |
| 86 | "Return non-nil if we can display images inline." | 86 | "Return non-nil if we can display images inline." |
| 87 | (and eudc-xemacs-p | 87 | (if eudc-xemacs-p |
| 88 | (memq (console-type) | 88 | (and (memq (console-type) '(x mswindows)) |
| 89 | '(x mswindows)) | 89 | (fboundp 'make-glyph)) |
| 90 | (fboundp 'make-glyph))) | 90 | (and (boundp 'image-types) |
| 91 | (not (null images-types))))) | ||
| 91 | 92 | ||
| 92 | (defun eudc-bob-make-button (label keymap &optional menu plist) | 93 | (defun eudc-bob-make-button (label keymap &optional menu plist) |
| 93 | "Create a button with LABEL. | 94 | "Create a button with LABEL. |
| @@ -112,41 +113,70 @@ LABEL." | |||
| 112 | 113 | ||
| 113 | (defun eudc-bob-display-jpeg (data inline) | 114 | (defun eudc-bob-display-jpeg (data inline) |
| 114 | "Display the JPEG DATA at point. | 115 | "Display the JPEG DATA at point. |
| 115 | if INLINE is non-nil, try to inline the image otherwise simply | 116 | If INLINE is non-nil, try to inline the image otherwise simply |
| 116 | display a button." | 117 | display a button." |
| 117 | (let ((glyph (if (eudc-bob-can-display-inline-images) | 118 | (cond (eudc-xemacs-p |
| 118 | (make-glyph (list (vector 'jpeg :data data) | 119 | (let ((glyph (if (eudc-bob-can-display-inline-images) |
| 119 | [string :data "[JPEG Picture]"]))))) | 120 | (make-glyph (list (vector 'jpeg :data data) |
| 120 | (eudc-bob-make-button "[JPEG Picture]" | 121 | [string :data "[JPEG Picture]"]))))) |
| 121 | eudc-bob-image-keymap | 122 | (eudc-bob-make-button "[JPEG Picture]" |
| 122 | eudc-bob-image-menu | 123 | eudc-bob-image-keymap |
| 123 | (list 'glyph glyph | 124 | eudc-bob-image-menu |
| 124 | 'end-glyph (if inline glyph) | 125 | (list 'glyph glyph |
| 125 | 'duplicable t | 126 | 'end-glyph (if inline glyph) |
| 126 | 'invisible inline | 127 | 'duplicable t |
| 127 | 'start-open t | 128 | 'invisible inline |
| 128 | 'end-open t | 129 | 'start-open t |
| 129 | 'object-data data)))) | 130 | 'end-open t |
| 131 | 'object-data data)))) | ||
| 132 | (t | ||
| 133 | (let* ((image (create-image data nil t)) | ||
| 134 | (props (list 'object-data data 'eudc-image image))) | ||
| 135 | (when inline | ||
| 136 | (setq props (nconc (list 'display image) props))) | ||
| 137 | (eudc-bob-make-button "[Picture]" | ||
| 138 | eudc-bob-image-keymap | ||
| 139 | eudc-bob-image-menu | ||
| 140 | props))))) | ||
| 130 | 141 | ||
| 131 | (defun eudc-bob-toggle-inline-display () | 142 | (defun eudc-bob-toggle-inline-display () |
| 132 | "Toggle inline display of an image." | 143 | "Toggle inline display of an image." |
| 133 | (interactive) | 144 | (interactive) |
| 134 | (if (eudc-bob-can-display-inline-images) | 145 | (when (eudc-bob-can-display-inline-images) |
| 135 | (let ((overlays (append (overlays-at (1- (point))) | 146 | (cond (eudc-xemacs-p |
| 136 | (overlays-at (point)))) | 147 | (let ((overlays (append (overlays-at (1- (point))) |
| 137 | overlay glyph) | 148 | (overlays-at (point)))) |
| 138 | (setq overlay (car overlays)) | 149 | overlay glyph) |
| 139 | (while (and overlay | 150 | (setq overlay (car overlays)) |
| 140 | (not (setq glyph (overlay-get overlay 'glyph)))) | 151 | (while (and overlay |
| 141 | (setq overlays (cdr overlays)) | 152 | (not (setq glyph (overlay-get overlay 'glyph)))) |
| 142 | (setq overlay (car overlays))) | 153 | (setq overlays (cdr overlays)) |
| 143 | (if overlay | 154 | (setq overlay (car overlays))) |
| 144 | (if (overlay-get overlay 'end-glyph) | 155 | (if overlay |
| 145 | (progn | 156 | (if (overlay-get overlay 'end-glyph) |
| 146 | (overlay-put overlay 'end-glyph nil) | 157 | (progn |
| 147 | (overlay-put overlay 'invisible nil)) | 158 | (overlay-put overlay 'end-glyph nil) |
| 148 | (overlay-put overlay 'end-glyph glyph) | 159 | (overlay-put overlay 'invisible nil)) |
| 149 | (overlay-put overlay 'invisible t)))))) | 160 | (overlay-put overlay 'end-glyph glyph) |
| 161 | (overlay-put overlay 'invisible t))))) | ||
| 162 | (t | ||
| 163 | (let* ((overlays (append (overlays-at (1- (point))) | ||
| 164 | (overlays-at (point)))) | ||
| 165 | image) | ||
| 166 | |||
| 167 | ;; Search overlay with an image. | ||
| 168 | (while (and overlays (null image)) | ||
| 169 | (let ((prop (overlay-get (car overlays) 'eudc-image))) | ||
| 170 | (if (imagep prop) | ||
| 171 | (setq image prop) | ||
| 172 | (setq overlays (cdr overlays))))) | ||
| 173 | |||
| 174 | ;; Toggle that overlay's image display. | ||
| 175 | (when overlays | ||
| 176 | (let ((overlay (car overlays))) | ||
| 177 | (overlay-put overlay 'display | ||
| 178 | (if (overlay-get overlay 'display) | ||
| 179 | nil image))))))))) | ||
| 150 | 180 | ||
| 151 | (defun eudc-bob-display-audio (data) | 181 | (defun eudc-bob-display-audio (data) |
| 152 | "Display a button for audio DATA." | 182 | "Display a button for audio DATA." |
| @@ -158,7 +188,6 @@ display a button." | |||
| 158 | 'end-open t | 188 | 'end-open t |
| 159 | 'object-data data))) | 189 | 'object-data data))) |
| 160 | 190 | ||
| 161 | |||
| 162 | (defun eudc-bob-display-generic-binary (data) | 191 | (defun eudc-bob-display-generic-binary (data) |
| 163 | "Display a button for unidentified binary DATA." | 192 | "Display a button for unidentified binary DATA." |
| 164 | (eudc-bob-make-button "[Binary Data]" | 193 | (eudc-bob-make-button "[Binary Data]" |
| @@ -175,17 +204,22 @@ display a button." | |||
| 175 | (let (sound) | 204 | (let (sound) |
| 176 | (if (null (setq sound (eudc-bob-get-overlay-prop 'object-data))) | 205 | (if (null (setq sound (eudc-bob-get-overlay-prop 'object-data))) |
| 177 | (error "No sound data available here") | 206 | (error "No sound data available here") |
| 178 | (if (not (and (boundp 'sound-alist) | 207 | (cond (eudc-xemacs-p |
| 179 | sound-alist)) | 208 | (if (not (and (boundp 'sound-alist) |
| 180 | (error "Don't know how to play sound on this Emacs version") | 209 | sound-alist)) |
| 181 | (setq sound-alist | 210 | (error "Don't know how to play sound on this Emacs version") |
| 182 | (cons (list 'eudc-sound | 211 | (setq sound-alist |
| 183 | :sound sound) | 212 | (cons (list 'eudc-sound |
| 184 | sound-alist)) | 213 | :sound sound) |
| 185 | (condition-case nil | 214 | sound-alist)) |
| 186 | (play-sound 'eudc-sound) | 215 | (condition-case nil |
| 187 | (t | 216 | (play-sound 'eudc-sound) |
| 188 | (setq sound-alist (cdr sound-alist)))))))) | 217 | (t |
| 218 | (setq sound-alist (cdr sound-alist)))))) | ||
| 219 | (t | ||
| 220 | (unless (fboundp 'play-sound) | ||
| 221 | (error "Playing sounds not supported on this system")) | ||
| 222 | (play-sound (list 'sound :data sound))))))) | ||
| 189 | 223 | ||
| 190 | 224 | ||
| 191 | (defun eudc-bob-play-sound-at-mouse (event) | 225 | (defun eudc-bob-play-sound-at-mouse (event) |