X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Friece-toolbar.el;h=0f283192be43eb75f631bc1761a6d43eb277ad59;hb=1427368d25257dfe250b57a26e157a35783a8207;hp=fdad3708fa3141fa65709a6fc484dec30aa4f71d;hpb=c467106d5b795c7d25d6f8d9b12ecf2f250777e3;p=elisp%2Friece.git diff --git a/lisp/riece-toolbar.el b/lisp/riece-toolbar.el index fdad370..0f28319 100644 --- a/lisp/riece-toolbar.el +++ b/lisp/riece-toolbar.el @@ -19,11 +19,20 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: +;; Image files are taken from stock icons: + +;; riece-command-next-channel.xpm gtk-go-forward +;; riece-command-previous-channel.xpm gtk-go-back +;; riece-command-configure-windows.xpm gtk-refresh +;; riece-command-list-addons gtk-preferences +;; riece-command-join gtk-new +;; riece-command-part gtk-close + ;; NOTE: This is an add-on module for Riece. ;;; Code: @@ -34,13 +43,12 @@ "Display toolbar icons.") (defvar riece-toolbar-items - '(riece-command-quit - riece-command-join - riece-command-part - riece-command-previous-channel - riece-command-next-channel - riece-command-change-layout - riece-submit-bug-report)) + '((riece-command-previous-channel . "left-arrow") + (riece-command-next-channel . "right-arrow") + (riece-command-configure-windows . "refresh") + (riece-command-join . "new") + (riece-command-part . "close") + (riece-command-list-addons . "preferences"))) (defun riece-toolbar-find-menu-item (command) (let ((pointer riece-menu-items) @@ -54,60 +62,62 @@ (setq pointer (cdr pointer)))) item)) -(if (featurep 'xemacs) - (if (featurep 'toolbar) - (progn - (defun riece-make-toolbar-from-menu (items menu-items map) - (let ((pointer items) - toolbar - file - menu-item) - (while pointer - (setq file (locate-file (symbol-name (car pointer)) - (cons riece-data-directory load-path) - '(".xpm" ".pbm" ".xbm")) - menu-item (riece-toolbar-find-menu-item (car pointer))) - (if (and file (file-exists-p file)) - (setq toolbar - (toolbar-add-item - toolbar - (toolbar-new-button - file - (car pointer) - (if menu-item - (aref menu-item 0) - (symbol-name (car pointer))))))) - (setq pointer (cdr pointer))) - toolbar)) - (defvar riece-toolbar-original-toolbar nil) - (defun riece-set-toolbar (toolbar) - (make-local-variable 'riece-toolbar-original-toolbar) - (setq riece-toolbar-original-toolbar - (specifier-specs default-toolbar (current-buffer))) - (set-specifier default-toolbar toolbar (current-buffer))) - (defun riece-unset-toolbar () - (if riece-toolbar-original-toolbar - (set-specifier default-toolbar riece-toolbar-original-toolbar - (current-buffer)) - (remove-specifier default-toolbar (current-buffer))) - (kill-local-variable 'riece-toolbar-original-toolbar))) - (defalias 'riece-make-toolbar-from-menu 'ignore) - (defalias 'riece-set-toolbar 'ignore) - (defalias 'riece-unset-toolbar 'ignore)) - (defun riece-make-toolbar-from-menu (items menu-items map) - (let ((pointer items) - (tool-bar-map (make-sparse-keymap))) - (while pointer - (tool-bar-add-item-from-menu (car pointer) - (symbol-name (car pointer)) - map) - (setq pointer (cdr pointer))) - tool-bar-map)) - (defun riece-set-toolbar (toolbar) - (make-local-variable 'tool-bar-map) - (setq tool-bar-map toolbar)) - (defun riece-unset-toolbar () - (kill-local-variable 'tool-bar-map))) +(eval-and-compile + (if (featurep 'xemacs) + (if (featurep 'toolbar) + (progn + (defun riece-make-toolbar-from-menu (items menu-items map) + (let ((pointer items) + toolbar + file + menu-item) + (while pointer + (setq file (locate-file (symbol-name (car (car pointer))) + (cons riece-data-directory load-path) + '(".xpm" ".pbm" ".xbm")) + menu-item (riece-toolbar-find-menu-item + (car (car pointer)))) + (if (and file (file-exists-p file)) + (setq toolbar + (toolbar-add-item + toolbar + (toolbar-new-button + file + (car (car pointer)) + (if menu-item + (aref menu-item 0) + (symbol-name (car (car pointer)))))))) + (setq pointer (cdr pointer))) + toolbar)) + (defvar riece-toolbar-original-toolbar nil) + (defun riece-set-toolbar (toolbar) + (make-local-variable 'riece-toolbar-original-toolbar) + (setq riece-toolbar-original-toolbar + (specifier-specs default-toolbar (current-buffer))) + (set-specifier default-toolbar toolbar (current-buffer))) + (defun riece-unset-toolbar () + (if riece-toolbar-original-toolbar + (set-specifier default-toolbar riece-toolbar-original-toolbar + (current-buffer)) + (remove-specifier default-toolbar (current-buffer))) + (kill-local-variable 'riece-toolbar-original-toolbar))) + (defalias 'riece-make-toolbar-from-menu 'ignore) + (defalias 'riece-set-toolbar 'ignore) + (defalias 'riece-unset-toolbar 'ignore)) + (defun riece-make-toolbar-from-menu (items menu-items map) + (let ((pointer items) + (tool-bar-map (make-sparse-keymap))) + (while pointer + (tool-bar-add-item-from-menu (car (car pointer)) + (cdr (car pointer)) + map) + (setq pointer (cdr pointer))) + tool-bar-map)) + (defun riece-set-toolbar (toolbar) + (make-local-variable 'tool-bar-map) + (setq tool-bar-map toolbar)) + (defun riece-unset-toolbar () + (kill-local-variable 'tool-bar-map)))) (defvar riece-command-mode-map) (defun riece-toolbar-command-mode-hook () @@ -121,16 +131,19 @@ '(riece-menu)) (defun riece-toolbar-insinuate () + (if riece-command-buffer + (with-current-buffer riece-command-buffer + (riece-toolbar-command-mode-hook))) (add-hook 'riece-command-mode-hook - 'riece-toolbar-command-mode-hook - t)) + 'riece-toolbar-command-mode-hook t)) (defun riece-toolbar-uninstall () + (if riece-command-buffer + (with-current-buffer riece-command-buffer + (riece-unset-toolbar))) (remove-hook 'riece-command-mode-hook - 'riece-toolbar-command-mode-hook) - (with-current-buffer riece-command-buffer - (riece-unset-toolbar))) + 'riece-toolbar-command-mode-hook)) (provide 'riece-toolbar) -;;; riece-toolbar.el ends here \ No newline at end of file +;;; riece-toolbar.el ends here