X-Git-Url: http://cgit.sxemacs.org/?p=riece;a=blobdiff_plain;f=lisp%2Friece-toolbar.el;h=75bcb2f32b0e364fdecc98d78605a28be46e7c6a;hp=3c076e5b52cfdfefb3771b5fe2ab98786487aa0d;hb=2d1c8282fe0f45703f23a38ae033766d3256fbde;hpb=2244c15ef11848cbc76e818e37a52c22fe359076 diff --git a/lisp/riece-toolbar.el b/lisp/riece-toolbar.el index 3c076e5..75bcb2f 100644 --- a/lisp/riece-toolbar.el +++ b/lisp/riece-toolbar.el @@ -1,4 +1,4 @@ -;;; riece-toolbar.el --- show toolbar icons +;;; riece-toolbar.el --- display toolbar icons ;; Copyright (C) 1998-2004 Daiki Ueno ;; Author: Daiki Ueno @@ -19,20 +19,19 @@ ;; 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: -;; To use, add the following line to your ~/.riece/init.el: -;; (add-to-list 'riece-addons 'riece-toolbar) +;; NOTE: This is an add-on module for Riece. ;;; Code: (require 'riece-menu) (defconst riece-toolbar-description - "Show toolbar icons.") + "Display toolbar icons.") (defvar riece-toolbar-items '(riece-command-quit @@ -80,10 +79,21 @@ (symbol-name (car pointer))))))) (setq pointer (cdr pointer))) toolbar)) + (defvar riece-toolbar-original-toolbar nil) (defun riece-set-toolbar (toolbar) - (set-specifier default-toolbar toolbar (current-buffer)))) + (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-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))) @@ -95,10 +105,12 @@ tool-bar-map)) (defun riece-set-toolbar (toolbar) (make-local-variable 'tool-bar-map) - (setq tool-bar-map toolbar))) + (setq tool-bar-map toolbar)) + (defun riece-unset-toolbar () + (kill-local-variable 'tool-bar-map))) (defvar riece-command-mode-map) -(defun riece-toolbar-insinuate-in-command-buffer () +(defun riece-toolbar-command-mode-hook () (riece-set-toolbar (riece-make-toolbar-from-menu riece-toolbar-items @@ -109,9 +121,18 @@ '(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-insinuate-in-command-buffer - 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)) (provide 'riece-toolbar)