]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/idlw-toolbar.el
Arch-tags shouldn't be outline headers.
[gnu-emacs] / lisp / progmodes / idlw-toolbar.el
index 69e386dbb11888804cec5357c93ff4ea2f4721d7..dc28938d5c5c5fab03fcbb6c396d22d4b0959c5a 100644 (file)
@@ -1,10 +1,9 @@
-;;; idlw-toolbar.el --- A debugging toolbar for IDLWAVE
-;; Copyright (c) 1999 Carsten Dominik
-;; Copyright (c) 1999 Free Software Foundation
+;;; idlw-toolbar.el --- a debugging toolbar for IDLWAVE
+;; Copyright (c) 1999, 2000, 2001,2002 Free Software Foundation
 
-;; Author: Carsten Dominik <dominik@strw.leidenuniv.nl>
-;; Version: 3.11
-;; Date: $Date: 2000/01/03 14:26:03 $
+;; Author: Carsten Dominik <dominik@astro.uva.nl>
+;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu>
+;; Version: 4.15
 ;; Keywords: processes
 
 ;; This file is part of GNU Emacs.
 ;; This file implements a debugging toolbar for IDLWAVE.  It requires
 ;; Emacs or XEmacs with toolbar and xpm support.
 
+;; New versions of IDLWAVE, documentation, and more information
+;; available from:
+;;                 http://idlwave.org
+
 \f
 ;;; Code:
 
