unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Toolbar patch (OS X)
@ 2005-09-25 20:25 David Reitter
  2005-09-26 13:17 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: David Reitter @ 2005-09-25 20:25 UTC (permalink / 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

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

* Re: Toolbar patch (OS X)
  2005-09-25 20:25 Toolbar patch (OS X) David Reitter
@ 2005-09-26 13:17 ` Stefan Monnier
  2005-09-27  3:43   ` YAMAMOTO Mitsuharu
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2005-09-26 13:17 UTC (permalink / raw)
  Cc: Emacs-Devel '

> 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.

I haven't looked at the code, but the functionality would be welcome.


        Stefan

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

* Re: Toolbar patch (OS X)
  2005-09-26 13:17 ` Stefan Monnier
@ 2005-09-27  3:43   ` YAMAMOTO Mitsuharu
  2005-09-27  9:56     ` David Reitter
  2005-10-06 21:57     ` David Reitter
  0 siblings, 2 replies; 6+ messages in thread
From: YAMAMOTO Mitsuharu @ 2005-09-27  3:43 UTC (permalink / raw)
  Cc: David Reitter, emacs-devel

>>>>> On Mon, 26 Sep 2005 09:17:26 -0400, Stefan Monnier <monnier@iro.umontreal.ca> said:

>> 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.

> I haven't looked at the code, but the functionality would be
> welcome.

One thing I'm concerned about is whether TOGGLE_TOOLBAR_EVENT deserves
a new constant in `enum event_kind' (in termhooks.h) or not.  Likewise
for `toggle-frame-toolbar' as a top-level Lisp event.  Are there any
guidelines about addition of new event kinds?  Once Kim F. Storm
suggested the `title-bar' prefix.

  http://lists.gnu.org/archive/html/emacs-devel/2004-05/msg00780.html

And as a general note, please enclose Mac OS X specific parts in
macfns.c and macterm.c with `#ifdef MAC_OSX' because these files are
also used by Mac OS Classic.

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp

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

* Re: Toolbar patch (OS X)
  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
  1 sibling, 1 reply; 6+ messages in thread
From: David Reitter @ 2005-09-27  9:56 UTC (permalink / raw)


On 27 Sep 2005, at 04:43, YAMAMOTO Mitsuharu wrote:
>
> And as a general note, please enclose Mac OS X specific parts in
> macfns.c and macterm.c with `#ifdef MAC_OSX' because these files are
> also used by Mac OS Classic.

If I only knew what works and what won't work on Classic.

By the way, I'd like to second what you wrote earlier:

> Maybe we need to consider whether there is a raison d'être of the
> Carbon port or not (with respect to version 23, not 22) before making
> further development effort for it.

One would expect that anyone interested in more advanced features (as  
offered by later releases) has moved on to OS X or GNU/Linux. Those  
who haven't obviously don't like upgrading. So it's difficult to  
understand why Classic should be supported.

(To explain: Carbon is an API that exists on Classic and on OS X,  
while Cocoa lives in NextSTEP and OS X.)

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

* Re: Toolbar patch (OS X)
  2005-09-27  9:56     ` David Reitter
@ 2005-09-28  8:29       ` YAMAMOTO Mitsuharu
  0 siblings, 0 replies; 6+ messages in thread
From: YAMAMOTO Mitsuharu @ 2005-09-28  8:29 UTC (permalink / raw)


>>>>> On Tue, 27 Sep 2005 10:56:53 +0100, David Reitter <david.reitter@gmail.com> said:

> If I only knew what works and what won't work on Classic.

OK, I'll take care of that later in the case you are not certain.

> By the way, I'd like to second what you wrote earlier:

>> Maybe we need to consider whether there is a raison d'être of the
>> Carbon port or not (with respect to version 23, not 22) before
>> making further development effort for it.

> One would expect that anyone interested in more advanced features
> (as offered by later releases) has moved on to OS X or
> GNU/Linux. Those who haven't obviously don't like upgrading. So it's
> difficult to understand why Classic should be supported.

As for Emacs 22, I added Mac OS Classic support because not only it
was a part of the official Emacs 21 release, but also it is useful for
making the Mac OS X version more stable.  In my experience, Mac OS
Classic is more sensitive to wrong use of (Carbon) API than Mac OS X,
and actually I've found various problems through adaptation for Mac OS
Classic.

As for Emacs 23, the Carbon port itself might become such that "it's
difficult to understand why it should be supported".  From the users'
point of view, it would be confusing to have two ports of Emacs that
are the same version and have similar look-and-feel, provided that
both of them are sufficiently stable and functional.

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp

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

* Re: Toolbar patch (OS X)
  2005-09-27  3:43   ` YAMAMOTO Mitsuharu
  2005-09-27  9:56     ` David Reitter
@ 2005-10-06 21:57     ` David Reitter
  1 sibling, 0 replies; 6+ messages in thread
From: David Reitter @ 2005-10-06 21:57 UTC (permalink / raw)


On 27 Sep 2005, at 04:43, YAMAMOTO Mitsuharu wrote:

>  One thing I'm concerned about is whether TOGGLE_TOOLBAR_EVENT  
> deserves
> a new constant in `enum event_kind' (in termhooks.h) or not.  Likewise
> for `toggle-frame-toolbar' as a top-level Lisp event.  Are there any
> guidelines about addition of new event kinds?  Once Kim F. Storm
> suggested the `title-bar' prefix.
>
>   http://lists.gnu.org/archive/html/emacs-devel/2004-05/msg00780.html

There hasn't been any feedback regarding this.
termhooks has stuff like  SAVE_SESSION_EVENT and I'm not sure if that  
is implemented on all systems.
If there's a place for OS X specific events to be added, sure - I  
wouldn't know where.

I agree that [toggle-frame-toolbar] could be [title-bar toggle-frame- 
toolbar]. How would one go about defining that in keyboard.c?

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

end of thread, other threads:[~2005-10-06 21:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-25 20:25 Toolbar patch (OS X) David Reitter
2005-09-26 13:17 ` 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

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).