1 ;;; riece-toolbar.el --- display toolbar icons
2 ;; Copyright (C) 1998-2004 Daiki Ueno
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
6 ;; Keywords: IRC, riece
8 ;; This file is part of Riece.
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
27 ;; Image files are taken from GNOME stock icons:
28 ;; riece-command-next-channel.xpm stock_next.png
29 ;; riece-command-previous-channel.xpm stock_previous.png
30 ;; riece-command-configure-windows.xpm stock_refresh.png
31 ;; riece-command-list-addons stock_styles.png
32 ;; riece-command-join stock_people.png
33 ;; riece-command-part stock_calc-cancel.png
34 ;; riece-command-quit stock_exit.png
36 ;; NOTE: This is an add-on module for Riece.
42 (defconst riece-toolbar-description
43 "Display toolbar icons.")
45 (defvar riece-toolbar-items
46 '(riece-command-previous-channel
47 riece-command-next-channel
48 riece-command-configure-windows
49 riece-command-list-addons
54 (defun riece-toolbar-find-menu-item (command)
55 (let ((pointer riece-menu-items)
58 (if (and (not (stringp (car pointer)))
59 (vectorp (car pointer))
60 (eq (aref (car pointer) 1) command))
61 (setq item (car pointer)
63 (setq pointer (cdr pointer))))
67 (if (featurep 'xemacs)
68 (if (featurep 'toolbar)
70 (defun riece-make-toolbar-from-menu (items menu-items map)
76 (setq file (locate-file (symbol-name (car pointer))
77 (cons riece-data-directory load-path)
78 '(".xpm" ".pbm" ".xbm"))
79 menu-item (riece-toolbar-find-menu-item (car pointer)))
80 (if (and file (file-exists-p file))
89 (symbol-name (car pointer)))))))
90 (setq pointer (cdr pointer)))
92 (defvar riece-toolbar-original-toolbar nil)
93 (defun riece-set-toolbar (toolbar)
94 (make-local-variable 'riece-toolbar-original-toolbar)
95 (setq riece-toolbar-original-toolbar
96 (specifier-specs default-toolbar (current-buffer)))
97 (set-specifier default-toolbar toolbar (current-buffer)))
98 (defun riece-unset-toolbar ()
99 (if riece-toolbar-original-toolbar
100 (set-specifier default-toolbar riece-toolbar-original-toolbar
102 (remove-specifier default-toolbar (current-buffer)))
103 (kill-local-variable 'riece-toolbar-original-toolbar)))
104 (defalias 'riece-make-toolbar-from-menu 'ignore)
105 (defalias 'riece-set-toolbar 'ignore)
106 (defalias 'riece-unset-toolbar 'ignore))
107 (defun riece-make-toolbar-from-menu (items menu-items map)
108 (let ((pointer items)
109 (tool-bar-map (make-sparse-keymap)))
111 (tool-bar-add-item-from-menu (car pointer)
112 (symbol-name (car pointer))
114 (setq pointer (cdr pointer)))
116 (defun riece-set-toolbar (toolbar)
117 (make-local-variable 'tool-bar-map)
118 (setq tool-bar-map toolbar))
119 (defun riece-unset-toolbar ()
120 (kill-local-variable 'tool-bar-map))))
122 (defvar riece-command-mode-map)
123 (defun riece-toolbar-command-mode-hook ()
125 (riece-make-toolbar-from-menu
128 riece-command-mode-map)))
130 (defun riece-toolbar-requires ()
133 (defun riece-toolbar-insinuate ()
134 (if riece-command-buffer
135 (with-current-buffer riece-command-buffer
136 (riece-toolbar-command-mode-hook)))
137 (add-hook 'riece-command-mode-hook
138 'riece-toolbar-command-mode-hook t))
140 (defun riece-toolbar-uninstall ()
141 (if riece-command-buffer
142 (with-current-buffer riece-command-buffer
143 (riece-unset-toolbar)))
144 (remove-hook 'riece-command-mode-hook
145 'riece-toolbar-command-mode-hook))
147 (provide 'riece-toolbar)
149 ;;; riece-toolbar.el ends here