X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/7815fe1985833c57457882b415a29358991dabdc..eab3844f965646b62e242aa622754b86d1fd3444:/src/nsmenu.m diff --git a/src/nsmenu.m b/src/nsmenu.m index c7ea6bb90f..623c933ce8 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -1,5 +1,5 @@ /* NeXT/Open/GNUstep and MacOSX Cocoa menu and toolbar module. - Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2007-2011 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -23,7 +23,7 @@ Carbon version by Yamamoto Mitsuharu. */ /* This should be the first include, as it may set up #defines affecting interpretation of even the system includes. */ -#include "config.h" +#include #include #include "lisp.h" @@ -65,8 +65,7 @@ extern Lisp_Object Qundefined, Qmenu_enable, Qmenu_bar_update_hook; extern Lisp_Object QCtoggle, QCradio; Lisp_Object Qdebug_on_next_call; -extern Lisp_Object Voverriding_local_map, Voverriding_local_map_menu_flag, - Qoverriding_local_map, Qoverriding_terminal_local_map; +extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map; extern long context_menu_value; EmacsMenu *mainMenu, *svcsMenu, *dockMenu; @@ -356,7 +355,7 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu) /* if (submenu && strcmp (submenuTitle, SDATA (string))) continue; */ - wv->name = (char *) SDATA (string); + wv->name = SSDATA (string); update_submenu_strings (wv->contents); wv = wv->next; } @@ -445,7 +444,7 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu) strncpy (previous_strings[i/4], SDATA (string), 10); wv = xmalloc_widget_value (); - wv->name = (char *) SDATA (string); + wv->name = SSDATA (string); wv->value = 0; wv->enabled = 1; wv->button_type = BUTTON_TYPE_NONE; @@ -507,21 +506,6 @@ set_frame_menubar (struct frame *f, int first_time, int deep_p) } -/* Utility (from macmenu.c): is this item a separator? */ -static int -name_is_separator ( const char *name) -{ - const char *start = name; - - /* Check if name string consists of only dashes ('-'). */ - while (*name == '-') name++; - /* Separators can also be of the form "--:TripleSuperMegaEtched" - or "--deep-shadow". We don't implement them yet, se we just treat - them like normal separators. */ - return (*name == '\0' || start + 2 == name); -} - - /* ========================================================================== Menu: class implementation @@ -600,9 +584,9 @@ name_is_separator ( const char *name) NSMenuItem get ignored. For now we try to display a super-single letter combo, and return the others as strings to be appended to the item title. (This is signaled by setting keyEquivModMask to 0 for now.) */ --(NSString *)parseKeyEquiv: (char *)key +-(NSString *)parseKeyEquiv: (const char *)key { - char *tpos = key; + const char *tpos = key; keyEquivModMask = NSCommandKeyMask; if (!key || !strlen (key)) @@ -624,7 +608,7 @@ name_is_separator ( const char *name) NSMenuItem *item; widget_value *wv = (widget_value *)wvptr; - if (name_is_separator (wv->name)) + if (menu_separator_name_p (wv->name)) { item = [NSMenuItem separatorItem]; [self addItem: item]; @@ -719,7 +703,7 @@ name_is_separator ( const char *name) /* adds an empty submenu and returns it */ -- (EmacsMenu *)addSubmenuWithTitle: (char *)title forFrame: (struct frame *)f +- (EmacsMenu *)addSubmenuWithTitle: (const char *)title forFrame: (struct frame *)f { NSString *titleStr = [NSString stringWithUTF8String: title]; NSMenuItem *item = [self addItemWithTitle: titleStr @@ -773,7 +757,7 @@ name_is_separator ( const char *name) Lisp_Object ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, - Lisp_Object title, char **error) + Lisp_Object title, const char **error) { EmacsMenu *pmenu; NSPoint p; @@ -836,7 +820,7 @@ ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, { /* Create a new pane. */ Lisp_Object pane_name, prefix; - char *pane_string; + const char *pane_string; pane_name = AREF (menu_items, i + MENU_ITEMS_PANE_NAME); prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX); @@ -849,7 +833,7 @@ ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, } #endif pane_string = (NILP (pane_name) - ? "" : (char *) SDATA (pane_name)); + ? "" : SSDATA (pane_name)); /* If there is just one top-level pane, put all its items directly under the top-level menu. */ if (menu_items_n_panes == 1) @@ -914,9 +898,9 @@ ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, prev_wv->next = wv; else save_wv->contents = wv; - wv->name = (char *) SDATA (item_name); + wv->name = SSDATA (item_name); if (!NILP (descrip)) - wv->key = (char *) SDATA (descrip); + wv->key = SSDATA (descrip); wv->value = 0; /* If this item has a null value, make the call_data null so that it won't display a box @@ -965,7 +949,7 @@ ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps, title = ENCODE_MENU_STRING (title); #endif - wv_title->name = (char *) SDATA (title); + wv_title->name = SSDATA (title); wv_title->enabled = NO; wv_title->button_type = BUTTON_TYPE_NONE; wv_title->help = Qnil; @@ -1033,7 +1017,7 @@ update_frame_tool_bar (FRAME_PTR f) struct image *img; Lisp_Object image; Lisp_Object helpObj; - char *helpText; + const char *helpText; /* If image is a vector, choose the image according to the button state. */ @@ -1049,10 +1033,15 @@ update_frame_tool_bar (FRAME_PTR f) { idx = -1; } + helpObj = TOOLPROP (TOOL_BAR_ITEM_HELP); + if (NILP (helpObj)) + helpObj = TOOLPROP (TOOL_BAR_ITEM_CAPTION); + helpText = NILP (helpObj) ? "" : SSDATA (helpObj); + /* Ignore invalid image specifications. */ if (!valid_image_p (image)) { - NSLog (@"Invalid image for toolbar item"); + /* Don't log anything, GNUS makes invalid images all the time. */ continue; } @@ -1066,11 +1055,6 @@ update_frame_tool_bar (FRAME_PTR f) continue; } - helpObj = TOOLPROP (TOOL_BAR_ITEM_HELP); - if (NILP (helpObj)) - helpObj = TOOLPROP (TOOL_BAR_ITEM_CAPTION); - helpText = NILP (helpObj) ? "" : (char *)SDATA (helpObj); - [toolbar addDisplayItemWithImage: img->pixmap idx: i helpText: helpText enabled: enabled_p]; #undef TOOLPROP @@ -1153,7 +1137,7 @@ update_frame_tool_bar (FRAME_PTR f) } - (void) addDisplayItemWithImage: (EmacsImage *)img idx: (int)idx - helpText: (char *)help enabled: (BOOL)enabled + helpText: (const char *)help enabled: (BOOL)enabled { /* 1) come up w/identifier */ NSString *identifier @@ -1721,7 +1705,6 @@ void process_dialog (id window, Lisp_Object list) - (Lisp_Object)runDialogAt: (NSPoint)p { NSInteger ret; - extern EMACS_TIME timer_check (int do_it_now); /* TODO: add to a header */ /* initiate a session that will be ended by pop_down_menu */ popupSession = [NSApp beginModalSessionForWindow: self]; @@ -1731,7 +1714,7 @@ void process_dialog (id window, Lisp_Object list) { /* Run this for timers.el, indep of atimers; might not return. TODO: use return value to avoid calling every iteration. */ - timer_check (1); + timer_check (); [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]]; } @@ -1808,8 +1791,7 @@ syms_of_nsmenu (void) defsubr (&Sns_reset_menu); defsubr (&Smenu_or_popup_active_p); - Qdebug_on_next_call = intern ("debug-on-next-call"); + Qdebug_on_next_call = intern_c_string ("debug-on-next-call"); staticpro (&Qdebug_on_next_call); } -// arch-tag: 75773656-52e5-4c44-a398-47bd87b32619