* gnus-sum.el (gnus-summary-tool-bar)
authorReiner Steib <Reiner.Steib@gmx.de>
Wed, 25 Jan 2006 15:42:40 +0000 (15:42 +0000)
committerReiner Steib <Reiner.Steib@gmx.de>
Wed, 25 Jan 2006 15:42:40 +0000 (15:42 +0000)
(gnus-summary-tool-bar-gnome, gnus-summary-tool-bar-retro)
(gnus-summary-tool-bar-zap-list): New variables.
(gnus-summary-make-tool-bar): Complete rewrite using
`gmm-tool-bar-from-list'.

* gnus-group.el (gnus-group-tool-bar, gnus-group-tool-bar-gnome)
(gnus-group-tool-bar-retro, gnus-group-tool-bar-zap-list): New
variables.
(gnus-group-make-tool-bar): Complete rewrite using
`gmm-tool-bar-from-list'.
(gnus-group-tool-bar-update): New function.

lisp/ChangeLog
lisp/gnus-group.el
lisp/gnus-sum.el

index e703210..3a2b99f 100644 (file)
@@ -1,5 +1,18 @@
 2006-01-25  Reiner Steib  <Reiner.Steib@gmx.de>
 
+       * gnus-sum.el (gnus-summary-tool-bar)
+       (gnus-summary-tool-bar-gnome, gnus-summary-tool-bar-retro)
+       (gnus-summary-tool-bar-zap-list): New variables.
+       (gnus-summary-make-tool-bar): Complete rewrite using
+       `gmm-tool-bar-from-list'.
+
+       * gnus-group.el (gnus-group-tool-bar, gnus-group-tool-bar-gnome)
+       (gnus-group-tool-bar-retro, gnus-group-tool-bar-zap-list): New
+       variables.
+       (gnus-group-make-tool-bar): Complete rewrite using
+       `gmm-tool-bar-from-list'.
+       (gnus-group-tool-bar-update): New function.
+
        * message.el (message-mode-field-menu): Add "Show hidden Headers".
 
 2006-01-25  Katsumi Yamaoka  <yamaoka@jpl.org>
