1 ;;; emchat-toolbar.el --- A toolbar for EMchat -*-Emacs-Lisp-*-
3 ;; Copyright (C) 2000 - 2011 Steve Youngs
5 ;; Author: Steve Youngs <steve@emchat.org>
6 ;; Maintainer: Steve Youngs <steve@emchat.org>
7 ;; Keywords: emchat, toolbar, comm
9 ;; This file is part of EMchat.
11 ;; Redistribution and use in source and binary forms, with or without
12 ;; modification, are permitted provided that the following conditions
15 ;; 1. Redistributions of source code must retain the above copyright
16 ;; notice, this list of conditions and the following disclaimer.
18 ;; 2. Redistributions in binary form must reproduce the above copyright
19 ;; notice, this list of conditions and the following disclaimer in the
20 ;; documentation and/or other materials provided with the distribution.
22 ;; 3. Neither the name of the author nor the names of any contributors
23 ;; may be used to endorse or promote products derived from this
24 ;; software without specific prior written permission.
26 ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
27 ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28 ;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29 ;; DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
33 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
34 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
35 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
36 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 ;; A toolbar for emchat.
44 (require 'emchat-meta)
45 (require 'emchat-log))
47 (autoload 'emchat-change-password "emchat" nil t)
48 (autoload 'emchat-send-message-alias-here "emchat" nil t)
49 (autoload 'emchat-send-message "emchat" nil t)
50 (autoload 'emchat-send-url-alias-here "emchat" nil t)
51 (autoload 'emchat-send-url "emchat" nil t)
52 (autoload 'emchat-query-info-alias-around "emchat" nil t)
53 (autoload 'emchat-query-info "emchat" nil t)
54 (autoload 'emchat-search "emchat" nil t)
55 (autoload 'emchat-authorize-alias-here "emchat" nil t)
56 (autoload 'emchat-login "emchat" nil t)
57 (autoload 'emchat-logout "emchat" nil t)
58 (autoload 'emchat-exit "emchat" nil t)
62 (defcustom emchat-use-toolbar (if (and (featurep 'toolbar)
66 "*If nil, do not use a toolbar.
67 If it is non-nil, it must be a toolbar. The five valid values are
68 `default-toolbar', `top-toolbar', `bottom-toolbar',
69 `right-toolbar', and `left-toolbar'."
70 :type '(choice (const default-toolbar)
71 (const top-toolbar) (const bottom-toolbar)
72 (const left-toolbar) (const right-toolbar)
73 (const :tag "no toolbar" nil))
74 :group 'emchat-interface)
76 (defvar emchat-password-icon
77 (toolbar-make-button-list
78 (expand-file-name "password.xpm" emchat-glyph-dir))
79 "A password toolbar icon.")
81 (defvar emchat-send-message-here-icon
82 (toolbar-make-button-list
83 (expand-file-name "msg-here.xpm" emchat-glyph-dir))
84 "A send message toolbar icon.")
86 (defvar emchat-send-message-around-icon
87 (toolbar-make-button-list
88 (expand-file-name "msg-around.xpm" emchat-glyph-dir))
89 "A send message toolbar icon.")
91 (defvar emchat-send-url-here-icon
92 (toolbar-make-button-list
93 (expand-file-name "url-here.xpm" emchat-glyph-dir))
94 "A send URL toolbar icon.")
96 (defvar emchat-send-url-around-icon
97 (toolbar-make-button-list
98 (expand-file-name "url-around.xpm" emchat-glyph-dir))
99 "A send URL toolbar icon.")
101 (defvar emchat-query-info-here-icon
102 (toolbar-make-button-list
103 (expand-file-name "info-here.xpm" emchat-glyph-dir))
104 "A query info here toolbar icon.")
106 (defvar emchat-query-info-around-icon
107 (toolbar-make-button-list
108 (expand-file-name "info-around.xpm" emchat-glyph-dir))
109 "A query info here toolbar icon.")
111 (defvar emchat-update-info-icon
112 (toolbar-make-button-list
113 (expand-file-name "upd-info.xpm" emchat-glyph-dir))
114 "A update info toolbar icon.")
116 (defvar emchat-search-icon
117 (toolbar-make-button-list
118 (expand-file-name "search.xpm" emchat-glyph-dir))
119 "A search toolbar icon.")
121 (defvar emchat-authorize-here-icon
122 (toolbar-make-button-list
123 (expand-file-name "auth-here.xpm" emchat-glyph-dir))
124 "A authorize toolbar icon.")
126 (defvar emchat-login-icon
127 (toolbar-make-button-list
128 (expand-file-name "login.xpm" emchat-glyph-dir))
129 "A login toolbar icon.")
131 (defvar emchat-logout-icon
132 (toolbar-make-button-list
133 (expand-file-name "logout.xpm" emchat-glyph-dir))
134 "A logout toolbar icon.")
136 (defvar emchat-exit-icon
137 (toolbar-make-button-list
138 (expand-file-name "exit.xpm" emchat-glyph-dir))
139 "A exit toolbar icon.")
141 (defvar emchat-new-log-icon
142 (toolbar-make-button-list
143 (expand-file-name "new-log.xpm" emchat-glyph-dir))
144 "New log file toolbar icon.")
146 (defvar emchat-help-icon
147 (toolbar-make-button-list
148 (expand-file-name "help.xpm" emchat-glyph-dir))
149 "A help toolbar icon.")
151 ;; Define the functions for the toolbar
153 (defun emchat-toolbar-change-password (password)
154 "Change PASSWORD from the toolbar."
155 (interactive (list (read-passwd "Password: " 'confirm)))
156 (emchat-change-password password))
158 (defun emchat-toolbar-send-message-here ()
159 "Send message from toolbar."
161 (emchat-send-message-alias-here))
163 (defun emchat-toolbar-send-message-around ()
164 "Send message from toolbar."
166 (emchat-send-message))
168 (defun emchat-toolbar-send-url-here ()
169 "Send URL from the toolbar."
171 (emchat-send-url-alias-here))
173 (defun emchat-toolbar-send-url-around ()
174 "Send URL from the toolbar."
178 (defun emchat-toolbar-query-info-here ()
179 "Query info from the toolbar."
181 (emchat-query-info-alias-around))
183 (defun emchat-toolbar-query-info-around ()
184 "Query info from the toolbar."
188 (defun emchat-toolbar-update-info ()
189 "Update meta info from the toolbar."
191 ;(emchat-update-meta-info))
192 (message-or-box "Sorry, this feature is not yet implemented"))
194 (defun emchat-toolbar-search ()
195 "Search from the toolbar.
197 Prompts for the search terms."
199 (let ((first (read-string "First Name [RET for null]: "))
200 (last (read-string "Last Name [RET for null]: "))
201 (nick (read-string "Nick Name [RET for null]: "))
202 (email (read-string "Email Address [RET for null]: ")))
203 (emchat-search nil first last nick email)))
205 (defun emchat-toolbar-authorize-here ()
206 "Authorize from the toolbar."
208 (emchat-authorize-alias-here))
210 (defun emchat-toolbar-login ()
211 "Login from the toolbar."
215 (defun emchat-toolbar-logout ()
216 "Logout from the toolbar."
220 (defun emchat-toolbar-exit ()
221 "Exit from the toolbar."
225 (defun emchat-toolbar-new-log ()
226 "New log file from the toolbar."
228 (emchat-log-new-file))
230 (defun emchat-toolbar-help ()
231 "Display the EMchat info documentation."
233 (Info-goto-node "(emchat.info)Top"))
235 ;; Now define the toolbar
236 (defvar emchat-log-toolbar
237 '([emchat-password-icon
238 emchat-toolbar-change-password t "Change password"]
239 [emchat-send-message-here-icon
240 emchat-toolbar-send-message-here t "Send message here"]
241 [emchat-send-message-around-icon
242 emchat-toolbar-send-message-around t "Send message..."]
243 [emchat-send-url-here-icon
244 emchat-toolbar-send-url-here t "Send URL here"]
245 [emchat-send-url-around-icon
246 emchat-toolbar-send-url-around t "Send URL..."]
247 [emchat-query-info-here-icon
248 emchat-toolbar-query-info-here t "Query info here"]
249 [emchat-query-info-around-icon
250 emchat-toolbar-query-info-around t "Query info..."]
252 emchat-toolbar-search t "Search"]
253 [emchat-authorize-here-icon
254 emchat-toolbar-authorize-here t "Authorize here"]
256 emchat-toolbar-new-log t "New log file"]
258 emchat-toolbar-login t "Login"]
260 emchat-toolbar-logout t "Logout"]
262 emchat-toolbar-exit t "Exit"]
265 emchat-toolbar-help t "Help"])
266 "A clickety click EMchat log buffer toolbar.")
269 (defun emchat-install-buddy-toolbar ()
270 "Install the toolbar for `emchat-buddy-mode' in EMchat."
271 (and emchat-use-toolbar
272 (set-specifier (symbol-value emchat-use-toolbar)
274 (current-buffer) emchat-log-toolbar))))
277 (defalias 'emchat-install-log-toolbar 'emchat-install-buddy-toolbar)
279 (provide 'emchat-toolbar)
281 ;;; emchat-toolbar.el ends here