File: toolbar-utils.el

package info (click to toggle)
xemacs20 20.4-13
  • links: PTS
  • area: main
  • in suites: slink
  • size: 67,324 kB
  • ctags: 57,643
  • sloc: lisp: 586,197; ansic: 184,662; sh: 4,296; asm: 3,179; makefile: 2,021; perl: 1,059; csh: 96; sed: 22
file content (90 lines) | stat: -rw-r--r-- 3,196 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
;;; toolbar-utils.el --- Toolbar utility functions for XEmacs

;; Copyright (C) 1997 by Free Software Foundation, Inc.

;; Author: Jeff Miller <jmiller@smart.net>
;; Keywords: extensions

;; This file is part of XEmacs.

;; XEmacs is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; XEmacs is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with XEmacs; see the file COPYING.  If not, write to the Free
;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
;; 02111-1307, USA.

;;; Synched up with: Not in FSF

;;; Commentary:

;; Based largely on edit-toolbar.el by Peter D. Pezaris <pez@dwwc.com>

;;; Code:

;;;###autoload
(defun restore-initial-toolbar ()
  "Restores the default toolbar defined by initial-toolbar-spec."
  (interactive)
  (set-specifier default-toolbar initial-toolbar-spec)
  )

;;;###autoload
(defun toolbar-add-item (item &optional index &optional toolbar-spec)
  "Add a toolbar item ITEM at the first location of the toolbar specifier. 
Optionally, can specify an INDEX position to insert the ITEM.  The default is
to use default-toolbar, but a different specifier can by specified with 
TOOLBAR-SPEC."
  (if (eq  toolbar-spec nil )
      (setq toolbar-spec default-toolbar))
  (let* ((toolbar (specifier-instance toolbar-spec)))
    (if(or (eq index nil) (eq index 0))
	(setq toolbar (cons item toolbar))
      (setcdr (nthcdr (- index 1) toolbar)
	      (cons item (nthcdr index toolbar))))
    (set-specifier toolbar-spec toolbar)
    ))


;;;###autoload
(defun toolbar-kill-item-pos ( index &optional toolbar-spec) 
  "Remove a toolbar item ITEM at the first location of the toolbar specifier.  
Optionally, can specify an INDEX position where to remove the ITEM.  The 
default is to use default-toolbar, but a different specifier can by 
specified with TOOLBAR-SPEC."
  (if (eq toolbar-spec nil ) 
      (setq toolbar-spec default-toolbar)) 
  (let* ((toolbar (specifier-instance toolbar-spec)) 
	 (item (nth index toolbar))) 
    (if (eq index 0) 
	(setq toolbar(cdr toolbar)) 
      (setcdr (nthcdr (1- index) toolbar) 
	      (nthcdr (1+ index) toolbar))) 
    (set-specifier toolbar-spec toolbar) 
    ))

;;;###autoload
(defun toolbar-kill-item ( item &optional toolbar-spec)
  "Remove a toolbar item ITEM at the first location of the toolbar specifier.  
Optionally, can specify an ITEM to remove.  The ITEM must be in form of a 
vector.  The default is to use default-toolbar, but a different specifier 
can by specified with TOOLBAR-SPEC."
  (if (eq  toolbar-spec nil )
      (setq toolbar-spec default-toolbar))
	      (let* ((toolbar (specifier-instance toolbar-spec)) )
    (eval item)
    (set-specifier toolbar-spec (delete item toolbar))
    ))


(provide 'toolbar-utils)

;;; toolbar-utils.el ends here