index 3e9b4ed..ae80239 100644 (file)
@@ -39,6 +39,7 @@
 (require 'gnus-range)
 (require 'gnus-win)
 (require 'gnus-undo)
+(require 'gmm-utils)
 (require 'time-date)
 (require 'gnus-ems)
 
@@ -995,36 +996,128 @@ simple manner.")
 
     (gnus-run-hooks 'gnus-group-menu-hook)))
 
-(defvar gnus-group-toolbar-map nil)
-
-;; Emacs 21 tool bar.  Should be no-op otherwise.
-(defun gnus-group-make-tool-bar ()
-  (if (and
-       (condition-case nil (require 'tool-bar) (error nil))
-       (fboundp 'tool-bar-add-item-from-menu)
-       (default-value 'tool-bar-mode)
-       (not gnus-group-toolbar-map))
-      (setq gnus-group-toolbar-map
-           (let ((tool-bar-map (make-sparse-keymap))
-                 (load-path (mm-image-load-path)))
-             (tool-bar-add-item-from-menu
-              'gnus-group-get-new-news "get-news" gnus-group-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-group-get-new-news-this-group "gnntg" gnus-group-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-group-catchup-current "catchup" gnus-group-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-group-describe-group "describe-group" gnus-group-mode-map)
-             (tool-bar-add-item "subscribe" 'gnus-group-subscribe 'subscribe
-                                :help "Subscribe to the current group")
-             (tool-bar-add-item "unsubscribe" 'gnus-group-unsubscribe
-                                'unsubscribe
-                                :help "Unsubscribe from the current group")
-             (tool-bar-add-item-from-menu
-              'gnus-group-exit "exit-gnus" gnus-group-mode-map)
-             tool-bar-map)))
-  (if gnus-group-toolbar-map
-      (set (make-local-variable 'tool-bar-map) gnus-group-toolbar-map)))
+
+(defvar gnus-group-tool-bar-map nil)
+
+(defun gnus-group-tool-bar-update (&optional symbol value)
+  "Update group buffer toolbar.
+Setter function for custom variables."
+  (when symbol
+    (set-default symbol value))
+  ;; (setq-default gnus-group-tool-bar-map nil)
+  ;; (use-local-map gnus-group-mode-map)
+  (when (gnus-alive-p)
+    (with-current-buffer gnus-group-buffer
+      (gnus-group-make-tool-bar t))))
+
+;; The default will be changed when the new icons have been checked in:
+(defcustom gnus-group-tool-bar 'gnus-group-tool-bar-retro
+  "Specifies the Gnus group tool bar.
+
+It can be either a list or a symbol refering to a list.  See
+`gmm-tool-bar-from-list' for the format of the list.  The
+default key map is `gnus-group-mode-map'.
+
+Pre-defined symbols include `gnus-group-tool-bar-gnome' and
+`gnus-group-tool-bar-retro'."
+  :type '(choice (const :tag "GNOME style" gnus-group-tool-bar-gnome)
+                (const :tag "Retro look" gnus-group-tool-bar-retro)
+                (repeat :tag "User defined list" gmm-tool-bar-item)
+                (symbol))
+  :version "23.0" ;; No Gnus
+  :initialize 'custom-initialize-default
+  :set 'gnus-group-tool-bar-update
+  :group 'gnus-group)
+
+(defcustom gnus-group-tool-bar-gnome
+  '((gnus-group-post-news "compose")
+    (gnus-group-get-new-news "inbox") ;; Add... nil :visible gnus-plugged ?
+    ;; FIXME: gnus-*-read-group should have a better help text.
+    (gnus-topic-read-group "open" nil :visible gnus-topic-mode)
+    (gnus-group-read-group "open" nil :visible (not gnus-topic-mode))
+    ;; (gnus-group-find-new-groups "???" nil)
+    (gnus-group-save-newsrc "save")
+    (gnus-group-describe-group "describe")
+    (gnus-group-unsubscribe-current-group "toggle-subscription")
+    ;; (gnus-group-subscribe "subscribe" t
+    ;;                           :help "Subscribe to the current group")
+    ;; (gnus-group-unsubscribe "unsubscribe" t
+    ;;                             :help "Unsubscribe from the current group")
+    ;;
+    ;; Some useful agent icons?  I don't use the agent so agent users should
+    ;; suggest useful commands:
+    (gnus-group-send-queue "outbox" t
+                          :visible (and gnus-agent gnus-plugged)
+                          :help "Send articles from the queue group")
+    (gnus-agent-toggle-plugged "connect" nil
+                              :visible (and gnus-agent (not gnus-plugged)))
+    (gnus-agent-toggle-plugged "disconnect" nil
+                              :visible (and gnus-agent gnus-plugged))
+    ;;
+    (gnus-group-exit "exit-mode")
+    (gnus-info-find-node "help"))
+  "List of functions for the group tool bar (GNOME style).
+
+See `gmm-tool-bar-from-list' for the format of the list."
+  :type '(repeat gmm-tool-bar-item)
+  :version "23.0" ;; No Gnus
+  :initialize 'custom-initialize-default
+  :set 'gnus-group-tool-bar-update
+  :group 'gnus-group)
+
+(defcustom gnus-group-tool-bar-retro
+  '((gnus-group-get-new-news "get-news")
+    (gnus-group-get-new-news-this-group "gnntg")
+    (gnus-group-catchup-current "catchup")
+    (gnus-group-describe-group "describe-group")
+    (gnus-group-subscribe "subscribe" t
+                         :help "Subscribe to the current group")
+    (gnus-group-unsubscribe "unsubscribe" t
+                           :help "Unsubscribe from the current group")
+    (gnus-group-exit "exit-gnus" gnus-group-mode-map))
+  "List of functions for the group tool bar (retro look).
+
+See `gmm-tool-bar-from-list' for the format of the list."
+  :type '(repeat gmm-tool-bar-item)
+  :version "23.0" ;; No Gnus
+  :initialize 'custom-initialize-default
+  :set 'gnus-group-tool-bar-update
+  :group 'gnus-group)
+
+;; FIXME: Moving through the Group buffer (in topic mode) e.g. with C-n
+;; doesn't update the state (enabled/disabled) of the icon
+;; `gnus-group-describe-group'.  After `C-l' the state is correct.
+;; See the following report on emacs-devel
+;; <http://thread.gmane.org/v9acdmrcse.fsf@marauder.physik.uni-ulm.de>:
+;; From: Reiner Steib
+;; Subject: tool bar icons not updated according to :active condition
+;; Newsgroups: gmane.emacs.devel
+;; Date: Mon, 23 Jan 2006 19:59:13 +0100
+;; Message-ID: <v9acdmrcse.fsf@marauder.physik.uni-ulm.de>
+
+(defcustom gnus-group-tool-bar-zap-list t
+  "List of icon items from the global tool bar.
+These items are not displayed in the Gnus group mode tool bar.
+
+See `gmm-tool-bar-from-list' for the format of the list."
+  :type 'gmm-tool-bar-zap-list
+  :version "23.0" ;; No Gnus
+  :initialize 'custom-initialize-default
+  :set 'gnus-group-tool-bar-update
+  :group 'gnus-group)
+
+(defun gnus-group-make-tool-bar (&optional force)
+  "Make a group mode tool bar from `gnus-group-tool-bar'.
+When FORCE, rebuild the tool bar."
+  (when (or (not gnus-group-tool-bar-map) force)
+    (let ((map (when (default-value 'tool-bar-mode)
+                (let ((load-path (mm-image-load-path)))
+                  (gmm-tool-bar-from-list gnus-group-tool-bar
+                                              gnus-group-tool-bar-zap-list
+                                              'gnus-group-mode-map)))))
+      (if map
+         (set (make-local-variable 'tool-bar-map) map))))
+  gnus-group-tool-bar-map)
 
 (defun gnus-group-mode ()
   "Major mode for reading news.
@@ -2248,6 +2341,25 @@ If EXCLUDE-GROUP, do not go to that group."
     (gnus-group-position-point)
     (and best-point (gnus-group-group-name))))
 
+;; Is there something like an after-point-motion-hook?
+;; (inhibit-point-motion-hooks?).  Is there a tool-bar-update function?
+
+;; (defun gnus-group-menu-bar-update ()
+;;   (let* ((buf (list (with-current-buffer gnus-group-buffer
+;;                   (current-buffer))))
+;;      (name (buffer-name (car buf))))
+;;     (setcdr buf
+;;         (if (> (length name) 27)
+;;             (concat (substring name 0 12)
+;;                     "..."
+;;                     (substring name -12))
+;;           name))
+;;     (menu-bar-update-buffers-1 buf)))
+
+;; (defun gnus-group-position-point ()
+;;   (gnus-goto-colon)
+;;   (gnus-group-menu-bar-update))
+
 (defun gnus-group-first-unread-group ()
   "Go to the first group with unread articles."
   (interactive)
index 869d093..67ac5bb 100644 (file)
@@ -38,6 +38,7 @@
 (require 'gnus-int)
 (require 'gnus-undo)
 (require 'gnus-util)
+(require 'gmm-utils)
 (require 'mm-decode)
 (require 'nnoo)
 
@@ -2635,49 +2636,146 @@ gnus-summary-show-article-from-menu-as-charset-%s" cs))))
 
 (defvar gnus-summary-tool-bar-map nil)
 
-;; Emacs 21 tool bar.  Should be no-op otherwise.
-(defun gnus-summary-make-tool-bar ()
-  (if (and (fboundp 'tool-bar-add-item-from-menu)
-          (default-value 'tool-bar-mode)
-          (not gnus-summary-tool-bar-map))
-      (setq gnus-summary-tool-bar-map
-           (let ((tool-bar-map (make-sparse-keymap))
-                 (load-path (mm-image-load-path)))
-             (tool-bar-add-item-from-menu
-              'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-summary-post-news "post" gnus-summary-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-summary-followup "followup" gnus-summary-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-summary-reply "reply" gnus-summary-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-summary-save-article "save-art" gnus-summary-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-summary-catchup "catchup" gnus-summary-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
-             (tool-bar-add-item-from-menu
-              'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
-             tool-bar-map)))
-  (if gnus-summary-tool-bar-map
-      (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
+;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
+;; affect _new_ message buffers.  We might add a function that walks thru all
+;; message-mode buffers and force the update.
+(defun gnus-summary-tool-bar-update (&optional symbol value)
+  "Update summary mode toolbar.
+Setter function for custom variables."
+  (if symbol
+      ;; When used as ":set" function:
+      (progn
+       (set-default symbol value)
+       (setq-default gnus-summary-tool-bar-map nil))
+    (gnus-summary-make-tool-bar t)))
+
+;; The default will be changed when the new icons have been checked in:
+(defcustom gnus-summary-tool-bar 'gnus-summary-tool-bar-retro
+  "Specifies the Gnus summary tool bar.
+
+It can be either a list or a symbol refering to a list.  See
+`gmm-tool-bar-from-list' for the format of the list.  The
+default key map is `gnus-summary-mode-map'.
+
+Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
+`gnus-summary-tool-bar-retro'."
+  :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
+                (const :tag "Retro look"  gnus-summary-tool-bar-retro)
+                (repeat :tag "User defined list" gmm-tool-bar-item)
+                (symbol))
+  :version "23.0" ;; No Gnus
+  :initialize 'custom-initialize-default
+  :set 'gnus-summary-tool-bar-update
+  :group 'gnus-summary)
+
+(defcustom gnus-summary-tool-bar-gnome
+  '((gnus-summary-post-news "compose" nil)
+    (gnus-summary-reply-with-original "reply-author")
+    (gnus-summary-reply "reply" nil :visible nil)
+    (gnus-summary-followup-with-original "reply-all")
+    (gnus-summary-followup "reply-all" nil :visible nil)
+    (gnus-summary-mail-forward "forward")
+    (gnus-summary-save-article "save") ;;  stock_mail-copy
+    (gnus-summary-search-article-forward "search")
+    (gnus-summary-print-article "print")
+    ;; gnus-group-read-only-p
+    (gnus-summary-mark-as-expirable
+     "delete" nil
+     :visible (gnus-check-backend-function 'request-expire-articles
+                                          gnus-newsgroup-name))
+    (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
+    (gnus-summary-mark-as-spam
+     "spam" t :visible (spam-group-ham-contents-p gnus-newsgroup-name)
+     :help "Mark as spam")
+    (gnus-summary-mark-as-read-forward
+     "not-spam" nil :visible (spam-group-spam-contents-p gnus-newsgroup-name))
+    ;; Some new commands that may need more suitable icons:
+    (gnus-summary-save-newsrc "save" nil :visible nil)
+    ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
+    (gnus-summary-prev-article "left-arrow" nil :visible nil)  ;; Emacs 22
+    (gnus-summary-next-article "right-arrow" nil :visible nil) ;; Emacs 22
+    (gnus-summary-prev-unread-article "prev-node") ;; Emacs 22
+    (gnus-summary-next-unread-article "next-node") ;; Emacs 22
+    (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
+    ;;
+    ;; Maybe some sort-by-... could be added:
+    (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
+    (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
+    ;;
+    (gnus-summary-insert-new-articles "inbox")
+    ;;
+    (gnus-summary-exit "exit-mode")
+    ;;
+    (gnus-info-find-node "help"))
+  "List of functions for the summary tool bar (GNOME style).
+
+See `gmm-tool-bar-from-list' for the format of the list."
+  :type '(repeat gmm-tool-bar-item)
+  :version "23.0" ;; No Gnus
+  :initialize 'custom-initialize-default
+  :set 'gnus-summary-tool-bar-update
+  :group 'gnus-summary)
+
+(defcustom gnus-summary-tool-bar-retro
+  '((gnus-summary-prev-unread-article "prev-ur")
+    (gnus-summary-next-unread-article "next-ur")
+    (gnus-summary-post-news "post")
+    (gnus-summary-followup-with-original "fuwo")
+    (gnus-summary-followup "followup")
+    (gnus-summary-reply-with-original "reply-wo")
+    (gnus-summary-reply "reply")
+    (gnus-summary-caesar-message "rot13")
+    (gnus-uu-decode-uu "uu-decode")
+    (gnus-summary-save-article-file "save-aif")
+    (gnus-summary-save-article "save-art")
+    (gnus-uu-post-news "uu-post")
+    (gnus-summary-catchup "catchup")
+    (gnus-summary-catchup-and-exit "cu-exit")
+    (gnus-summary-exit "exit-summ")
+    ;; Some new command that may need more suitable icons:
+    (gnus-summary-print-article "print" nil :visible nil)
+    (gnus-summary-mark-as-expirable "close" nil :visible nil)
+    (gnus-summary-save-newsrc "save" nil :visible nil)
+    ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
+    (gnus-summary-search-article-forward "search" nil :visible nil)
+    ;; (gnus-summary-insert-new-articles "paste" nil :visible nil)
+    ;; (gnus-summary-toggle-threads "open" nil :visible nil)
+    ;;
+    (gnus-info-find-node "help" nil :visible nil))
+  "List of functions for the summary tool bar (retro look).
+
+See `gmm-tool-bar-from-list' for the format of the list."
+  :type '(repeat gmm-tool-bar-item)
+  :version "23.0" ;; No Gnus
+  :initialize 'custom-initialize-default
+  :set 'gnus-summary-tool-bar-update
+  :group 'gnus-summary)
+
+(defcustom gnus-summary-tool-bar-zap-list t
+  "List of icon items from the global tool bar.
+These items are not displayed in the Gnus summary mode tool bar.
+
+See `gmm-tool-bar-from-list' for the format of the list."
+  :type 'gmm-tool-bar-zap-list
+  :version "23.0" ;; No Gnus
+  :initialize 'custom-initialize-default
+  :set 'gnus-summary-tool-bar-update
+  :group 'gnus-summary)
+
+(defun gnus-summary-make-tool-bar (&optional force)
+  "Make a summary mode tool bar from `gnus-summary-tool-bar'.
+When FORCE, rebuild the tool bar."
+  (when (or (not gnus-summary-tool-bar-map) force)
+    (let ((map (when (default-value 'tool-bar-mode)
+                (let ((load-path (mm-image-load-path)))
+                  (gmm-tool-bar-from-list gnus-summary-tool-bar
+                                              gnus-summary-tool-bar-zap-list
+                                              'gnus-summary-mode-map)))))
+      (when map
+       ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
+       ;; uses it's value.
+       (setq gnus-summary-tool-bar-map map))))
+  (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
 
 (defun gnus-score-set-default (var value)
   "A version of set that updates the GNU Emacs menu-bar."
@@ -2788,12 +2886,13 @@ The following commands are available:
 \\{gnus-summary-mode-map}"
   (interactive)
   (kill-all-local-variables)
+  (let ((gnus-summary-local-variables gnus-newsgroup-variables))
+    (gnus-summary-make-local-variables))
+  (gnus-summary-make-local-variables)
+  (setq gnus-newsgroup-name group)
   (when (gnus-visual-p 'summary-menu 'menu)
     (gnus-summary-make-menu-bar)
     (gnus-summary-make-tool-bar))
-  (gnus-summary-make-local-variables)
-  (let ((gnus-summary-local-variables gnus-newsgroup-variables))
-    (gnus-summary-make-local-variables))
   (gnus-make-thread-indent-array)
   (gnus-simplify-mode-line)
   (setq major-mode 'gnus-summary-mode)
@@ -2808,7 +2907,6 @@ The following commands are available:
   (setq selective-display-ellipses t)  ;Display `...'
   (gnus-summary-set-display-table)
   (gnus-set-default-directory)
-  (setq gnus-newsgroup-name group)
   (make-local-variable 'gnus-summary-line-format)
   (make-local-variable 'gnus-summary-line-format-spec)
   (make-local-variable 'gnus-summary-dummy-line-format)