1 ;; jabber-menu.el - menu definitions
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 (require 'jabber-autoloads
)
24 (eval-when-compile (require 'cl
))
28 (let ((map (make-sparse-keymap "jabber-menu")))
31 '("Connect" . jabber-connect-all
))
35 '("Next unread message" . jabber-activity-switch-to
))
38 [jabber-menu-disconnect
]
39 '("Disconnect" . jabber-disconnect
))
43 '("Switch to roster" . jabber-switch-to-roster-buffer
))
46 [jabber-menu-customize
]
47 '("Customize" . jabber-customize
))
51 '("Help" . jabber-info
))
55 (cons "Set Status" (make-sparse-keymap "set-status")))
58 [jabber-menu-status jabber-menu-status-chat
]
62 (jabber-send-presence "chat"
63 (jabber-read-with-input-method "status message: " *jabber-current-status
* '*jabber-status-history
*)
64 *jabber-current-priority
*))))
66 [jabber-menu-status jabber-menu-status-dnd
]
70 (jabber-send-presence "dnd"
71 (jabber-read-with-input-method "status message: " *jabber-current-status
* '*jabber-status-history
*)
72 *jabber-current-priority
*))))
74 [jabber-menu-status jabber-menu-status-xa
]
75 '("Extended Away" . jabber-send-xa-presence
))
77 [jabber-menu-status jabber-menu-status-away
]
78 '("Away" . jabber-send-away-presence
))
80 [jabber-menu-status jabber-menu-status-online
]
81 '("Online" . jabber-send-default-presence
))
86 (defcustom jabber-display-menu
'maybe
87 "Decide whether the \"Jabber\" menu is displayed in the menu bar.
89 If nil, never display.
90 If maybe, display if any of `jabber-account-list' or `jabber-connections'
93 :type
'(choice (const :tag
"Never" nil
)
94 (const :tag
"Always" t
)
95 (const :tag
"When any accounts have been configured or connected" maybe
)))
97 (defun jabber-menu (&optional remove
)
98 "Put \"Jabber\" menu on menubar.
99 With prefix argument, remove it."
101 (setq jabber-display-menu
(if remove nil t
))
102 (force-mode-line-update))
103 (make-obsolete 'jabber-menu
"set the variable `jabber-display-menu' instead.")
106 ;; (define-key-after global-map [menu-bar jabber-menu] ...)
107 ;; but that doesn't work in Emacs 21.
109 (define-key-after (lookup-key global-map
[menu-bar
])
111 (list 'menu-item
"Jabber" jabber-menu
112 :visible
'(or (eq jabber-display-menu t
)
113 (and (eq jabber-display-menu
'maybe
)
114 (or jabber-account-list
115 (bound-and-true-p jabber-connections
))))))
117 (defvar jabber-jid-chat-menu nil
118 "Menu items for chat menu")
120 (defvar jabber-jid-info-menu nil
121 "Menu item for info menu")
123 (defvar jabber-jid-roster-menu nil
124 "Menu items for roster menu")
126 (defvar jabber-jid-muc-menu nil
127 "Menu items for MUC menu")
129 (defvar jabber-jid-service-menu nil
130 "Menu items for service menu")
132 (defun jabber-popup-menu (which-menu)
133 "Popup specified menu"
134 (let* ((mouse-event (and (listp last-input-event
) last-input-event
))
135 (choice (widget-choose "Actions" which-menu mouse-event
)))
137 (mouse-set-point mouse-event
))
139 (call-interactively choice
))))
141 (defun jabber-popup-chat-menu ()
144 (jabber-popup-menu jabber-jid-chat-menu
))
146 (defun jabber-popup-info-menu ()
149 (jabber-popup-menu jabber-jid-info-menu
))
151 (defun jabber-popup-roster-menu ()
154 (jabber-popup-menu jabber-jid-roster-menu
))
156 (defun jabber-popup-muc-menu ()
159 (jabber-popup-menu jabber-jid-muc-menu
))
161 (defun jabber-popup-service-menu ()
164 (jabber-popup-menu jabber-jid-service-menu
))
166 (defun jabber-popup-combined-menu ()
167 "Popup combined menu"
169 (jabber-popup-menu (append jabber-jid-chat-menu jabber-jid-info-menu jabber-jid-roster-menu jabber-jid-muc-menu
)))
171 (provide 'jabber-menu
)
173 ;;; arch-tag: 5147f52f-de47-4348-86ff-b799d7a75e3f