all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* pop-up tool-bar
@ 2004-10-07  7:51 Drew Adams
  2004-10-07 11:33 ` Miguel Frasson
  2004-10-07 15:13 ` Stefan Monnier
  0 siblings, 2 replies; 24+ messages in thread
From: Drew Adams @ 2004-10-07  7:51 UTC (permalink / raw)


This code adds a minor mode, `tool-bar-here-mode', which is the same as
`tool-bar-mode', except that it affects only the selected frame.

It also adds a "button" named "Tool Bar" to the far right of the menu-bar
whenever the tool-bar is not visible (both `tool-bar-here-mode' and
`tool-bar-mode' are turned off). You can click the button to pop up the
tool-bar on the selected frame for the execution of a single command
(typically a tool-bar button click). The Tool Bar button is absent whenever
the tool-bar is visible, and vice versa.

The idea is to _conserve frame real estate_ but still have quick access to
the tool-bar: No reason to have a tool-bar on each frame. No reason to have
a tool-bar visible all the time; just pop it up when you need it.

Any interest in adding something like this to Emacs (file tool-bar.el)? It's
not intended to replace `tool-bar-mode'; it's just an alternative for people
who might want to use the tool-bar sometimes but don't want to sacrifice
real estate from every frame all the time.

 - Drew

---------------8<-----------------------------------

(define-key global-map [menu-bar temp-tool-bar]
  '(menu-item "Tool Bar" show-tool-bar-for-one-command
              :visible (and (not tool-bar-mode) (not tool-bar-here-mode))
              :enable (and (not tool-bar-mode) (not tool-bar-here-mode))
              :help "Use tool bar for one command"))

(setq menu-bar-final-items (append menu-bar-final-items (list
'temp-tool-bar)))


(define-minor-mode tool-bar-here-mode
  "Toggle use of the tool bar on this frame only.
With numeric ARG, display the tool bar if and only if ARG is positive.

See `tool-bar-add-item' and `tool-bar-add-item-from-menu' for
conveniently adding tool bar items."
  :init-value nil :global t :group 'mouse :group 'frames
  (and (display-images-p)
       (let ((lines (if tool-bar-here-mode 1 0)))
	 ;; Alter existing frame...
	 (modify-frame-parameters (selected-frame) (list (cons 'tool-bar-lines
lines))))
       (if (and tool-bar-here-mode
		(display-graphic-p)
		(= 1 (length (default-value 'tool-bar-map)))) ; not yet set up
	   (tool-bar-setup))))

(defun show-tool-bar-for-one-command ()
  "Pop up the tool bar so you can click a button.
The tool bar stays visible until one command is executed
\(whether or not it was initiated by clicking a button)."
  (interactive)
  (unwind-protect
      (let (evnt)
        (tool-bar-here-mode 99)         ; Show tool-bar
        (setq evnt (read-event))
        (push evnt unread-command-events))
    (tool-bar-here-mode -99)))          ; Hide tool-bar

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2004-10-11  4:45 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-07  7:51 pop-up tool-bar Drew Adams
2004-10-07 11:33 ` Miguel Frasson
2004-10-07 19:01   ` Drew Adams
2004-10-07 20:07     ` Stefan Monnier
2004-10-07 21:04       ` Drew Adams
2004-10-07 21:44         ` Drew Adams
2004-10-09 15:44           ` Richard Stallman
2004-10-10 19:15             ` Drew Adams
2004-10-08 17:20         ` Drew Adams
2004-10-08 17:39           ` Stefan
2004-10-08 18:24             ` David Kastrup
2004-10-08 19:58               ` Drew Adams
2004-10-08 19:03             ` Drew Adams
2004-10-08 23:12               ` Stefan Monnier
2004-10-09  0:46                 ` Drew Adams
2004-10-11  4:45           ` Drew Adams
2004-10-07 20:08     ` David Kastrup
2004-10-07 20:20       ` Drew Adams
2004-10-07 20:54         ` Stefan Monnier
2004-10-07 20:56         ` David Kastrup
2004-10-08  6:12     ` Miguel Frasson
2004-10-09 15:45       ` Richard Stallman
2004-10-07 15:13 ` Stefan Monnier
2004-10-07 17:15   ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.