unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: David Reitter <david.reitter@gmail.com>
Subject: Toolbar patch (OS X)
Date: Sun, 25 Sep 2005 21:25:32 +0100	[thread overview]
Message-ID: <5E6B6577-653A-4DCF-AC6A-10EC020C3548@gmail.com> (raw)


[-- Attachment #1.1.1: Type: text/plain, Size: 507 bytes --]

I'm attaching a patch which enables the toolbar button in the upper  
right corner of each frame. This button is standard in OS X  
applications and allows users to switch the toolbar on and off per  
frame. The actual tool-bar switching functionality is already present  
(frame parameter 'tool-bar-lines), here I'm just enabling the button  
and its event-handling.

This has been in use in a couple of Aquamacs versions (>1500 users  
currently), and the Japanese Carbon Emacs Package is using it too.



[-- Attachment #1.1.2: toolbar-button.patch --]
[-- Type: application/octet-stream, Size: 5544 bytes --]

Index: src/keyboard.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/keyboard.c,v
retrieving revision 1.833
diff -c -r1.833 keyboard.c
*** src/keyboard.c	13 Jul 2005 05:30:56 -0000	1.833
--- src/keyboard.c	17 Jul 2005 20:23:36 -0000
***************
*** 517,522 ****
--- 517,525 ----
  Lisp_Object Qmake_frame_visible;
  Lisp_Object Qselect_window;
  Lisp_Object Qhelp_echo;
+ #ifdef MAC_OSX
+ Lisp_Object Qtoggle_frame_toolbar;
+ #endif
  
  #ifdef HAVE_MOUSE
  Lisp_Object Qmouse_fixup_help_message;
***************
*** 4017,4022 ****
--- 4020,4034 ----
  	  kbd_fetch_ptr = event + 1;
  	}
  #endif
+ #ifdef MAC_OSX
+       else if (event->kind == TOGGLE_TOOLBAR_EVENT)
+ 	{
+ 	  /* Make an event (toggle-frame-toolbar (FRAME)).  */
+ 	  obj = Fcons (event->frame_or_window, Qnil);
+ 	  obj = Fcons (Qtoggle_frame_toolbar, Fcons (obj, Qnil));
+ 	  kbd_fetch_ptr = event + 1;
+ 	}
+ #endif
        else if (event->kind == BUFFER_SWITCH_EVENT)
  	{
  	  /* The value doesn't matter here; only the type is tested.  */
***************
*** 10773,10778 ****
--- 10785,10793 ----
    /* `select-window' should be handled just like `switch-frame'
       in read_key_sequence.  */
    {&Qselect_window,       "select-window",       &Qswitch_frame}
+ #ifdef MAC_OSX
+   ,{&Qtoggle_frame_toolbar,  "toggle-frame-toolbar",  &Qtoggle_frame_toolbar}
+ #endif
  };
  
  void
***************
*** 11436,11441 ****
--- 11451,11458 ----
  
    initial_define_lispy_key (Vspecial_event_map, "delete-frame",
  			    "handle-delete-frame");
+   /* initial_define_lispy_key (Vspecial_event_map, "toggle-frame-toolbar",
+      "handle-toggle-frame-toolbar"); */
    /* Here we used to use `ignore-event' which would simple set prefix-arg to
       current-prefix-arg, as is done in `handle-switch-frame'.
       But `handle-switch-frame is not run from the special-map.
Index: src/termhooks.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/termhooks.h,v
retrieving revision 1.69
diff -c -r1.69 termhooks.h
*** src/termhooks.h	4 Jul 2005 16:06:35 -0000	1.69
--- src/termhooks.h	17 Jul 2005 20:23:36 -0000
***************
*** 289,294 ****
--- 289,298 ----
    DEICONIFY_EVENT,		/* An X client deiconified this window.  */
    MENU_BAR_ACTIVATE_EVENT,      /* A button press in the menu bar
  				   (toolkit version only).  */
+ #ifdef MAC_OSX
+   TOGGLE_TOOLBAR_EVENT,         /* A client requestes toggling the tool-bar */
+ #endif
+ 
    DRAG_N_DROP_EVENT,		/* A drag-n-drop event is generated when
  				   files selected outside of Emacs are dropped
  				   onto an Emacs window.
Index: src/macfns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macfns.c,v
retrieving revision 1.63
diff -c -r1.63 macfns.c
*** src/macfns.c	4 Jul 2005 16:06:33 -0000	1.63
--- src/macfns.c	17 Jul 2005 20:23:37 -0000
***************
*** 2226,2232 ****
  #if TARGET_API_MAC_CARBON
    CreateNewWindow (kDocumentWindowClass,
  		   kWindowStandardDocumentAttributes
! 		   /* | kWindowToolbarButtonAttribute */,
  		   &r, &FRAME_MAC_WINDOW (f));
    if (FRAME_MAC_WINDOW (f))
      {
--- 2226,2232 ----
  #if TARGET_API_MAC_CARBON
    CreateNewWindow (kDocumentWindowClass,
  		   kWindowStandardDocumentAttributes
! 		   | kWindowToolbarButtonAttribute,
  		   &r, &FRAME_MAC_WINDOW (f));
    if (FRAME_MAC_WINDOW (f))
      {
Index: src/macterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macterm.c,v
retrieving revision 1.123
diff -c -r1.123 macterm.c
*** src/macterm.c	14 Jul 2005 09:23:24 -0000	1.123
--- src/macterm.c	17 Jul 2005 20:23:40 -0000
***************
*** 9124,9129 ****
--- 9124,9134 ----
  		if (TrackBox (window_ptr, er.where, part_code))
  		  do_zoom_window (window_ptr, part_code);
  		break;
+ 	      case inToolbarButton:
+ 		inev.kind = TOGGLE_TOOLBAR_EVENT;
+ 		XSETFRAME (inev.frame_or_window,
+ 			   mac_window_to_frame (window_ptr));
+ 		break;
  
  	      default:
  		break;
Index: lisp/toolbar/tool-bar.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/toolbar/tool-bar.el,v
retrieving revision 1.40
diff -c -r1.40 tool-bar.el
*** lisp/toolbar/tool-bar.el	4 Jul 2005 23:09:00 -0000	1.40
--- lisp/toolbar/tool-bar.el	17 Jul 2005 20:23:40 -0000
***************
*** 265,271 ****
--- 265,301 ----
  			      (popup-menu menu-bar-help-menu))
  		     'help
  		     :help "Pop up the Help menu")
+ 
+   ;; Toolbar button, mapped to handle-toggle-tool-bar in tool-bar.el
+   ;; (Toolbar button - on systems that support it!)
+   (global-set-key [toggle-frame-toolbar] 'handle-toggle-tool-bar)
+ 
    )
+ 
+ 
+ ;; local toolbars
+ 
+ (defun tool-bar-enabled-p (&optional frame)
+ "Evaluates to non-nil if the tool-bar is present
+ in frame FRAME. If FRAME is nil, the function applies
+ to the selected frame."
+   (> (or (frame-parameter frame 'tool-bar-lines) 0) 0))
+ 
+ (defun toggle-tool-bar (&optional frame)
+ "Switches the tool bar on and off in frame FRAME.
+ If FRAME is nil, the change applies to the selected frame."
+ (interactive)
+   (modify-frame-parameters frame 
+    (list (cons 'tool-bar-lines 
+ 	       (if (tool-bar-enabled-p frame)
+ 		   0
+ 		 1
+ 		 )))))
+ 
+ (defun handle-toggle-tool-bar (event)
+ "Handles a tool-bar toggle event."
+ (interactive "e")
+   (toggle-tool-bar  (posn-window (event-start event))))
  
  (provide 'tool-bar)
  

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2400 bytes --]

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

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

             reply	other threads:[~2005-09-25 20:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-25 20:25 David Reitter [this message]
2005-09-26 13:17 ` Toolbar patch (OS X) Stefan Monnier
2005-09-27  3:43   ` YAMAMOTO Mitsuharu
2005-09-27  9:56     ` David Reitter
2005-09-28  8:29       ` YAMAMOTO Mitsuharu
2005-10-06 21:57     ` David Reitter

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=5E6B6577-653A-4DCF-AC6A-10EC020C3548@gmail.com \
    --to=david.reitter@gmail.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).