diff options
| author | Miles Bader | 2007-06-11 01:00:07 +0000 |
|---|---|---|
| committer | Miles Bader | 2007-06-11 01:00:07 +0000 |
| commit | 67f3ad67ee317226cb5d1bb139de0cfd883fdc5e (patch) | |
| tree | 58a0e1bea7a1d8728fd32e6127a44434e7eac006 /src/macmenu.c | |
| parent | d17cf4eb2024cf54e4a216312184665094ee3df4 (diff) | |
| parent | 2d715b39ea1c89066f469405d065dd1a6631d28e (diff) | |
| download | emacs-67f3ad67ee317226cb5d1bb139de0cfd883fdc5e.tar.gz emacs-67f3ad67ee317226cb5d1bb139de0cfd883fdc5e.zip | |
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 781-792)
- Update from CVS
- Merge from gnus--rel--5.10
- Merge from emacs--rel--22
* emacs--rel--22 (patch 33-41)
* gnus--rel--5.10 (patch 226-228)
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--multi-tty--0--patch-21
Diffstat (limited to 'src/macmenu.c')
| -rw-r--r-- | src/macmenu.c | 161 |
1 files changed, 95 insertions, 66 deletions
diff --git a/src/macmenu.c b/src/macmenu.c index a23e516dd07..1eb0b16cd95 100644 --- a/src/macmenu.c +++ b/src/macmenu.c | |||
| @@ -200,7 +200,7 @@ static void list_of_items P_ ((Lisp_Object)); | |||
| 200 | 200 | ||
| 201 | static void find_and_call_menu_selection P_ ((FRAME_PTR, int, Lisp_Object, | 201 | static void find_and_call_menu_selection P_ ((FRAME_PTR, int, Lisp_Object, |
| 202 | void *)); | 202 | void *)); |
| 203 | static int fill_menu P_ ((MenuHandle, widget_value *, enum mac_menu_kind, int)); | 203 | static int fill_menu P_ ((MenuRef, widget_value *, enum mac_menu_kind, int)); |
| 204 | static void fill_menubar P_ ((widget_value *, int)); | 204 | static void fill_menubar P_ ((widget_value *, int)); |
| 205 | static void dispose_menus P_ ((enum mac_menu_kind, int)); | 205 | static void dispose_menus P_ ((enum mac_menu_kind, int)); |
| 206 | 206 | ||
| @@ -1162,7 +1162,7 @@ x_activate_menubar (f) | |||
| 1162 | #endif | 1162 | #endif |
| 1163 | if (menu_id) | 1163 | if (menu_id) |
| 1164 | { | 1164 | { |
| 1165 | MenuHandle menu = GetMenuHandle (menu_id); | 1165 | MenuRef menu = GetMenuRef (menu_id); |
| 1166 | 1166 | ||
| 1167 | if (menu) | 1167 | if (menu) |
| 1168 | { | 1168 | { |
| @@ -1595,15 +1595,13 @@ menu_target_item_handler (next_handler, event, data) | |||
| 1595 | EventRef event; | 1595 | EventRef event; |
| 1596 | void *data; | 1596 | void *data; |
| 1597 | { | 1597 | { |
| 1598 | OSStatus err, result; | 1598 | OSStatus err; |
| 1599 | MenuRef menu; | 1599 | MenuRef menu; |
| 1600 | MenuItemIndex menu_item; | 1600 | MenuItemIndex menu_item; |
| 1601 | Lisp_Object help; | 1601 | Lisp_Object help; |
| 1602 | GrafPtr port; | 1602 | GrafPtr port; |
| 1603 | int specpdl_count = SPECPDL_INDEX (); | 1603 | int specpdl_count = SPECPDL_INDEX (); |
| 1604 | 1604 | ||
| 1605 | result = CallNextEventHandler (next_handler, event); | ||
| 1606 | |||
| 1607 | err = GetEventParameter (event, kEventParamDirectObject, typeMenuRef, | 1605 | err = GetEventParameter (event, kEventParamDirectObject, typeMenuRef, |
| 1608 | NULL, sizeof (MenuRef), NULL, &menu); | 1606 | NULL, sizeof (MenuRef), NULL, &menu); |
| 1609 | if (err == noErr) | 1607 | if (err == noErr) |
| @@ -1626,30 +1624,21 @@ menu_target_item_handler (next_handler, event, data) | |||
| 1626 | SetPort (port); | 1624 | SetPort (port); |
| 1627 | unbind_to (specpdl_count, Qnil); | 1625 | unbind_to (specpdl_count, Qnil); |
| 1628 | 1626 | ||
| 1629 | return err == noErr ? noErr : result; | 1627 | return err == noErr ? noErr : eventNotHandledErr; |
| 1630 | } | 1628 | } |
| 1631 | #endif | ||
| 1632 | 1629 | ||
| 1633 | OSStatus | 1630 | OSStatus |
| 1634 | install_menu_target_item_handler (window) | 1631 | install_menu_target_item_handler () |
| 1635 | WindowPtr window; | ||
| 1636 | { | 1632 | { |
| 1637 | OSStatus err = noErr; | ||
| 1638 | #if TARGET_API_MAC_CARBON | ||
| 1639 | static const EventTypeSpec specs[] = | 1633 | static const EventTypeSpec specs[] = |
| 1640 | {{kEventClassMenu, kEventMenuTargetItem}}; | 1634 | {{kEventClassMenu, kEventMenuTargetItem}}; |
| 1641 | static EventHandlerUPP menu_target_item_handlerUPP = NULL; | ||
| 1642 | |||
| 1643 | if (menu_target_item_handlerUPP == NULL) | ||
| 1644 | menu_target_item_handlerUPP = | ||
| 1645 | NewEventHandlerUPP (menu_target_item_handler); | ||
| 1646 | 1635 | ||
| 1647 | err = InstallWindowEventHandler (window, menu_target_item_handlerUPP, | 1636 | return InstallApplicationEventHandler (NewEventHandlerUPP |
| 1648 | GetEventTypeCount (specs), specs, | 1637 | (menu_target_item_handler), |
| 1649 | NULL, NULL); | 1638 | GetEventTypeCount (specs), |
| 1650 | #endif | 1639 | specs, NULL, NULL); |
| 1651 | return err; | ||
| 1652 | } | 1640 | } |
| 1641 | #endif /* TARGET_API_MAC_CARBON */ | ||
| 1653 | 1642 | ||
| 1654 | /* Event handler function that pops down a menu on C-g. We can only pop | 1643 | /* Event handler function that pops down a menu on C-g. We can only pop |
| 1655 | down menus if CancelMenuTracking is present (OSX 10.3 or later). */ | 1644 | down menus if CancelMenuTracking is present (OSX 10.3 or later). */ |
| @@ -1687,15 +1676,15 @@ menu_quit_handler (nextHandler, theEvent, userData) | |||
| 1687 | } | 1676 | } |
| 1688 | #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */ | 1677 | #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */ |
| 1689 | 1678 | ||
| 1690 | /* Add event handler to all menus that belong to KIND so we can detect C-g. | 1679 | /* Add event handler to all menus that belong to KIND so we can detect |
| 1691 | MENU_HANDLE is the root menu of the tracking session to dismiss | 1680 | C-g. ROOT_MENU is the root menu of the tracking session to dismiss |
| 1692 | when C-g is detected. NULL means the menu bar. | 1681 | when C-g is detected. NULL means the menu bar. If |
| 1693 | If CancelMenuTracking isn't available, do nothing. */ | 1682 | CancelMenuTracking isn't available, do nothing. */ |
| 1694 | 1683 | ||
| 1695 | static void | 1684 | static void |
| 1696 | install_menu_quit_handler (kind, menu_handle) | 1685 | install_menu_quit_handler (kind, root_menu) |
| 1697 | enum mac_menu_kind kind; | 1686 | enum mac_menu_kind kind; |
| 1698 | MenuHandle menu_handle; | 1687 | MenuRef root_menu; |
| 1699 | { | 1688 | { |
| 1700 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 | 1689 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 |
| 1701 | static const EventTypeSpec typesList[] = | 1690 | static const EventTypeSpec typesList[] = |
| @@ -1708,13 +1697,13 @@ install_menu_quit_handler (kind, menu_handle) | |||
| 1708 | #endif | 1697 | #endif |
| 1709 | for (id = min_menu_id[kind]; id < min_menu_id[kind + 1]; id++) | 1698 | for (id = min_menu_id[kind]; id < min_menu_id[kind + 1]; id++) |
| 1710 | { | 1699 | { |
| 1711 | MenuHandle menu = GetMenuHandle (id); | 1700 | MenuRef menu = GetMenuRef (id); |
| 1712 | 1701 | ||
| 1713 | if (menu == NULL) | 1702 | if (menu == NULL) |
| 1714 | break; | 1703 | break; |
| 1715 | InstallMenuEventHandler (menu, menu_quit_handler, | 1704 | InstallMenuEventHandler (menu, menu_quit_handler, |
| 1716 | GetEventTypeCount (typesList), | 1705 | GetEventTypeCount (typesList), |
| 1717 | typesList, menu_handle, NULL); | 1706 | typesList, root_menu, NULL); |
| 1718 | } | 1707 | } |
| 1719 | #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */ | 1708 | #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */ |
| 1720 | } | 1709 | } |
| @@ -1738,10 +1727,13 @@ set_frame_menubar (f, first_time, deep_p) | |||
| 1738 | 1727 | ||
| 1739 | XSETFRAME (Vmenu_updating_frame, f); | 1728 | XSETFRAME (Vmenu_updating_frame, f); |
| 1740 | 1729 | ||
| 1730 | /* This seems to be unnecessary for Carbon. */ | ||
| 1731 | #if 0 | ||
| 1741 | if (! menubar_widget) | 1732 | if (! menubar_widget) |
| 1742 | deep_p = 1; | 1733 | deep_p = 1; |
| 1743 | else if (pending_menu_activation && !deep_p) | 1734 | else if (pending_menu_activation && !deep_p) |
| 1744 | deep_p = 1; | 1735 | deep_p = 1; |
| 1736 | #endif | ||
| 1745 | 1737 | ||
| 1746 | if (deep_p) | 1738 | if (deep_p) |
| 1747 | { | 1739 | { |
| @@ -1978,7 +1970,7 @@ pop_down_menu (arg) | |||
| 1978 | { | 1970 | { |
| 1979 | struct Lisp_Save_Value *p = XSAVE_VALUE (arg); | 1971 | struct Lisp_Save_Value *p = XSAVE_VALUE (arg); |
| 1980 | FRAME_PTR f = p->pointer; | 1972 | FRAME_PTR f = p->pointer; |
| 1981 | MenuHandle menu = GetMenuHandle (min_menu_id[MAC_MENU_POPUP]); | 1973 | MenuRef menu = GetMenuRef (min_menu_id[MAC_MENU_POPUP]); |
| 1982 | 1974 | ||
| 1983 | BLOCK_INPUT; | 1975 | BLOCK_INPUT; |
| 1984 | 1976 | ||
| @@ -2024,8 +2016,7 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error) | |||
| 2024 | int i; | 2016 | int i; |
| 2025 | int menu_item_choice; | 2017 | int menu_item_choice; |
| 2026 | UInt32 menu_item_selection; | 2018 | UInt32 menu_item_selection; |
| 2027 | MenuHandle menu; | 2019 | MenuRef menu; |
| 2028 | Point pos; | ||
| 2029 | widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0; | 2020 | widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0; |
| 2030 | widget_value **submenu_stack | 2021 | widget_value **submenu_stack |
| 2031 | = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); | 2022 | = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); |
| @@ -2231,11 +2222,8 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error) | |||
| 2231 | free_menubar_widget_value_tree (first_wv); | 2222 | free_menubar_widget_value_tree (first_wv); |
| 2232 | 2223 | ||
| 2233 | /* Adjust coordinates to be root-window-relative. */ | 2224 | /* Adjust coordinates to be root-window-relative. */ |
| 2234 | pos.h = x; | 2225 | x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f); |
| 2235 | pos.v = y; | 2226 | y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f); |
| 2236 | |||
| 2237 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); | ||
| 2238 | LocalToGlobal (&pos); | ||
| 2239 | 2227 | ||
| 2240 | /* No selection has been chosen yet. */ | 2228 | /* No selection has been chosen yet. */ |
| 2241 | menu_item_selection = 0; | 2229 | menu_item_selection = 0; |
| @@ -2248,13 +2236,13 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error) | |||
| 2248 | 2236 | ||
| 2249 | /* Display the menu. */ | 2237 | /* Display the menu. */ |
| 2250 | popup_activated_flag = 1; | 2238 | popup_activated_flag = 1; |
| 2251 | menu_item_choice = PopUpMenuSelect (menu, pos.v, pos.h, 0); | 2239 | menu_item_choice = PopUpMenuSelect (menu, y, x, 0); |
| 2252 | popup_activated_flag = 0; | 2240 | popup_activated_flag = 0; |
| 2253 | 2241 | ||
| 2254 | /* Get the refcon to find the correct item */ | 2242 | /* Get the refcon to find the correct item */ |
| 2255 | if (menu_item_choice) | 2243 | if (menu_item_choice) |
| 2256 | { | 2244 | { |
| 2257 | MenuHandle sel_menu = GetMenuHandle (HiWord (menu_item_choice)); | 2245 | MenuRef sel_menu = GetMenuRef (HiWord (menu_item_choice)); |
| 2258 | 2246 | ||
| 2259 | if (sel_menu) | 2247 | if (sel_menu) |
| 2260 | GetMenuItemRefCon (sel_menu, LoWord (menu_item_choice), | 2248 | GetMenuItemRefCon (sel_menu, LoWord (menu_item_choice), |
| @@ -2330,6 +2318,14 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error) | |||
| 2330 | 2318 | ||
| 2331 | #if TARGET_API_MAC_CARBON | 2319 | #if TARGET_API_MAC_CARBON |
| 2332 | 2320 | ||
| 2321 | #define DIALOG_BUTTON_COMMAND_ID_OFFSET 'Bt\0\0' | ||
| 2322 | #define DIALOG_BUTTON_COMMAND_ID_P(id) \ | ||
| 2323 | (((id) & ~0xffff) == DIALOG_BUTTON_COMMAND_ID_OFFSET) | ||
| 2324 | #define DIALOG_BUTTON_COMMAND_ID_VALUE(id) \ | ||
| 2325 | ((id) - DIALOG_BUTTON_COMMAND_ID_OFFSET) | ||
| 2326 | #define DIALOG_BUTTON_MAKE_COMMAND_ID(value) \ | ||
| 2327 | ((value) + DIALOG_BUTTON_COMMAND_ID_OFFSET) | ||
| 2328 | |||
| 2333 | static pascal OSStatus | 2329 | static pascal OSStatus |
| 2334 | mac_handle_dialog_event (next_handler, event, data) | 2330 | mac_handle_dialog_event (next_handler, event, data) |
| 2335 | EventHandlerCallRef next_handler; | 2331 | EventHandlerCallRef next_handler; |
| @@ -2349,7 +2345,7 @@ mac_handle_dialog_event (next_handler, event, data) | |||
| 2349 | typeHICommand, NULL, sizeof (HICommand), | 2345 | typeHICommand, NULL, sizeof (HICommand), |
| 2350 | NULL, &command); | 2346 | NULL, &command); |
| 2351 | if (err == noErr) | 2347 | if (err == noErr) |
| 2352 | if ((command.commandID & ~0xffff) == 'Bt\0\0') | 2348 | if (DIALOG_BUTTON_COMMAND_ID_P (command.commandID)) |
| 2353 | { | 2349 | { |
| 2354 | SetWRefCon (window, command.commandID); | 2350 | SetWRefCon (window, command.commandID); |
| 2355 | err = QuitAppModalLoopForWindow (window); | 2351 | err = QuitAppModalLoopForWindow (window); |
| @@ -2402,7 +2398,10 @@ mac_handle_dialog_event (next_handler, event, data) | |||
| 2402 | break; | 2398 | break; |
| 2403 | } | 2399 | } |
| 2404 | 2400 | ||
| 2405 | return err == noErr ? noErr : result; | 2401 | if (err == noErr) |
| 2402 | result = noErr; | ||
| 2403 | |||
| 2404 | return result; | ||
| 2406 | } | 2405 | } |
| 2407 | break; | 2406 | break; |
| 2408 | 2407 | ||
| @@ -2518,14 +2517,16 @@ create_and_show_dialog (f, first_wv) | |||
| 2518 | } | 2517 | } |
| 2519 | if (err == noErr) | 2518 | if (err == noErr) |
| 2520 | { | 2519 | { |
| 2520 | UInt32 command_id; | ||
| 2521 | |||
| 2521 | OffsetRect (&rects[i], -rects[i].left, -rects[i].top); | 2522 | OffsetRect (&rects[i], -rects[i].left, -rects[i].top); |
| 2522 | if (rects[i].right < DIALOG_BUTTON_MIN_WIDTH) | 2523 | if (rects[i].right < DIALOG_BUTTON_MIN_WIDTH) |
| 2523 | rects[i].right = DIALOG_BUTTON_MIN_WIDTH; | 2524 | rects[i].right = DIALOG_BUTTON_MIN_WIDTH; |
| 2524 | else if (rects[i].right > DIALOG_MAX_INNER_WIDTH) | 2525 | else if (rects[i].right > DIALOG_MAX_INNER_WIDTH) |
| 2525 | rects[i].right = DIALOG_MAX_INNER_WIDTH; | 2526 | rects[i].right = DIALOG_MAX_INNER_WIDTH; |
| 2526 | 2527 | ||
| 2527 | err = SetControlCommandID (buttons[i], | 2528 | command_id = DIALOG_BUTTON_MAKE_COMMAND_ID ((int) wv->call_data); |
| 2528 | 'Bt\0\0' + (int) wv->call_data); | 2529 | err = SetControlCommandID (buttons[i], command_id); |
| 2529 | } | 2530 | } |
| 2530 | if (err != noErr) | 2531 | if (err != noErr) |
| 2531 | break; | 2532 | break; |
| @@ -2702,8 +2703,8 @@ create_and_show_dialog (f, first_wv) | |||
| 2702 | { | 2703 | { |
| 2703 | UInt32 command_id = GetWRefCon (window); | 2704 | UInt32 command_id = GetWRefCon (window); |
| 2704 | 2705 | ||
| 2705 | if ((command_id & ~0xffff) == 'Bt\0\0') | 2706 | if (DIALOG_BUTTON_COMMAND_ID_P (command_id)) |
| 2706 | result = command_id - 'Bt\0\0'; | 2707 | result = DIALOG_BUTTON_COMMAND_ID_VALUE (command_id); |
| 2707 | } | 2708 | } |
| 2708 | 2709 | ||
| 2709 | if (window) | 2710 | if (window) |
| @@ -2724,8 +2725,8 @@ mac_dialog (widget_value *wv) | |||
| 2724 | int i; | 2725 | int i; |
| 2725 | int dialog_width; | 2726 | int dialog_width; |
| 2726 | Rect rect; | 2727 | Rect rect; |
| 2727 | WindowPtr window_ptr; | 2728 | WindowRef window_ptr; |
| 2728 | ControlHandle ch; | 2729 | ControlRef ch; |
| 2729 | int left; | 2730 | int left; |
| 2730 | EventRecord event_record; | 2731 | EventRecord event_record; |
| 2731 | SInt16 part_code; | 2732 | SInt16 part_code; |
| @@ -2754,7 +2755,7 @@ mac_dialog (widget_value *wv) | |||
| 2754 | wv = wv->next; | 2755 | wv = wv->next; |
| 2755 | } | 2756 | } |
| 2756 | 2757 | ||
| 2757 | window_ptr = GetNewCWindow (DIALOG_WINDOW_RESOURCE, NULL, (WindowPtr) -1); | 2758 | window_ptr = GetNewCWindow (DIALOG_WINDOW_RESOURCE, NULL, (WindowRef) -1); |
| 2758 | 2759 | ||
| 2759 | SetPortWindowPort (window_ptr); | 2760 | SetPortWindowPort (window_ptr); |
| 2760 | 2761 | ||
| @@ -3031,7 +3032,7 @@ name_is_separator (name) | |||
| 3031 | 3032 | ||
| 3032 | static void | 3033 | static void |
| 3033 | add_menu_item (menu, pos, wv) | 3034 | add_menu_item (menu, pos, wv) |
| 3034 | MenuHandle menu; | 3035 | MenuRef menu; |
| 3035 | int pos; | 3036 | int pos; |
| 3036 | widget_value *wv; | 3037 | widget_value *wv; |
| 3037 | { | 3038 | { |
| @@ -3108,7 +3109,7 @@ add_menu_item (menu, pos, wv) | |||
| 3108 | 3109 | ||
| 3109 | static int | 3110 | static int |
| 3110 | fill_menu (menu, wv, kind, submenu_id) | 3111 | fill_menu (menu, wv, kind, submenu_id) |
| 3111 | MenuHandle menu; | 3112 | MenuRef menu; |
| 3112 | widget_value *wv; | 3113 | widget_value *wv; |
| 3113 | enum mac_menu_kind kind; | 3114 | enum mac_menu_kind kind; |
| 3114 | int submenu_id; | 3115 | int submenu_id; |
| @@ -3120,7 +3121,7 @@ fill_menu (menu, wv, kind, submenu_id) | |||
| 3120 | add_menu_item (menu, pos, wv); | 3121 | add_menu_item (menu, pos, wv); |
| 3121 | if (wv->contents && submenu_id < min_menu_id[kind + 1]) | 3122 | if (wv->contents && submenu_id < min_menu_id[kind + 1]) |
| 3122 | { | 3123 | { |
| 3123 | MenuHandle submenu = NewMenu (submenu_id, "\pX"); | 3124 | MenuRef submenu = NewMenu (submenu_id, "\pX"); |
| 3124 | 3125 | ||
| 3125 | InsertMenu (submenu, -1); | 3126 | InsertMenu (submenu, -1); |
| 3126 | SetMenuItemHierarchicalID (menu, pos, submenu_id); | 3127 | SetMenuItemHierarchicalID (menu, pos, submenu_id); |
| @@ -3139,8 +3140,6 @@ fill_menubar (wv, deep_p) | |||
| 3139 | int deep_p; | 3140 | int deep_p; |
| 3140 | { | 3141 | { |
| 3141 | int id, submenu_id; | 3142 | int id, submenu_id; |
| 3142 | MenuHandle menu; | ||
| 3143 | Str255 title; | ||
| 3144 | #if !TARGET_API_MAC_CARBON | 3143 | #if !TARGET_API_MAC_CARBON |
| 3145 | int title_changed_p = 0; | 3144 | int title_changed_p = 0; |
| 3146 | #endif | 3145 | #endif |
| @@ -3162,45 +3161,75 @@ fill_menubar (wv, deep_p) | |||
| 3162 | wv != NULL && id < min_menu_id[MAC_MENU_MENU_BAR + 1]; | 3161 | wv != NULL && id < min_menu_id[MAC_MENU_MENU_BAR + 1]; |
| 3163 | wv = wv->next, id++) | 3162 | wv = wv->next, id++) |
| 3164 | { | 3163 | { |
| 3164 | OSStatus err = noErr; | ||
| 3165 | MenuRef menu; | ||
| 3166 | #if TARGET_API_MAC_CARBON | ||
| 3167 | CFStringRef title; | ||
| 3168 | |||
| 3169 | title = CFStringCreateWithCString (NULL, wv->name, | ||
| 3170 | kCFStringEncodingMacRoman); | ||
| 3171 | #else | ||
| 3172 | Str255 title; | ||
| 3173 | |||
| 3165 | strncpy (title, wv->name, 255); | 3174 | strncpy (title, wv->name, 255); |
| 3166 | title[255] = '\0'; | 3175 | title[255] = '\0'; |
| 3167 | c2pstr (title); | 3176 | c2pstr (title); |
| 3177 | #endif | ||
| 3168 | 3178 | ||
| 3169 | menu = GetMenuHandle (id); | 3179 | menu = GetMenuRef (id); |
| 3170 | if (menu) | 3180 | if (menu) |
| 3171 | { | 3181 | { |
| 3172 | #if TARGET_API_MAC_CARBON | 3182 | #if TARGET_API_MAC_CARBON |
| 3173 | Str255 old_title; | 3183 | CFStringRef old_title; |
| 3174 | 3184 | ||
| 3175 | GetMenuTitle (menu, old_title); | 3185 | err = CopyMenuTitleAsCFString (menu, &old_title); |
| 3176 | if (!EqualString (title, old_title, false, false)) | 3186 | if (err == noErr) |
| 3177 | SetMenuTitle (menu, title); | 3187 | { |
| 3188 | if (CFStringCompare (title, old_title, 0) != kCFCompareEqualTo) | ||
| 3189 | err = SetMenuTitleWithCFString (menu, title); | ||
| 3190 | CFRelease (old_title); | ||
| 3191 | } | ||
| 3192 | else | ||
| 3193 | err = SetMenuTitleWithCFString (menu, title); | ||
| 3178 | #else /* !TARGET_API_MAC_CARBON */ | 3194 | #else /* !TARGET_API_MAC_CARBON */ |
| 3179 | if (!EqualString (title, (*menu)->menuData, false, false)) | 3195 | if (!EqualString (title, (*menu)->menuData, false, false)) |
| 3180 | { | 3196 | { |
| 3181 | DeleteMenu (id); | 3197 | DeleteMenu (id); |
| 3182 | DisposeMenu (menu); | 3198 | DisposeMenu (menu); |
| 3183 | menu = NewMenu (id, title); | 3199 | menu = NewMenu (id, title); |
| 3184 | InsertMenu (menu, GetMenuHandle (id + 1) ? id + 1 : 0); | 3200 | InsertMenu (menu, GetMenuRef (id + 1) ? id + 1 : 0); |
| 3185 | title_changed_p = 1; | 3201 | title_changed_p = 1; |
| 3186 | } | 3202 | } |
| 3187 | #endif /* !TARGET_API_MAC_CARBON */ | 3203 | #endif /* !TARGET_API_MAC_CARBON */ |
| 3188 | } | 3204 | } |
| 3189 | else | 3205 | else |
| 3190 | { | 3206 | { |
| 3207 | #if TARGET_API_MAC_CARBON | ||
| 3208 | err = CreateNewMenu (id, 0, &menu); | ||
| 3209 | if (err == noErr) | ||
| 3210 | err = SetMenuTitleWithCFString (menu, title); | ||
| 3211 | #else | ||
| 3191 | menu = NewMenu (id, title); | 3212 | menu = NewMenu (id, title); |
| 3192 | InsertMenu (menu, 0); | 3213 | #endif |
| 3214 | if (err == noErr) | ||
| 3215 | { | ||
| 3216 | InsertMenu (menu, 0); | ||
| 3193 | #if !TARGET_API_MAC_CARBON | 3217 | #if !TARGET_API_MAC_CARBON |
| 3194 | title_changed_p = 1; | 3218 | title_changed_p = 1; |
| 3195 | #endif | 3219 | #endif |
| 3220 | } | ||
| 3196 | } | 3221 | } |
| 3222 | #if TARGET_API_MAC_CARBON | ||
| 3223 | CFRelease (title); | ||
| 3224 | #endif | ||
| 3197 | 3225 | ||
| 3198 | if (wv->contents) | 3226 | if (err == noErr) |
| 3199 | submenu_id = fill_menu (menu, wv->contents, MAC_MENU_MENU_BAR_SUB, | 3227 | if (wv->contents) |
| 3200 | submenu_id); | 3228 | submenu_id = fill_menu (menu, wv->contents, MAC_MENU_MENU_BAR_SUB, |
| 3229 | submenu_id); | ||
| 3201 | } | 3230 | } |
| 3202 | 3231 | ||
| 3203 | if (id < min_menu_id[MAC_MENU_MENU_BAR + 1] && GetMenuHandle (id)) | 3232 | if (id < min_menu_id[MAC_MENU_MENU_BAR + 1] && GetMenuRef (id)) |
| 3204 | { | 3233 | { |
| 3205 | dispose_menus (MAC_MENU_MENU_BAR, id); | 3234 | dispose_menus (MAC_MENU_MENU_BAR, id); |
| 3206 | #if !TARGET_API_MAC_CARBON | 3235 | #if !TARGET_API_MAC_CARBON |
| @@ -3224,7 +3253,7 @@ dispose_menus (kind, id) | |||
| 3224 | { | 3253 | { |
| 3225 | for (id = max (id, min_menu_id[kind]); id < min_menu_id[kind + 1]; id++) | 3254 | for (id = max (id, min_menu_id[kind]); id < min_menu_id[kind + 1]; id++) |
| 3226 | { | 3255 | { |
| 3227 | MenuHandle menu = GetMenuHandle (id); | 3256 | MenuRef menu = GetMenuRef (id); |
| 3228 | 3257 | ||
| 3229 | if (menu == NULL) | 3258 | if (menu == NULL) |
| 3230 | break; | 3259 | break; |