diff -Naur xemacs/lisp/carbon-toolbar.el xemacs-toolbar/lisp/carbon-toolbar.el --- xemacs/lisp/carbon-toolbar.el Wed Dec 31 17:00:00 1969 +++ xemacs-toolbar/lisp/carbon-toolbar.el Wed Apr 13 15:54:10 2005 @@ -0,0 +1,5 @@ +(defun carbon-show-toolbar () + (customize-set-variable 'toolbar-visible-p t)) + +(defun carbon-hide-toolbar () + (customize-set-variable 'toolbar-visible-p nil)) diff -Naur xemacs/lisp/dumped-lisp.el xemacs-toolbar/lisp/dumped-lisp.el --- xemacs/lisp/dumped-lisp.el Fri Feb 25 09:29:53 2005 +++ xemacs-toolbar/lisp/dumped-lisp.el Wed Apr 13 15:53:40 2005 @@ -268,6 +268,7 @@ ;; preload the Carbon code. (when (featurep 'carbon) '("carbon-glyphs" + "carbon-toolbar" "carbon-init")) ;;; Formerly in tooltalk/tooltalk-load.el ;; Moved to tooltalk package diff -Naur xemacs/src/emacs.c xemacs-toolbar/src/emacs.c --- xemacs/src/emacs.c Fri Feb 25 09:29:59 2005 +++ xemacs-toolbar/src/emacs.c Wed Apr 13 15:55:31 2005 @@ -1469,6 +1469,7 @@ syms_of_intl_carbon (); syms_of_redisplay_carbon (); syms_of_select_carbon (); + syms_of_toolbar_carbon (); #endif /* HAVE_CARBON */ syms_of_file_coding (); diff -Naur xemacs/src/symsinit.h xemacs-toolbar/src/symsinit.h --- xemacs/src/symsinit.h Fri Feb 25 09:30:08 2005 +++ xemacs-toolbar/src/symsinit.h Wed Apr 13 15:56:23 2005 @@ -559,6 +559,7 @@ void syms_of_objects_carbon (void); void syms_of_redisplay_carbon (void); void syms_of_select_carbon (void); +void syms_of_toolbar_carbon (void); void console_type_create_carbon (void); void console_type_create_device_carbon (void); void console_type_create_frame_carbon (void); diff -Naur xemacs/src/toolbar-carbon.c xemacs-toolbar/src/toolbar-carbon.c --- xemacs/src/toolbar-carbon.c Fri Feb 25 10:17:44 2005 +++ xemacs-toolbar/src/toolbar-carbon.c Wed Apr 13 16:00:38 2005 @@ -30,6 +30,9 @@ extern void carbon_enqueue_misc_user_event (Lisp_Object, Lisp_Object, Lisp_Object); /* In event-carbon.c. */ +static Lisp_Object Qcarbon_show_toolbar; +static Lisp_Object Qcarbon_hide_toolbar; + static CFStringRef toolbar_item_create_command_id_from_index (int i) { @@ -225,7 +228,10 @@ SetEventParameter (event, kEventParamToolbarItem, typeHIToolbarItemRef, sizeof (HIToolbarItemRef), &item); result = noErr; } + + break; } + default: ; } @@ -234,9 +240,11 @@ } static OSStatus -window_event_handler (EventHandlerCallRef UNUSED (next_handler), EventRef event, void *data) +window_event_handler (EventHandlerCallRef next_handler, EventRef event, void *data) { - if (GetEventKind(event) == kEventCommandProcess) + struct frame *f = (struct frame *) data; + + if (GetEventClass (event) == kEventClassCommand && GetEventKind (event) == kEventCommandProcess) { HICommand command; GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof (command), NULL, &command); @@ -244,8 +252,6 @@ int index = toolbar_item_index_from_uint32_command_id (command.commandID); if (index >= 0) { - struct frame *f = (struct frame *) data; - Lisp_Object button = FRAME_TOOLBAR_BUTTONS (f, TOP_TOOLBAR); int i = 0; @@ -279,6 +285,18 @@ else return eventNotHandledErr; } + else if (GetEventClass (event) == kEventClassWindow && GetEventKind (event) == kEventWindowToolbarSwitchMode) + { + printf("window toolbar switch mode: active = %d\n", IsWindowToolbarVisible(FRAME_CARBON_WINDOW ((struct frame *) data))); + + if (IsWindowToolbarVisible(FRAME_CARBON_WINDOW (f))) + carbon_enqueue_misc_user_event (wrap_frame (f), Qeval, list1 (Qcarbon_hide_toolbar)); + else + carbon_enqueue_misc_user_event (wrap_frame (f), Qeval, list1 (Qcarbon_show_toolbar)); + + /*return CallNextEventHandler (next_handler, event);*/ + return noErr; + } else return eventNotHandledErr; } @@ -312,7 +330,7 @@ if (HIToolbarSetDisplayMode (toolbar, kHIToolbarDisplayModeIconOnly) != noErr) invalid_operation ("Can't set toolbar display mode for frame", wrap_frame (f)); - ShowHideWindowToolbar (FRAME_CARBON_WINDOW (f), true, false); + /*ShowHideWindowToolbar (FRAME_CARBON_WINDOW (f), true, false);*/ ChangeWindowAttributes (FRAME_CARBON_WINDOW (f), kWindowToolbarButtonAttribute, 0); @@ -323,7 +341,8 @@ EventTypeSpec we_types[] = { - { kEventClassCommand, kEventCommandProcess } + { kEventClassCommand, kEventCommandProcess }, + { kEventClassWindow, kEventWindowToolbarSwitchMode } }; if (InstallWindowEventHandler (FRAME_CARBON_WINDOW (f), we_handler, sizeof (we_types) / sizeof (we_types[0]), we_types, f, NULL) != noErr) @@ -335,6 +354,8 @@ static void carbon_output_frame_toolbars (struct frame *f) { + ShowHideWindowToolbar (FRAME_CARBON_WINDOW (f), FRAME_REAL_TOP_TOOLBAR_VISIBLE (f), false); + if (!FRAME_REAL_TOP_TOOLBAR_VISIBLE (f)) return; @@ -390,4 +411,11 @@ CONSOLE_HAS_METHOD (carbon, output_frame_toolbars); CONSOLE_HAS_METHOD (carbon, clear_frame_toolbars); /*CONSOLE_HAS_METHOD (carbon, free_frame_toolbars);*/ +} + +void +syms_of_toolbar_carbon (void) +{ + DEFSYMBOL (Qcarbon_show_toolbar); + DEFSYMBOL (Qcarbon_hide_toolbar); }