@@ -44,7 +47,7 @@
                  (featurep 'xpm)                   ; need xpm
                  (featurep 'toolbar))              ; ... and the toolbar
             (and (not (featurep 'xemacs))          ; This is Emacs
-                 (boundp 'toolbar-button-margin)   ; need toolbar
+                 (boundp 'tool-bar-button-margin)   ; need toolbar
                  (fboundp 'image-type-available-p) ; need image stuff
                  (image-type-available-p 'xpm))    ; need xpm
             ))
     (message "Sorry, IDLWAVE xpm toolbar cannot be used on this version of Emacs")
 ;; OK, we can define a toolbar
 
+(defconst idlwave-toolbar-is-possible t
+  "When defined, indicates that a toolbar is possible with this Emacs.")
 (defvar idlwave-toolbar-compile-icon
   (idlwave-toolbar-make-button
    "/* XPM */
 static char * file[] = {
 \"28 28 2 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \".    c #000000000000\",
 \"                            \",
 \"                            \",
@@ -94,7 +99,7 @@ static char * file[] = {
    "/* XPM */
 static char * file[] = {
 \"28 28 3 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \".    c #000000000000\",
 \"R    c #FFFF00000000\",
 \"                            \",
@@ -132,7 +137,7 @@ static char * file[] = {
    "/* XPM */
 static char * file[] = {
 \"28 28 3 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \".    c #000000000000\",
 \"R    c #FFFF00000000\",
 \"                            \",
@@ -170,7 +175,7 @@ static char * file[] = {
    "/* XPM */
 static char * file[] = {
 \"28 28 4 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \"_    c #FFFFFFFFFFFF\",
 \".    c #000000000000\",
 \"R    c #FFFF00000000\",
@@ -210,7 +215,7 @@ static char * file[] = {
    "/* XPM */
 static char * file[] = {
 \"28 28 3 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \".    c #000000000000\",
 \"R    c #FFFF00000000\",
 \"                            \",
@@ -248,7 +253,7 @@ static char * file[] = {
    "/* XPM */
 static char * file[] = {
 \"28 28 4 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \".    c #000000000000\",
 \"X    c #FFFFFFFFFFFF\",
 \"R    c #FFFF00000000\",
@@ -287,7 +292,7 @@ static char * file[] = {
    "/* XPM */
 static char * file[] = {
 \"28 28 2 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \".    c #000000000000\",
 \"                            \",
 \"                            \",
@@ -324,7 +329,7 @@ static char * file[] = {
    "/* XPM */
 static char * file[] = {
 \"28 28 3 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \".    s FgColor c #000000000000\",
 \"G    c #0000BBBB0000\",
 \"                            \",
@@ -362,7 +367,7 @@ static char * file[] = {
    "/* XPM */
 static char * file[] = {
 \"28 28 3 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \".    s FgColor c #000000000000\",
 \"G    c #0000BBBB0000\",
 \"                            \",
@@ -393,14 +398,14 @@ static char * file[] = {
 \"                            \",
 \"                            \",
 \"                            \"};")
-  "The Cont icon.")      
+  "The Cont icon.")
 
 (defvar idlwave-toolbar-to-here-icon
   (idlwave-toolbar-make-button
    "/* XPM */
 static char * file[] = {
 \"28 28 4 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \".    c #000000000000\",
 \"G    c #0000BBBB0000\",
 \"R    c #FFFF00000000\",
@@ -439,7 +444,7 @@ static char * file[] = {
    "/* XPM */
 static char * file[] = {
 \"28 28 3 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \".    c #000000000000\",
 \"G    c #0000BBBB0000\",
 \"                            \",
@@ -477,7 +482,7 @@ static char * file[] = {
    "/* XPM */
 static char * file[] = {
 \"28 28 3 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \".    c #000000000000\",
 \"G    c #0000BBBB0000\",
 \"                            \",
@@ -515,7 +520,7 @@ static char * file[] = {
    "/* XPM */
 static char * file[] = {
 \"28 28 3 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \".    c #000000000000\",
 \"G    c #0000BBBB0000\",
 \"                            \",
@@ -554,7 +559,7 @@ static char * file[] = {
    "/* XPM */
 static char * file[] = {
 \"28 28 2 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \".    c #000000000000\",
 \"                            \",
 \"                            \",
@@ -591,7 +596,7 @@ static char * file[] = {
    "/* XPM */
 static char * file[] = {
 \"28 28 5 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \".    s FgColor c #000000000000\",
 \"_    c #FFFFFFFFFFFF\",
 \"G    c #0000BBBB0000\",
@@ -631,7 +636,7 @@ static char * file[] = {
    "/* XPM */
 static char * file[] = {
 \"28 28 5 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \".    s FgColor c #000000000000\",
 \"_    c #FFFFFFFFFFFF\",
 \"G    c #0000BBBB0000\",
@@ -671,7 +676,7 @@ static char * file[] = {
    "/* XPM */
 static char * file[] = {
 \"28 28 3 1\",
-\"     c #C8C8C8C8C8C8 s backgroundToolBarColor\",
+\"     c None s backgroundToolBarColor\",
 \"G    c #0000BBBB0000\",
 \".    c #000000000000\",
 \"                            \",
@@ -776,12 +781,7 @@ static char * file[] = {
      "Reset IDL (RETALL & CLOSE,/ALL and more)"]
     ))
 
-
-;; Add the toolbar to all open idlwave buffers when the shell starts.
-(add-hook 'idlwave-shell-mode-hook 'idlwave-toolbar-add-everywhere)
-;; Make sure the toolbar will be added to any future idlwave-mode buffers
-(add-hook 'idlwave-mode-hook 'idlwave-toolbar-add)
-;; When the shell exits, remove the special toolbar everywhere.
+;; When the shell exits, arrange to remove the special toolbar everywhere.
 (add-hook 'idlwave-shell-cleanup-hook
          'idlwave-toolbar-remove-everywhere)
 );; End can define toolbar
@@ -789,6 +789,7 @@ static char * file[] = {
 (defun idlwave-toolbar-add ()
   "Add the IDLWAVE toolbar if appropriate."
   (if (and (featurep 'xemacs)    ; This is a noop on Emacs
+          (boundp 'idlwave-toolbar-is-possible)
           (or (eq major-mode 'idlwave-mode)
               (eq major-mode 'idlwave-shell-mode)))
       (set-specifier default-toolbar (cons (current-buffer)
@@ -797,67 +798,80 @@ static char * file[] = {
 (defun idlwave-toolbar-remove ()
   "Add the IDLWAVE toolbar if appropriate."
   (if (and (featurep 'xemacs)    ; This is a noop on Emacs
+          (boundp 'idlwave-toolbar-is-possible)
           (or (eq major-mode 'idlwave-mode)
               (eq major-mode 'idlwave-shell-mode)))
       (remove-specifier default-toolbar (current-buffer))))
 
 (defvar idlwave-shell-mode-map)
+(defvar idlwave-mode-map)
 (defvar idlwave-toolbar-visible nil)
 (defun idlwave-toolbar-add-everywhere ()
   "Add the toolbar in all appropriate buffers."
-  (if (featurep 'xemacs)
-      ;; For XEmacs, map over all buffers to add toolbar
-      (save-excursion
-       (mapcar (lambda (buf)
-                 (set-buffer buf)
-                 (idlwave-toolbar-add))
-               (buffer-list)))
-    ;; For Emacs, add the key definitions to the mode maps
-    (mapcar (lambda (x)
-             (let* ((icon (aref x 0))
-                    (func (aref x 1))
-                    ;;(show (aref x 2))
-                    (help (aref x 3))
-                    (key (vector 'toolbar func))
-                    (def (list 'menu-item
-                               "a"
-                               func
-                               :image (symbol-value icon)
-                               :help help)))
-               (define-key idlwave-mode-map key def)
-               (define-key idlwave-shell-mode-map key def)))
-           (reverse idlwave-toolbar)))
-  (setq idlwave-toolbar-visible t))
+  (when (boundp 'idlwave-toolbar-is-possible)
+
+    ;; First make sure new buffers will get the toolbar
+    (add-hook 'idlwave-mode-hook 'idlwave-toolbar-add)
+    ;; Then add it to all existing buffers
+    (if (featurep 'xemacs)
+       ;; For XEmacs, map over all buffers to add toolbar
+       (save-excursion
+         (mapcar (lambda (buf)
+                   (set-buffer buf)
+                   (idlwave-toolbar-add))
+                 (buffer-list)))
+      ;; For Emacs, add the key definitions to the mode maps
+      (mapcar (lambda (x)
+               (let* ((icon (aref x 0))
+                      (func (aref x 1))
+                      ;;(show (aref x 2))
+                      (help (aref x 3))
+                      (key (vector 'tool-bar func))
+                      (def (list 'menu-item
+                                 "a"
+                                 func
+                                 :image (symbol-value icon)
+                                 :help help)))
+                 (define-key idlwave-mode-map key def)
+                 (define-key idlwave-shell-mode-map key def)))
+             (reverse idlwave-toolbar)))
+    (setq idlwave-toolbar-visible t)))
 
 (defun idlwave-toolbar-remove-everywhere ()
   "Remove the toolbar in all appropriate buffers."
   ;; First make sure new buffers won't get the toolbar
-  (remove-hook 'idlwave-mode-hook 'idlwave-toolbar-add)
-  ;; Then remove it in all existing buffers.
-  (if (featurep 'xemacs)
-      ;; For XEmacs, map over all buffers to remove toolbar
-      (save-excursion
-       (mapcar (lambda (buf)
-                 (set-buffer buf)
-                 (idlwave-toolbar-remove))
-               (buffer-list)))
-    ;; For Emacs, remove the key definitions from the mode maps
-    (mapcar (lambda (x)
-             (let* (;;(icon (aref x 0))
-                    (func (aref x 1))
-                    ;;(show (aref x 2))
-                    ;;(help (aref x 3))
-                    (key (vector 'toolbar func)))
-               (define-key idlwave-mode-map key nil)
-               (define-key idlwave-shell-mode-map key nil)))
-           idlwave-toolbar))
-  (setq idlwave-toolbar-visible nil))
-
-(defun idlwave-toolbar-toggle ()
+  (when idlwave-toolbar-is-possible
+    (remove-hook 'idlwave-mode-hook 'idlwave-toolbar-add)
+    ;; Then remove it in all existing buffers.
+    (if (featurep 'xemacs)
+       ;; For XEmacs, map over all buffers to remove toolbar
+       (save-excursion
+         (mapcar (lambda (buf)
+                   (set-buffer buf)
+                   (idlwave-toolbar-remove))
+                 (buffer-list)))
+      ;; For Emacs, remove the key definitions from the mode maps
+      (mapcar (lambda (x)
+               (let* (;;(icon (aref x 0))
+                      (func (aref x 1))
+                      ;;(show (aref x 2))
+                      ;;(help (aref x 3))
+                      (key (vector 'tool-bar func)))
+                 (define-key idlwave-mode-map key nil)
+                 (define-key idlwave-shell-mode-map key nil)))
+             idlwave-toolbar))
+    (setq idlwave-toolbar-visible nil)))
+
+(defun idlwave-toolbar-toggle (&optional force-on)
   (interactive)
   (if idlwave-toolbar-visible
-      (idlwave-toolbar-remove-everywhere)
-    (idlwave-toolbar-add-everywhere)))
+      (or force-on (idlwave-toolbar-remove-everywhere))
+    (idlwave-toolbar-add-everywhere))
+  ;; Now make sure this
+  (if (featurep 'xemacs)
+      nil ; no action necessary, toolbar gets updated automatically
+    ;; On Emacs, redraw the frame to make sure the Toolbar is updated.
+    (redraw-frame (selected-frame))))
 
 (provide 'idlw-toolbar)
 (provide 'idlwave-toolbar)
@@ -865,3 +879,4 @@ static char * file[] = {
 ;;; idlw-toolbar.el ends here
 
 
+;;; arch-tag: ec9a3717-c44c-4716-9bda-cdacbe5ddb62