;;; emchat-toolbar.el --- A toolbar for EMchat -*-Emacs-Lisp-*- ;; Copyright (C) 2000 - 2011 Steve Youngs ;; Author: Steve Youngs ;; Maintainer: Steve Youngs ;; Keywords: emchat, toolbar, comm ;; This file is part of EMchat. ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions ;; are met: ;; ;; 1. Redistributions of source code must retain the above copyright ;; notice, this list of conditions and the following disclaimer. ;; ;; 2. Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; ;; 3. Neither the name of the author nor the names of any contributors ;; may be used to endorse or promote products derived from this ;; software without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;; Commentary: ;; ;; A toolbar for emchat. ;; (eval-and-compile (require 'emchat-meta) (require 'emchat-log)) (autoload 'emchat-change-password "emchat" nil t) (autoload 'emchat-send-message-alias-here "emchat" nil t) (autoload 'emchat-send-message "emchat" nil t) (autoload 'emchat-send-url-alias-here "emchat" nil t) (autoload 'emchat-send-url "emchat" nil t) (autoload 'emchat-query-info-alias-around "emchat" nil t) (autoload 'emchat-query-info "emchat" nil t) (autoload 'emchat-search "emchat" nil t) (autoload 'emchat-authorize-alias-here "emchat" nil t) (autoload 'emchat-login "emchat" nil t) (autoload 'emchat-logout "emchat" nil t) (autoload 'emchat-exit "emchat" nil t) ;;; Code: (defcustom emchat-use-toolbar (if (and (featurep 'toolbar) (featurep 'xpm)) 'default-toolbar nil) "*If nil, do not use a toolbar. If it is non-nil, it must be a toolbar. The five valid values are `default-toolbar', `top-toolbar', `bottom-toolbar', `right-toolbar', and `left-toolbar'." :type '(choice (const default-toolbar) (const top-toolbar) (const bottom-toolbar) (const left-toolbar) (const right-toolbar) (const :tag "no toolbar" nil)) :group 'emchat-interface) (defvar emchat-password-icon (toolbar-make-button-list (expand-file-name "password.xpm" emchat-glyph-dir)) "A password toolbar icon.") (defvar emchat-send-message-here-icon (toolbar-make-button-list (expand-file-name "msg-here.xpm" emchat-glyph-dir)) "A send message toolbar icon.") (defvar emchat-send-message-around-icon (toolbar-make-button-list (expand-file-name "msg-around.xpm" emchat-glyph-dir)) "A send message toolbar icon.") (defvar emchat-send-url-here-icon (toolbar-make-button-list (expand-file-name "url-here.xpm" emchat-glyph-dir)) "A send URL toolbar icon.") (defvar emchat-send-url-around-icon (toolbar-make-button-list (expand-file-name "url-around.xpm" emchat-glyph-dir)) "A send URL toolbar icon.") (defvar emchat-query-info-here-icon (toolbar-make-button-list (expand-file-name "info-here.xpm" emchat-glyph-dir)) "A query info here toolbar icon.") (defvar emchat-query-info-around-icon (toolbar-make-button-list (expand-file-name "info-around.xpm" emchat-glyph-dir)) "A query info here toolbar icon.") (defvar emchat-update-info-icon (toolbar-make-button-list (expand-file-name "upd-info.xpm" emchat-glyph-dir)) "A update info toolbar icon.") (defvar emchat-search-icon (toolbar-make-button-list (expand-file-name "search.xpm" emchat-glyph-dir)) "A search toolbar icon.") (defvar emchat-authorize-here-icon (toolbar-make-button-list (expand-file-name "auth-here.xpm" emchat-glyph-dir)) "A authorize toolbar icon.") (defvar emchat-login-icon (toolbar-make-button-list (expand-file-name "login.xpm" emchat-glyph-dir)) "A login toolbar icon.") (defvar emchat-logout-icon (toolbar-make-button-list (expand-file-name "logout.xpm" emchat-glyph-dir)) "A logout toolbar icon.") (defvar emchat-exit-icon (toolbar-make-button-list (expand-file-name "exit.xpm" emchat-glyph-dir)) "A exit toolbar icon.") (defvar emchat-new-log-icon (toolbar-make-button-list (expand-file-name "new-log.xpm" emchat-glyph-dir)) "New log file toolbar icon.") (defvar emchat-help-icon (toolbar-make-button-list (expand-file-name "help.xpm" emchat-glyph-dir)) "A help toolbar icon.") ;; Define the functions for the toolbar (defun emchat-toolbar-change-password (password) "Change PASSWORD from the toolbar." (interactive (list (read-passwd "Password: " 'confirm))) (emchat-change-password password)) (defun emchat-toolbar-send-message-here () "Send message from toolbar." (interactive) (emchat-send-message-alias-here)) (defun emchat-toolbar-send-message-around () "Send message from toolbar." (interactive) (emchat-send-message)) (defun emchat-toolbar-send-url-here () "Send URL from the toolbar." (interactive) (emchat-send-url-alias-here)) (defun emchat-toolbar-send-url-around () "Send URL from the toolbar." (interactive) (emchat-send-url)) (defun emchat-toolbar-query-info-here () "Query info from the toolbar." (interactive) (emchat-query-info-alias-around)) (defun emchat-toolbar-query-info-around () "Query info from the toolbar." (interactive) (emchat-query-info)) (defun emchat-toolbar-update-info () "Update meta info from the toolbar." (interactive) ;(emchat-update-meta-info)) (message-or-box "Sorry, this feature is not yet implemented")) (defun emchat-toolbar-search () "Search from the toolbar. Prompts for the search terms." (interactive) (let ((first (read-string "First Name [RET for null]: ")) (last (read-string "Last Name [RET for null]: ")) (nick (read-string "Nick Name [RET for null]: ")) (email (read-string "Email Address [RET for null]: "))) (emchat-search nil first last nick email))) (defun emchat-toolbar-authorize-here () "Authorize from the toolbar." (interactive) (emchat-authorize-alias-here)) (defun emchat-toolbar-login () "Login from the toolbar." (interactive) (emchat-login)) (defun emchat-toolbar-logout () "Logout from the toolbar." (interactive) (emchat-logout)) (defun emchat-toolbar-exit () "Exit from the toolbar." (interactive) (emchat-exit)) (defun emchat-toolbar-new-log () "New log file from the toolbar." (interactive) (emchat-log-new-file)) (defun emchat-toolbar-help () "Display the EMchat info documentation." (interactive) (Info-goto-node "(emchat.info)Top")) ;; Now define the toolbar (defvar emchat-log-toolbar '([emchat-password-icon emchat-toolbar-change-password t "Change password"] [emchat-send-message-here-icon emchat-toolbar-send-message-here t "Send message here"] [emchat-send-message-around-icon emchat-toolbar-send-message-around t "Send message..."] [emchat-send-url-here-icon emchat-toolbar-send-url-here t "Send URL here"] [emchat-send-url-around-icon emchat-toolbar-send-url-around t "Send URL..."] [emchat-query-info-here-icon emchat-toolbar-query-info-here t "Query info here"] [emchat-query-info-around-icon emchat-toolbar-query-info-around t "Query info..."] [emchat-search-icon emchat-toolbar-search t "Search"] [emchat-authorize-here-icon emchat-toolbar-authorize-here t "Authorize here"] [emchat-new-log-icon emchat-toolbar-new-log t "New log file"] [emchat-login-icon emchat-toolbar-login t "Login"] [emchat-logout-icon emchat-toolbar-logout t "Logout"] [emchat-exit-icon emchat-toolbar-exit t "Exit"] nil [emchat-help-icon emchat-toolbar-help t "Help"]) "A clickety click EMchat log buffer toolbar.") ;;;###autoload (defun emchat-install-buddy-toolbar () "Install the toolbar for `emchat-buddy-mode' in EMchat." (and emchat-use-toolbar (set-specifier (symbol-value emchat-use-toolbar) (cons (current-buffer) emchat-log-toolbar)))) ;;;###autoload (defalias 'emchat-install-log-toolbar 'emchat-install-buddy-toolbar) (provide 'emchat-toolbar) ;;; emchat-toolbar.el ends here