1 ;; jabber-menu.el - menu definitions -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2003, 2004, 2008 - Magnus Henoch - mange@freemail.hu
4 ;; Copyright (C) 2002, 2003, 2004 - tom berger - object@intelectronica.net
6 ;; This file is a part of jabber.el.
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program; if not, write to the Free Software
20 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 (require 'jabber-util)
23 (eval-when-compile (require 'cl-lib))
27 (let ((map (make-sparse-keymap "jabber-menu")))
30 '("Connect" . jabber-connect-all))
33 [jabber-menu-disconnect]
34 '(menu-item "Disconnect" jabber-disconnect
35 :enable (bound-and-true-p jabber-connections)))
39 `(menu-item "Set Status" ,(make-sparse-keymap "set-status")
40 :enable (bound-and-true-p jabber-connections)))
43 [jabber-menu-status jabber-menu-status-chat]
48 (jabber-send-presence "chat"
49 (jabber-read-with-input-method "status message: " *jabber-current-status* '*jabber-status-history*)
50 *jabber-current-priority*))
51 :button (:radio . (and (boundp '*jabber-current-show*)
52 (equal *jabber-current-show* "chat")))))
54 [jabber-menu-status jabber-menu-status-dnd]
59 (jabber-send-presence "dnd"
60 (jabber-read-with-input-method "status message: " *jabber-current-status* '*jabber-status-history*)
61 *jabber-current-priority*))
62 :button (:radio . (and (boundp '*jabber-current-show*)
63 (equal *jabber-current-show* "dnd")))))
65 [jabber-menu-status jabber-menu-status-xa]
66 '(menu-item "Extended Away" jabber-send-xa-presence
67 :button (:radio . (and (boundp '*jabber-current-show*)
68 (equal *jabber-current-show* "xa")))))
70 [jabber-menu-status jabber-menu-status-away]
71 '(menu-item "Away" jabber-send-away-presence
72 :button (:radio . (and (boundp '*jabber-current-show*)
73 (equal *jabber-current-show* "away")))))
75 [jabber-menu-status jabber-menu-status-online]
76 '(menu-item "Online" jabber-send-default-presence
77 :button (:radio . (and (boundp '*jabber-current-show*)
78 (equal *jabber-current-show* "")))))
85 [jabber-menu-chat-with]
86 '(menu-item "Chat with..." jabber-chat-with
87 :enable (bound-and-true-p jabber-connections)))
91 '(menu-item "Next unread message" jabber-activity-switch-to
92 :enable (bound-and-true-p jabber-activity-jids)))
95 [jabber-menu-send-subscription-request]
96 '(menu-item "Send subscription request" jabber-send-subscription-request
97 :enable (bound-and-true-p jabber-connections)))
101 '("Switch to roster" . jabber-switch-to-roster-buffer))
103 (define-key-after map
107 (define-key-after map
108 [jabber-menu-customize]
109 '("Customize" . jabber-customize))
111 (define-key-after map
113 '("Help" . jabber-info))
118 (defcustom jabber-display-menu 'maybe
119 "Decide whether the \"Jabber\" menu is displayed in the menu bar.
120 If t, always display.
121 If nil, never display.
122 If maybe, display if jabber.el is installed under `package-user-dir', or
123 if any of `jabber-account-list' or `jabber-connections' is non-nil."
125 :type '(choice (const :tag "Never" nil)
126 (const :tag "Always" t)
127 (const :tag "When installed by user, or when any accounts have been configured or connected" maybe)))
129 (defun jabber-menu (&optional remove)
130 "Put \"Jabber\" menu on menubar.
131 With prefix argument, remove it."
133 (setq jabber-display-menu (if remove nil t))
134 (force-mode-line-update))
135 (make-obsolete 'jabber-menu "set the variable `jabber-display-menu' instead." "27.2")
138 (define-key-after (lookup-key global-map [menu-bar])
140 (list 'menu-item "Jabber" jabber-menu
142 '(or (eq jabber-display-menu t)
143 (and (eq jabber-display-menu 'maybe)
144 (or (bound-and-true-p jabber-account-list)
145 (bound-and-true-p jabber-connections))))))
147 (defvar jabber-jid-chat-menu nil
148 "Menu items for chat menu.")
150 (defvar jabber-jid-info-menu nil
151 "Menu item for info menu.")
153 (defvar jabber-jid-roster-menu nil
154 "Menu items for roster menu.")
156 (defvar jabber-jid-muc-menu nil
157 "Menu items for MUC menu.")
159 (defvar jabber-jid-service-menu nil
160 "Menu items for service menu.")
162 (defun jabber-popup-menu (which-menu)
163 "Popup specified menu."
164 (let* ((mouse-event (and (listp last-input-event) last-input-event))
165 (choice (widget-choose "Actions" which-menu mouse-event)))
167 (mouse-set-point mouse-event))
169 (call-interactively choice))))
171 (defun jabber-popup-chat-menu ()
174 (jabber-popup-menu jabber-jid-chat-menu))
176 (defun jabber-popup-info-menu ()
179 (jabber-popup-menu jabber-jid-info-menu))
181 (defun jabber-popup-roster-menu ()
184 (jabber-popup-menu jabber-jid-roster-menu))
186 (defun jabber-popup-muc-menu ()
189 (jabber-popup-menu jabber-jid-muc-menu))
191 (defun jabber-popup-service-menu ()
192 "Popup service menu."
194 (jabber-popup-menu jabber-jid-service-menu))
196 (defun jabber-popup-combined-menu ()
197 "Popup combined menu."
199 (jabber-popup-menu (append jabber-jid-chat-menu jabber-jid-info-menu jabber-jid-roster-menu jabber-jid-muc-menu)))
201 (provide 'jabber-menu)
203 ;;; arch-tag: 5147f52f-de47-4348-86ff-b799d7a75e3f