*** empty log message ***
[gnus] / lisp / gnus-xmas.el
1 ;;; gnus-xmas.el --- Gnus functions for XEmacs
2 ;; Copyright (C) 1995,96,97,98 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; Keywords: news
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;;; Commentary:
25
26 ;;; Code:
27
28 (require 'text-props)
29 (defvar menu-bar-mode (featurep 'menubar))
30 (require 'messagexmas)
31 (require 'wid-edit)
32
33 (defgroup gnus-xmas nil
34   "XEmacsoid support for Gnus"
35   :group 'gnus)
36
37 (defcustom gnus-xmas-glyph-directory nil
38   "Directory where Gnus logos and icons are located.
39 If this variable is nil, Gnus will try to locate the directory
40 automatically."
41   :type '(choice (const :tag "autodetect" nil)
42                  directory)
43   :group 'gnus-xmas)
44
45 ;;(format "%02x%02x%02x" 114 66 20) "724214"
46
47 (defvar gnus-xmas-logo-color-alist
48   '((flame "#cc3300" "#ff2200")
49     (pine "#c0cc93" "#f8ffb8")
50     (moss "#a1cc93" "#d2ffb8")
51     (irish "#04cc90" "#05ff97")
52     (sky "#049acc" "#05deff")
53     (tin "#6886cc" "#82b6ff")
54     (velvet "#7c68cc" "#8c82ff")
55     (grape "#b264cc" "#cf7df")
56     (labia "#cc64c2" "#fd7dff")
57     (berry "#cc6485" "#ff7db5")
58     (dino "#724214" "#1e3f03")
59     (neutral "#b4b4b4" "#878787")
60     (september "#bf9900" "#ffcc00"))
61   "Color alist used for the Gnus logo.")
62
63 (defcustom gnus-xmas-logo-color-style 'dino
64   "*Color styles used for the Gnus logo."
65   :type '(choice (const flame) (const pine) (const moss)
66                  (const irish) (const sky) (const tin)
67                  (const velvet) (const grape) (const labia)
68                  (const berry) (const neutral) (const september)
69                  (const dino))
70   :group 'gnus-xmas)
71
72 (defvar gnus-xmas-logo-colors
73   (cdr (assq gnus-xmas-logo-color-style gnus-xmas-logo-color-alist))
74   "Colors used for the Gnus logo.")
75
76 (defcustom gnus-article-x-face-command
77   (if (or (featurep 'xface)
78           (featurep 'xpm))
79       'gnus-xmas-article-display-xface
80     "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -")
81   "*String or function to be executed to display an X-Face header.
82 If it is a string, the command will be executed in a sub-shell
83 asynchronously.  The compressed face will be piped to this command."
84   :type '(choice string function))
85
86 ;;; Internal variables.
87
88 ;; Don't warn about these undefined variables.
89
90 (defvar gnus-group-mode-hook)
91 (defvar gnus-summary-mode-hook)
92 (defvar gnus-article-mode-hook)
93
94 ;;defined in gnus.el
95 (defvar gnus-active-hashtb)
96 (defvar gnus-article-buffer)
97 (defvar gnus-auto-center-summary)
98 (defvar gnus-current-headers)
99 (defvar gnus-level-killed)
100 (defvar gnus-level-zombie)
101 (defvar gnus-newsgroup-bookmarks)
102 (defvar gnus-newsgroup-dependencies)
103 (defvar gnus-newsgroup-selected-overlay)
104 (defvar gnus-newsrc-hashtb)
105 (defvar gnus-read-mark)
106 (defvar gnus-refer-article-method)
107 (defvar gnus-reffed-article-number)
108 (defvar gnus-unread-mark)
109 (defvar gnus-version)
110 (defvar gnus-view-pseudos)
111 (defvar gnus-view-pseudos-separately)
112 (defvar gnus-visual)
113 (defvar gnus-zombie-list)
114 ;;defined in gnus-msg.el
115 (defvar gnus-article-copy)
116 (defvar gnus-check-before-posting)
117 ;;defined in gnus-vis.el
118 (defvar gnus-article-button-face)
119 (defvar gnus-article-mouse-face)
120 (defvar gnus-summary-selected-face)
121 (defvar gnus-group-reading-menu)
122 (defvar gnus-group-group-menu)
123 (defvar gnus-group-misc-menu)
124 (defvar gnus-summary-article-menu)
125 (defvar gnus-summary-thread-menu)
126 (defvar gnus-summary-misc-menu)
127 (defvar gnus-summary-post-menu)
128 (defvar gnus-summary-kill-menu)
129 (defvar gnus-article-article-menu)
130 (defvar gnus-article-treatment-menu)
131 (defvar gnus-mouse-2)
132 (defvar standard-display-table)
133 (defvar gnus-tree-minimize-window)
134
135 (defun gnus-xmas-set-text-properties (start end props &optional buffer)
136   "You should NEVER use this function.  It is ideologically blasphemous.
137 It is provided only to ease porting of broken FSF Emacs programs."
138   (if (stringp buffer)
139       nil
140     (map-extents (lambda (extent ignored)
141                    (remove-text-properties
142                     start end
143                     (list (extent-property extent 'text-prop) nil)
144                     buffer)
145                    nil)
146                  buffer start end nil nil 'text-prop)
147     (gnus-add-text-properties start end props buffer)))
148
149 (defun gnus-xmas-highlight-selected-summary ()
150   ;; Highlight selected article in summary buffer
151   (when gnus-summary-selected-face
152     (when gnus-newsgroup-selected-overlay
153       (delete-extent gnus-newsgroup-selected-overlay))
154     (setq gnus-newsgroup-selected-overlay
155           (make-extent (gnus-point-at-bol) (gnus-point-at-eol)))
156     (set-extent-face gnus-newsgroup-selected-overlay
157                      gnus-summary-selected-face)))
158
159 (defcustom gnus-xmas-force-redisplay nil
160   "*If non-nil, force a redisplay before recentering the summary buffer.
161 This is ugly, but it works around a bug in `window-displayed-height'."
162   :type 'boolean
163   :group 'gnus-xmas)
164
165 (defun gnus-xmas-switch-horizontal-scrollbar-off ()
166   (when (featurep 'scrollbar)
167     (set-specifier scrollbar-height (cons (current-buffer) 0))))
168
169 (defun gnus-xmas-summary-recenter ()
170   "\"Center\" point in the summary window.
171 If `gnus-auto-center-summary' is nil, or the article buffer isn't
172 displayed, no centering will be performed."
173   ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
174   ;; Recenter only when requested.  Suggested by popovich@park.cs.columbia.edu.
175   ;; Force redisplay to get properly computed window height.
176   (when gnus-xmas-force-redisplay
177     (sit-for 0))
178   (when gnus-auto-center-summary
179     (let* ((height (if (fboundp 'window-displayed-height)
180                        (window-displayed-height)
181                      (- (window-height) 2)))
182            (top (cond ((< height 4) 0)
183                       ((< height 7) 1)
184                       (t 2)))
185            (bottom (save-excursion (goto-char (point-max))
186                                    (forward-line (- height))
187                                    (point)))
188            (window (get-buffer-window (current-buffer))))
189       (when (get-buffer-window gnus-article-buffer)
190         ;; Only do recentering when the article buffer is displayed,
191         ;; Set the window start to either `bottom', which is the biggest
192         ;; possible valid number, or the second line from the top,
193         ;; whichever is the least.
194         (set-window-start
195          window (min bottom (save-excursion (forward-line (- top)) (point)))))
196       ;; Do horizontal recentering while we're at it.
197       (when (and (get-buffer-window (current-buffer) t)
198                  (not (eq gnus-auto-center-summary 'vertical)))
199         (let ((selected (selected-window)))
200           (select-window (get-buffer-window (current-buffer) t))
201           (gnus-summary-position-point)
202           (gnus-horizontal-recenter)
203           (select-window selected))))))
204
205 (defun gnus-xmas-summary-set-display-table ()
206   ;; Setup the display table -- like `gnus-summary-setup-display-table',
207   ;; but done in an XEmacsish way.
208   (let ((table (make-display-table))
209         (i 32))
210     ;; Nix out all the control chars...
211     (while (>= (setq i (1- i)) 0)
212       (aset table i [??]))
213     ;; ... but not newline and cr, of course.  (cr is necessary for the
214     ;; selective display).
215     (aset table ?\n nil)
216     (aset table ?\r nil)
217     ;; We keep TAB as well.
218     (aset table ?\t nil)
219     ;; We nix out any glyphs over 126 below ctl-arrow.
220     (let ((i (if (integerp ctl-arrow) ctl-arrow 160)))
221       (while (>= (setq i (1- i)) 127)
222         (unless (aref table i)
223           (aset table i [??]))))
224     ;; Can't use `set-specifier' because of a bug in 19.14 and earlier
225     (add-spec-to-specifier current-display-table table (current-buffer) nil)))
226
227 (defun gnus-xmas-add-text-properties (start end props &optional object)
228   (add-text-properties start end props object)
229   (put-text-property start end 'start-closed nil object))
230
231 (defun gnus-xmas-put-text-property (start end prop value &optional object)
232   (put-text-property start end prop value object)
233   (put-text-property start end 'start-closed nil object))
234
235 (defun gnus-xmas-extent-start-open (point)
236   (map-extents (lambda (extent arg)
237                  (set-extent-property extent 'start-open t))
238                nil point (min (1+ (point)) (point-max))))
239
240 (defun gnus-xmas-article-push-button (event)
241   "Check text under the mouse pointer for a callback function.
242 If the text under the mouse pointer has a `gnus-callback' property,
243 call it with the value of the `gnus-data' text property."
244   (interactive "e")
245   (set-buffer (window-buffer (event-window event)))
246   (let* ((pos (event-closest-point event))
247          (data (get-text-property pos 'gnus-data))
248          (fun (get-text-property pos 'gnus-callback)))
249     (when fun
250       (funcall fun data))))
251
252 (defun gnus-xmas-move-overlay (extent start end &optional buffer)
253   (set-extent-endpoints extent start end buffer))
254
255 (defun gnus-xmas-kill-all-overlays ()
256   "Delete all extents in the current buffer."
257   (map-extents (lambda (extent ignore)
258                  (delete-extent extent)
259                  nil)))
260
261 (defun gnus-xmas-window-top-edge (&optional window)
262   (nth 1 (window-pixel-edges window)))
263
264 (defun gnus-xmas-tree-minimize ()
265   (when (and gnus-tree-minimize-window
266              (not (one-window-p)))
267     (let* ((window-min-height 2)
268            (height (1+ (count-lines (point-min) (point-max))))
269            (min (max (1- window-min-height) height))
270            (tot (if (numberp gnus-tree-minimize-window)
271                     (min gnus-tree-minimize-window min)
272                   min))
273            (win (get-buffer-window (current-buffer)))
274            (wh (and win (1- (window-height win)))))
275       (when (and win
276                  (not (eq tot wh)))
277         (let ((selected (selected-window)))
278           (select-window win)
279           (enlarge-window (- tot wh))
280           (select-window selected))))))
281
282 ;; Select the lowest window on the frame.
283 (defun gnus-xmas-appt-select-lowest-window ()
284   (let* ((lowest-window (selected-window))
285          (bottom-edge (car (cdr (cdr (cdr (window-pixel-edges))))))
286          (last-window (previous-window))
287          (window-search t))
288     (while window-search
289       (let* ((this-window (next-window))
290              (next-bottom-edge (car (cdr (cdr (cdr
291                                                (window-pixel-edges
292                                                 this-window)))))))
293         (when (< bottom-edge next-bottom-edge)
294           (setq bottom-edge next-bottom-edge)
295           (setq lowest-window this-window))
296
297         (select-window this-window)
298         (when (eq last-window this-window)
299           (select-window lowest-window)
300           (setq window-search nil))))))
301
302 (defmacro gnus-xmas-menu-add (type &rest menus)
303   `(gnus-xmas-menu-add-1 ',type ',menus))
304 (put 'gnus-xmas-menu-add 'lisp-indent-function 1)
305
306 (defun gnus-xmas-menu-add-1 (type menus)
307   (when (and menu-bar-mode
308              (gnus-visual-p (intern (format "%s-menu" type)) 'menu))
309     (while menus
310       (easy-menu-add (symbol-value (pop menus))))))
311
312 (defun gnus-xmas-group-menu-add ()
313   (gnus-xmas-menu-add group
314     gnus-group-reading-menu gnus-group-group-menu gnus-group-misc-menu))
315
316 (defun gnus-xmas-summary-menu-add ()
317   (gnus-xmas-menu-add summary
318     gnus-summary-misc-menu gnus-summary-kill-menu
319     gnus-summary-article-menu gnus-summary-thread-menu
320     gnus-summary-post-menu ))
321
322 (defun gnus-xmas-article-menu-add ()
323   (gnus-xmas-menu-add article
324     gnus-article-article-menu gnus-article-treatment-menu))
325
326 (defun gnus-xmas-score-menu-add ()
327   (gnus-xmas-menu-add score
328     gnus-score-menu))
329
330 (defun gnus-xmas-pick-menu-add ()
331   (gnus-xmas-menu-add pick
332     gnus-pick-menu))
333
334 (defun gnus-xmas-topic-menu-add ()
335   (gnus-xmas-menu-add topic
336     gnus-topic-menu))
337
338 (defun gnus-xmas-binary-menu-add ()
339   (gnus-xmas-menu-add binary
340     gnus-binary-menu))
341
342 (defun gnus-xmas-agent-summary-menu-add ()
343   (gnus-xmas-menu-add agent-summary
344     gnus-agent-summary-menu))
345
346 (defun gnus-xmas-agent-group-menu-add ()
347   (gnus-xmas-menu-add agent-group
348     gnus-agent-group-menu))
349
350 (defun gnus-xmas-agent-server-menu-add ()
351   (gnus-xmas-menu-add agent-server
352     gnus-agent-server-menu))
353
354 (defun gnus-xmas-tree-menu-add ()
355   (gnus-xmas-menu-add tree
356     gnus-tree-menu))
357
358 (defun gnus-xmas-draft-menu-add ()
359   (gnus-xmas-menu-add draft
360     gnus-draft-menu))
361
362 (defun gnus-xmas-server-menu-add ()
363   (gnus-xmas-menu-add menu
364     gnus-server-server-menu gnus-server-connections-menu))
365
366 (defun gnus-xmas-browse-menu-add ()
367   (gnus-xmas-menu-add browse
368     gnus-browse-menu))
369
370 (defun gnus-xmas-grouplens-menu-add ()
371   (gnus-xmas-menu-add grouplens
372     gnus-grouplens-menu))
373
374 (defun gnus-xmas-read-event-char ()
375   "Get the next event."
376   (let ((event (next-command-event)))
377     (sit-for 0)
378     ;; We junk all non-key events.  Is this naughty?
379     (while (not (or (key-press-event-p event)
380                     (button-press-event-p event)))
381       (dispatch-event event)
382       (setq event (next-command-event)))
383     (cons (and (key-press-event-p event)
384                (event-to-character event))
385           event)))
386
387 (defun gnus-xmas-define ()
388   (setq gnus-mouse-2 [button2])
389   (setq gnus-mouse-3 [button3])
390   (setq gnus-widget-button-keymap widget-button-keymap)
391
392   (unless (memq 'underline (face-list))
393     (and (fboundp 'make-face)
394          (funcall (intern "make-face") 'underline)))
395   ;; Must avoid calling set-face-underline-p directly, because it
396   ;; is a defsubst in emacs19, and will make the .elc files non
397   ;; portable!
398   (unless (face-differs-from-default-p 'underline)
399     (funcall (intern "set-face-underline-p") 'underline t))
400
401   (cond
402    ((fboundp 'char-or-char-int-p)
403     ;; Handle both types of marks for XEmacs-20.x.
404     (fset 'gnus-characterp 'char-or-char-int-p))
405    ;; V19 of XEmacs, probably.
406    (t
407     (fset 'gnus-characterp 'characterp)))
408
409   (fset 'gnus-make-overlay 'make-extent)
410   (fset 'gnus-delete-overlay 'delete-extent)
411   (fset 'gnus-overlay-put 'set-extent-property)
412   (fset 'gnus-move-overlay 'gnus-xmas-move-overlay)
413   (fset 'gnus-overlay-end 'extent-end-position)
414   (fset 'gnus-kill-all-overlays 'gnus-xmas-kill-all-overlays)
415   (fset 'gnus-extent-detached-p 'extent-detached-p)
416   (fset 'gnus-add-text-properties 'gnus-xmas-add-text-properties)
417   (fset 'gnus-put-text-property 'gnus-xmas-put-text-property)
418   (fset 'gnus-deactivate-mark 'ignore)
419   (fset 'gnus-window-edges 'window-pixel-edges)
420
421   (if (and (<= emacs-major-version 19)
422            (< emacs-minor-version 14))
423       (fset 'gnus-set-text-properties 'gnus-xmas-set-text-properties))
424
425   (when (fboundp 'turn-off-scroll-in-place)
426     (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
427
428   (unless (boundp 'standard-display-table)
429     (setq standard-display-table nil))
430
431   (defvar gnus-mouse-face-prop 'highlight)
432
433   (defun gnus-byte-code (func)
434     "Return a form that can be `eval'ed based on FUNC."
435     (let ((fval (indirect-function func)))
436       (if (compiled-function-p fval)
437           (list 'funcall fval)
438         (cons 'progn (cdr (cdr fval))))))
439
440   (fset 'gnus-x-color-values
441         (if (fboundp 'x-color-values)
442             'x-color-values
443           (lambda (color)
444             (color-instance-rgb-components
445              (make-color-instance color))))))
446
447 (defun gnus-xmas-redefine ()
448   "Redefine lots of Gnus functions for XEmacs."
449   (fset 'gnus-summary-set-display-table 'gnus-xmas-summary-set-display-table)
450   (fset 'gnus-visual-turn-off-edit-menu 'identity)
451   (fset 'gnus-summary-recenter 'gnus-xmas-summary-recenter)
452   (fset 'gnus-extent-start-open 'gnus-xmas-extent-start-open)
453   (fset 'gnus-article-push-button 'gnus-xmas-article-push-button)
454   (fset 'gnus-window-top-edge 'gnus-xmas-window-top-edge)
455   (fset 'gnus-read-event-char 'gnus-xmas-read-event-char)
456   (fset 'gnus-group-startup-message 'gnus-xmas-group-startup-message)
457   (fset 'gnus-tree-minimize 'gnus-xmas-tree-minimize)
458   (fset 'gnus-appt-select-lowest-window
459         'gnus-xmas-appt-select-lowest-window)
460   (fset 'gnus-mail-strip-quoted-names 'gnus-xmas-mail-strip-quoted-names)
461   (fset 'gnus-character-to-event 'character-to-event)
462   (fset 'gnus-mode-line-buffer-identification
463         'gnus-xmas-mode-line-buffer-identification)
464   (fset 'gnus-key-press-event-p 'key-press-event-p)
465   (fset 'gnus-region-active-p 'region-active-p)
466   (fset 'gnus-annotation-in-region-p 'gnus-xmas-annotation-in-region-p)
467   (fset 'gnus-mime-button-menu 'gnus-xmas-mime-button-menu)
468   
469   (add-hook 'gnus-group-mode-hook 'gnus-xmas-group-menu-add)
470   (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
471   (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add)
472   (add-hook 'gnus-score-mode-hook 'gnus-xmas-score-menu-add)
473
474   (add-hook 'gnus-pick-mode-hook 'gnus-xmas-pick-menu-add)
475   (add-hook 'gnus-topic-mode-hook 'gnus-xmas-topic-menu-add)
476   (add-hook 'gnus-tree-mode-hook 'gnus-xmas-tree-menu-add)
477   (add-hook 'gnus-binary-mode-hook 'gnus-xmas-binary-menu-add)
478   (add-hook 'gnus-grouplens-mode-hook 'gnus-xmas-grouplens-menu-add)
479   (add-hook 'gnus-server-mode-hook 'gnus-xmas-server-menu-add)
480   (add-hook 'gnus-browse-mode-hook 'gnus-xmas-browse-menu-add)
481
482   (add-hook 'gnus-group-mode-hook 'gnus-xmas-setup-group-toolbar)
483   (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
484
485   (add-hook 'gnus-agent-summary-mode-hook 'gnus-xmas-agent-summary-menu-add)
486   (add-hook 'gnus-agent-group-mode-hook 'gnus-xmas-agent-group-menu-add)
487   (add-hook 'gnus-agent-server-mode-hook 'gnus-xmas-agent-server-menu-add)
488
489   (add-hook 'gnus-draft-mode-hook 'gnus-xmas-draft-menu-add)
490   (add-hook 'gnus-summary-mode-hook
491             'gnus-xmas-switch-horizontal-scrollbar-off)
492   (add-hook 'gnus-tree-mode-hook 'gnus-xmas-switch-horizontal-scrollbar-off))
493
494
495 ;;; XEmacs logo and toolbar.
496
497 (defun gnus-xmas-group-startup-message (&optional x y)
498   "Insert startup message in current buffer."
499   ;; Insert the message.
500   (setq gnus-xmas-glyph-directory (message-xmas-find-glyph-directory "gnus"))
501   (erase-buffer)
502   (cond
503    ((and (console-on-window-system-p)
504          (or (featurep 'xpm)
505              (featurep 'xbm)))
506     (let* ((logo-xpm (expand-file-name "gnus.xpm" gnus-xmas-glyph-directory))
507            (logo-xbm (expand-file-name "gnus.xbm" gnus-xmas-glyph-directory))
508            (glyph (make-glyph
509                    (cond ((featurep 'xpm)
510                           `[xpm
511                             :file ,logo-xpm
512                             :color-symbols
513                             (("thing" . ,(car gnus-xmas-logo-colors))
514                              ("shadow" . ,(cadr gnus-xmas-logo-colors))
515                              ("background" . ,(face-background 'default)))])
516                          ((featurep 'xbm)
517                           `[xbm :file ,logo-xbm])
518                          (t [nothing])))))
519       (insert " ")
520       (set-extent-begin-glyph (make-extent (point) (point)) glyph)
521       (goto-char (point-min))
522       (while (not (eobp))
523         (insert (make-string (/ (max (- (window-width) (or x 35)) 0) 2)
524                              ?\ ))
525         (forward-line 1))
526       (setq gnus-simple-splash nil))
527     (goto-char (point-min))
528     (let* ((pheight (+ 20 (count-lines (point-min) (point-max))))
529            (wheight (window-height))
530            (rest (- wheight pheight)))
531       (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n))))
532    (t
533     (insert
534      (format "              %s
535           _    ___ _             _
536           _ ___ __ ___  __    _ ___
537           __   _     ___    __  ___
538               _           ___     _
539              _  _ __             _
540              ___   __            _
541                    __           _
542                     _      _   _
543                    _      _    _
544                       _  _    _
545                   __  ___
546                  _   _ _     _
547                 _   _
548               _    _
549              _    _
550             _
551           __
552
553 "
554              ""))
555     ;; And then hack it.
556     (gnus-indent-rigidly (point-min) (point-max)
557                          (/ (max (- (window-width) (or x 46)) 0) 2))
558     (goto-char (point-min))
559     (forward-line 1)
560     (let* ((pheight (count-lines (point-min) (point-max)))
561            (wheight (window-height))
562            (rest (- wheight pheight)))
563       (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
564     ;; Paint it.
565     (put-text-property (point-min) (point-max) 'face 'gnus-splash-face)))
566   (setq modeline-buffer-identification
567         (list (concat gnus-version ": *Group*")))
568   (set-buffer-modified-p t))
569
570
571 ;;; The toolbar.
572
573 (defcustom gnus-use-toolbar (if (featurep 'toolbar)
574                                 'default-toolbar
575                               nil)
576   "*If nil, do not use a toolbar.
577 If it is non-nil, it must be a toolbar.  The five legal values are
578 `default-toolbar', `top-toolbar', `bottom-toolbar',
579 `right-toolbar', and `left-toolbar'."
580   :type '(choice (const default-toolbar)
581                  (const top-toolbar) (const bottom-toolbar)
582                  (const left-toolbar) (const right-toolbar)
583                  (const :tag "no toolbar" nil))
584   :group 'gnus-xmas)
585
586 (defvar gnus-group-toolbar
587   '([gnus-group-get-new-news gnus-group-get-new-news t "Get new news"]
588     [gnus-group-get-new-news-this-group
589      gnus-group-get-new-news-this-group t "Get new news in this group"]
590     [gnus-group-catchup-current
591      gnus-group-catchup-current t "Catchup group"]
592     [gnus-group-describe-group
593      gnus-group-describe-group t "Describe group"]
594     [gnus-group-unsubscribe gnus-group-unsubscribe t "Unsubscribe group"]
595     [gnus-group-subscribe gnus-group-subscribe t "Subscribe group"]
596     [gnus-group-kill-group gnus-group-kill-group t "Kill group"]
597     [gnus-group-exit gnus-group-exit t "Exit Gnus"]
598     )
599   "The group buffer toolbar.")
600
601 (defvar gnus-summary-toolbar
602   '([gnus-summary-prev-unread
603      gnus-summary-prev-page-or-article t "Page up"]
604     [gnus-summary-next-unread
605      gnus-summary-next-page t "Page down"]
606     [gnus-summary-post-news
607      gnus-summary-post-news t "Post an article"]
608     [gnus-summary-followup-with-original
609      gnus-summary-followup-with-original t
610      "Post a followup and yank the original"]
611     [gnus-summary-followup
612      gnus-summary-followup t "Post a followup"]
613     [gnus-summary-reply-with-original
614      gnus-summary-reply-with-original t "Mail a reply and yank the original"]
615     [gnus-summary-reply
616      gnus-summary-reply t "Mail a reply"]
617     [gnus-summary-caesar-message
618      gnus-summary-caesar-message t "Rot 13"]
619     [gnus-uu-decode-uu
620      gnus-uu-decode-uu t "Decode uuencoded articles"]
621     [gnus-summary-save-article-file
622      gnus-summary-save-article-file t "Save article in file"]
623     [gnus-summary-save-article
624      gnus-summary-save-article t "Save article"]
625     [gnus-uu-post-news
626      gnus-uu-post-news t "Post a uuencoded article"]
627     [gnus-summary-cancel-article
628      gnus-summary-cancel-article t "Cancel article"]
629     [gnus-summary-catchup
630      gnus-summary-catchup t "Catchup"]
631     [gnus-summary-catchup-and-exit
632      gnus-summary-catchup-and-exit t "Catchup and exit"]
633     [gnus-summary-exit gnus-summary-exit t "Exit this summary"]
634     )
635   "The summary buffer toolbar.")
636
637 (defvar gnus-summary-mail-toolbar
638   '(
639     [gnus-summary-prev-unread
640      gnus-summary-prev-unread-article t "Prev unread article"]
641     [gnus-summary-next-unread
642      gnus-summary-next-unread-article t "Next unread article"]
643     [gnus-summary-mail-reply gnus-summary-reply t "Reply"]
644 ;    [gnus-summary-mail-get gnus-mail-get t "Message get"]
645     [gnus-summary-mail-originate gnus-summary-post-news t "Originate"]
646     [gnus-summary-mail-save gnus-summary-save-article t "Save"]
647     [gnus-summary-mail-copy gnus-summary-copy-article t "Copy message"]
648 ;    [gnus-summary-mail-delete gnus-summary-delete-article t "Delete message"]
649     [gnus-summary-mail-forward gnus-summary-mail-forward t "Forward message"]
650 ;    [gnus-summary-mail-spell gnus-mail-spell t "Spell"]
651 ;    [gnus-summary-mail-help gnus-mail-help  t "Message help"]
652     [gnus-summary-caesar-message
653      gnus-summary-caesar-message t "Rot 13"]
654     [gnus-uu-decode-uu
655      gnus-uu-decode-uu t "Decode uuencoded articles"]
656     [gnus-summary-save-article-file
657      gnus-summary-save-article-file t "Save article in file"]
658     [gnus-summary-save-article
659      gnus-summary-save-article t "Save article"]
660     [gnus-summary-catchup
661      gnus-summary-catchup t "Catchup"]
662     [gnus-summary-catchup-and-exit
663      gnus-summary-catchup-and-exit t "Catchup and exit"]
664     [gnus-summary-exit gnus-summary-exit t "Exit this summary"]
665     )
666   "The summary buffer mail toolbar.")
667
668 (defun gnus-xmas-setup-group-toolbar ()
669   (and gnus-use-toolbar
670        (message-xmas-setup-toolbar gnus-group-toolbar nil "gnus")
671        (set-specifier (symbol-value gnus-use-toolbar)
672                       (cons (current-buffer) gnus-group-toolbar))))
673
674 (defun gnus-xmas-setup-summary-toolbar ()
675   (let ((bar (if (gnus-news-group-p gnus-newsgroup-name)
676                  gnus-summary-toolbar gnus-summary-mail-toolbar)))
677     (and gnus-use-toolbar
678          (message-xmas-setup-toolbar bar nil "gnus")
679          (set-specifier (symbol-value gnus-use-toolbar)
680                         (cons (current-buffer) bar)))))
681
682 (defun gnus-xmas-mail-strip-quoted-names (address)
683   "Protect mail-strip-quoted-names from NIL input.
684 XEmacs compatibility workaround."
685   (if (null address)
686       nil
687     (mail-strip-quoted-names address)))
688
689 (defun gnus-xmas-call-region (command &rest args)
690   (apply
691    'call-process-region (point-min) (point-max) command t '(t nil) nil
692    args))
693
694 (defface gnus-x-face '((t (:foreground "black" :background "white")))
695   "Face to show X face"
696   :group 'gnus-xmas)
697
698 (defun gnus-xmas-article-display-xface (beg end)
699   "Display any XFace headers in the current article."
700   (save-excursion
701     (let ((xface-glyph
702            (cond ((featurep 'xface)
703                   (make-glyph (vector 'xface :data
704                                       (concat "X-Face: "
705                                               (buffer-substring beg end)))))
706                  ((featurep 'xpm)
707                   (let ((cur (current-buffer)))
708                     (save-excursion
709                       (gnus-set-work-buffer)
710                       (insert (format "%s" (buffer-substring beg end cur)))
711                       (gnus-xmas-call-region "uncompface")
712                       (goto-char (point-min))
713                       (insert "/* Width=48, Height=48 */\n")
714                       (gnus-xmas-call-region "icontopbm")
715                       (gnus-xmas-call-region "ppmtoxpm")
716                       (make-glyph
717                        (vector 'xpm :data (buffer-string))))))
718                  (t
719                   (make-glyph [nothing]))))
720           (ext (make-extent (progn
721                               (goto-char (point-min))
722                               (re-search-forward "^From:" nil t)
723                               (point))
724                             (1+ (point)))))
725       (set-glyph-face xface-glyph 'gnus-x-face)
726       (set-extent-begin-glyph ext xface-glyph)
727       (set-extent-property ext 'duplicable t))))
728
729 ;;(defvar gnus-xmas-pointer-glyph
730 ;;  (progn
731 ;;    (setq gnus-xmas-glyph-directory (message-xmas-find-glyph-directory
732 ;;                                     "gnus"))
733 ;;    (let ((file-xpm (expand-file-name "gnus-pointer.xpm"
734 ;;                                    gnus-xmas-glyph-directory))
735 ;;        (file-xbm (expand-file-name "gnus-pointer.xbm"
736 ;;                                    gnus-xmas-glyph-directory)))
737 ;;      (make-pointer-glyph
738 ;;       (list (vector 'xpm ':file file-xpm)
739 ;;           (vector 'xbm ':file file-xbm))))))
740
741 (defvar gnus-xmas-modeline-left-extent
742   (let ((ext (copy-extent modeline-buffer-id-left-extent)))
743 ;    (set-extent-property ext 'pointer gnus-xmas-pointer-glyph)
744     ext))
745
746 (defvar gnus-xmas-modeline-right-extent
747   (let ((ext (copy-extent modeline-buffer-id-right-extent)))
748 ;    (set-extent-property ext 'pointer gnus-xmas-pointer-glyph)
749     ext))
750
751 (defvar gnus-xmas-modeline-glyph
752   (progn
753     (setq gnus-xmas-glyph-directory (message-xmas-find-glyph-directory "gnus"))
754     (let* ((file-xpm (expand-file-name "gnus-pointer.xpm"
755                                        gnus-xmas-glyph-directory))
756            (file-xbm (expand-file-name "gnus-pointer.xbm"
757                                        gnus-xmas-glyph-directory))
758            (glyph (make-glyph
759                    ;; Gag gag gag.
760                    (cond ((featurep 'xpm)
761                           ;; Let's try a nifty XPM
762                           `[xpm :file ,file-xpm])
763                          ((featurep 'xbm)
764                           ;; Then a not-so-nifty XBM
765                           [xbm :file ,file-xbm])
766                          ;; Then the simple string
767                          (t [string :data "Gnus:"])))))
768       (set-glyph-face glyph 'modeline-buffer-id)
769       glyph)))
770
771 (defun gnus-xmas-mode-line-buffer-identification (line)
772   (let ((line (car line))
773         chop)
774     (cond
775      ;; This is some weird type of id.
776      ((not (stringp line))
777       (list line))
778      ;; This is non-standard, so we just pass it through.
779      ((not (string-match "^Gnus:" line))
780       (list line))
781      ;; We have a standard line, so we colorize and glyphize it a bit.
782      (t
783       (setq chop (match-end 0))
784       (list
785        (if gnus-xmas-modeline-glyph
786            (cons gnus-xmas-modeline-left-extent gnus-xmas-modeline-glyph)
787          (cons gnus-xmas-modeline-left-extent (substring line 0 chop)))
788        (cons gnus-xmas-modeline-right-extent (substring line chop)))))))
789
790 (defun gnus-xmas-splash ()
791   (when (eq (device-type) 'x)
792     (gnus-splash)))
793
794 (defun gnus-xmas-annotation-in-region-p (b e)
795   (map-extents (lambda (e u) t) nil b e nil nil 'mm t))
796
797 (defun gnus-xmas-mime-button-menu (event)
798   "Construct a context-sensitive menu of MIME commands."
799   (interactive "e")
800   (let ((response (get-popup-menu-response
801                    `("MIME Part"
802                      ,@(mapcar (lambda (c) `[,(caddr c) ,(car c) t])
803                                gnus-mime-button-commands)))))
804     (set-buffer (event-buffer event))
805     (goto-char (event-point event))
806     (funcall (event-function response) (event-object response))))
807
808
809 (provide 'gnus-xmas)
810
811 ;;; gnus-xmas.el ends here