all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
Subject: RE: pop-up tool-bar
Date: Sun, 10 Oct 2004 21:45:28 -0700	[thread overview]
Message-ID: <FDELKNEBLPKKDCEBEJCBAEEPCIAA.drew.adams@oracle.com> (raw)
In-Reply-To: <MEEKKIABFKKDFJMPIOEBAELECGAA.drew.adams@oracle.com>

[-- Attachment #1: Type: text/plain, Size: 346 bytes --]

For those interested, attached is a new patch for the pop-up tool-bar
implementation that I sent previously. It fixes a minor bug (scroll-down
when bobp).

To use: patch the standard file tool-bar.el, load it, and `M-x
tool-bar-popup-mode'. Then click "Buttons" in the menu-bar to pop up the
tool-bar for a single command (button click).  - Drew

[-- Attachment #2: diff-tool-bar-pop-up-10-10.txt --]
[-- Type: text/plain, Size: 4411 bytes --]

cd c:/drews-lisp-20/
diff -c "c:/emacs-21.3.50/lisp/toolbar/tool-bar.el" "c:/drews-lisp-20/tool-bar-w-popup-10-10.el"
*** c:/emacs-21.3.50/lisp/toolbar/tool-bar.el	Mon Jul 26 09:42:32 2004
--- c:/drews-lisp-20/tool-bar-w-popup-10-10.el	Sun Oct 10 21:23:58 2004
***************
*** 40,45 ****
--- 40,49 ----
  
  ;;; Code:
  
+ 
+ \f
+ ;;; Global Tool Bar Mode ------------------------
+ 
  ;;;###autoload
  (define-minor-mode tool-bar-mode
    "Toggle use of the tool bar.
***************
*** 266,271 ****
--- 270,367 ----
  		     :help "Pop up the Help menu")
    )
  
+ 
+ 
+ \f
+ ;;; Local Tool Bar Mode -------------------------
+ 
+ (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))))
+ 
+ (make-variable-frame-local 'tool-bar-here-mode)
+ 
+ 
+ \f
+ ;;; Pop-Up Tool Bar Mode ------------------------
+ 
+ ;; If either of the normal tool-bar modes is turned on, then
+ ;; `tool-bar-popup-mode' is not available.
+ (define-key global-map [menu-bar pop-up-tool-bar]
+   '(menu-item
+     "Buttons" show-tool-bar-for-one-command
+     :visible (and tool-bar-pop-up-mode (not tool-bar-mode) (not tool-bar-here-mode))
+     :enable  (and tool-bar-pop-up-mode (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 'pop-up-tool-bar)))
+ 
+ 
+ 
+ (define-minor-mode tool-bar-pop-up-mode
+   "Toggle tool-bar pop-up.
+ With numeric ARG, turn on tool-bar pop-up if and only if ARG is positive.
+ 
+ Note: Command `tool-bar-pop-up-mode' functions as a toggle only
+       if neither `tool-bar-mode' nor `tool-bar-here-mode' is on.
+ 
+       If either of those modes is on, then command
+       `tool-bar-pop-up-mode' turns them both off and turns
+       `tool-bar-pop-up-mode' on."
+   :init-value nil :global t :group 'mouse :group 'frames
+   (when (or tool-bar-mode tool-bar-here-mode)
+     (setq tool-bar-pop-up-mode t)
+     (tool-bar-mode -99)
+     (tool-bar-here-mode -99)))
+ 
+ 
+ ;; Note: This treats mouse events specially: it scrolls the buffer
+ ;; text (window) down to compensate for the disappearance of the
+ ;; tool-bar.  That is, it replaces the tool-bar with an equivalent
+ ;; number of lines of buffer text.
+ ;;
+ ;; The reason for this is so that where you click the mouse when the
+ ;; tool-bar is visible corresponds to where the mouse is after the
+ ;; tool-bar disappears. Otherwise, the buffer text moves up, relative
+ ;; to the mouse, and a region is selected (without ever physically
+ ;; moving the mouse).
+ ;;
+ (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)
+   (unless tool-bar-pop-up-mode
+     (error "You must turn on `tool-bar-pop-up-mode' to use this command"))
+   (let (evnt tb-lines)
+     (unwind-protect
+         (progn
+           (tool-bar-here-mode 99)     ; Show tool-bar
+           (setq evnt (read-event))
+           (push evnt unread-command-events))
+       (when (and (consp evnt)
+                  (member (event-basic-type (car evnt)) '(mouse-1 mouse-2 mouse-3)))
+         (setq tb-lines (cdr (assq 'tool-bar-lines (frame-parameters (selected-frame)))))
+         (condition-case nil
+             (when tb-lines (scroll-down tb-lines))
+           (error (tool-bar-here-mode -99)))) ; E.g. "Beginning of buffer" error
+       (tool-bar-here-mode -99))))     ; Hide tool-bar
+ 
+ 
+ ;;;;;;;;;;;;;;;;;;
+ 
  (provide 'tool-bar)
  
  ;;; arch-tag: 15f30f0a-d0d7-4d50-bbb7-f48fd0c8582f

Diff finished at Sun Oct 10 21:24:58

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

  parent reply	other threads:[~2004-10-11  4:45 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=FDELKNEBLPKKDCEBEJCBAEEPCIAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.