Fix GNUstep build warnings
* src/nsterm.h ([EmacsWindow orderedIndex]): * src/nsterm.m ([EmacsWindow orderedIndex]): Implement orderedIndex for use under GNUstep. * src/nsmenu.m (free_frame_menubar): (ns_update_menubar): ([EmacsMenu addSubmenuWithTitle:]): ([EmacsMenu addItemWithWidgetValue:attributes:]): Cast return values to correct types. ([EmacsMenu fillWithWidgetValue:]): Move variable definition inside relevant #ifdef block. ([EmacsMenu menuWillOpen:]): ([EmacsMenu menuDidClose:]): ([EmacsMenu confinementRectForMenu:onScreen:]): ([EmacsMenu menu:willHighlightItem:]): New functions to silence build warnings. * src/nsfont.m (nsfont_open): Remove pointless fabs call.
This commit is contained in:
parent
9e7681516f
commit
0bd9e78256
4 changed files with 46 additions and 9 deletions
|
@ -700,7 +700,7 @@ Properties to be considered are same as for list(). */
|
||||||
when setting family in ns_spec_to_descriptor(). */
|
when setting family in ns_spec_to_descriptor(). */
|
||||||
if (ns_attribute_fvalue (fontDesc, NSFontWeightTrait) > 0.50F)
|
if (ns_attribute_fvalue (fontDesc, NSFontWeightTrait) > 0.50F)
|
||||||
traits |= NSBoldFontMask;
|
traits |= NSBoldFontMask;
|
||||||
if (fabs (ns_attribute_fvalue (fontDesc, NSFontSlantTrait) > 0.05F))
|
if (ns_attribute_fvalue (fontDesc, NSFontSlantTrait) > 0.05F)
|
||||||
traits |= NSItalicFontMask;
|
traits |= NSItalicFontMask;
|
||||||
|
|
||||||
/* see https://web.archive.org/web/20100201175731/http://cocoadev.com/forums/comments.php?DiscussionID=74 */
|
/* see https://web.archive.org/web/20100201175731/http://cocoadev.com/forums/comments.php?DiscussionID=74 */
|
||||||
|
|
37
src/nsmenu.m
37
src/nsmenu.m
|
@ -73,7 +73,7 @@
|
||||||
id menu = [NSApp mainMenu];
|
id menu = [NSApp mainMenu];
|
||||||
for (int i = [menu numberOfItems] - 1 ; i >= 0; i--)
|
for (int i = [menu numberOfItems] - 1 ; i >= 0; i--)
|
||||||
{
|
{
|
||||||
NSMenuItem *item = [menu itemAtIndex:i];
|
NSMenuItem *item = (NSMenuItem *)[menu itemAtIndex:i];
|
||||||
NSString *title = [item title];
|
NSString *title = [item title];
|
||||||
|
|
||||||
if ([ns_app_name isEqualToString:title])
|
if ([ns_app_name isEqualToString:title])
|
||||||
|
@ -358,7 +358,7 @@
|
||||||
if (i < [menu numberOfItems])
|
if (i < [menu numberOfItems])
|
||||||
{
|
{
|
||||||
NSString *titleStr = [NSString stringWithUTF8String: wv->name];
|
NSString *titleStr = [NSString stringWithUTF8String: wv->name];
|
||||||
NSMenuItem *item = [menu itemAtIndex:i];
|
NSMenuItem *item = (NSMenuItem *)[menu itemAtIndex:i];
|
||||||
submenu = (EmacsMenu*)[item submenu];
|
submenu = (EmacsMenu*)[item submenu];
|
||||||
|
|
||||||
[item setTitle:titleStr];
|
[item setTitle:titleStr];
|
||||||
|
@ -368,8 +368,10 @@
|
||||||
else
|
else
|
||||||
submenu = [menu addSubmenuWithTitle: wv->name];
|
submenu = [menu addSubmenuWithTitle: wv->name];
|
||||||
|
|
||||||
|
#ifdef NS_IMPL_COCOA
|
||||||
if ([[submenu title] isEqualToString:@"Help"])
|
if ([[submenu title] isEqualToString:@"Help"])
|
||||||
[NSApp setHelpMenu:submenu];
|
[NSApp setHelpMenu:submenu];
|
||||||
|
#endif
|
||||||
|
|
||||||
if (deep_p)
|
if (deep_p)
|
||||||
[submenu fillWithWidgetValue: wv->contents];
|
[submenu fillWithWidgetValue: wv->contents];
|
||||||
|
@ -472,7 +474,7 @@ - (NSMenuItem *)addItemWithWidgetValue: (void *)wvptr
|
||||||
|
|
||||||
if (menu_separator_name_p (wv->name))
|
if (menu_separator_name_p (wv->name))
|
||||||
{
|
{
|
||||||
item = [NSMenuItem separatorItem];
|
item = (NSMenuItem *)[NSMenuItem separatorItem];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -534,7 +536,7 @@ -(void)removeAllItems
|
||||||
needsUpdate = YES;
|
needsUpdate = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NS_IMPL_COCOA
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *from, *to;
|
const char *from, *to;
|
||||||
} subst_t;
|
} subst_t;
|
||||||
|
@ -591,17 +593,18 @@ -(void)removeAllItems
|
||||||
xfree (buf);
|
xfree (buf);
|
||||||
return SSDATA (result);
|
return SSDATA (result);
|
||||||
}
|
}
|
||||||
|
#endif /* NS_IMPL_COCOA */
|
||||||
|
|
||||||
- (void)fillWithWidgetValue: (void *)wvptr
|
- (void)fillWithWidgetValue: (void *)wvptr
|
||||||
{
|
{
|
||||||
widget_value *first_wv = (widget_value *)wvptr;
|
widget_value *first_wv = (widget_value *)wvptr;
|
||||||
NSFont *menuFont = [NSFont menuFontOfSize:0];
|
|
||||||
NSDictionary *attributes = nil;
|
NSDictionary *attributes = nil;
|
||||||
|
|
||||||
#ifdef NS_IMPL_COCOA
|
#ifdef NS_IMPL_COCOA
|
||||||
/* Cocoa doesn't allow multi-key sequences in its menu display, so
|
/* Cocoa doesn't allow multi-key sequences in its menu display, so
|
||||||
work around it by using tabs to split the title into two
|
work around it by using tabs to split the title into two
|
||||||
columns. */
|
columns. */
|
||||||
|
NSFont *menuFont = [NSFont menuFontOfSize:0];
|
||||||
NSDictionary *font_attribs = @{NSFontAttributeName: menuFont};
|
NSDictionary *font_attribs = @{NSFontAttributeName: menuFont};
|
||||||
CGFloat maxNameWidth = 0;
|
CGFloat maxNameWidth = 0;
|
||||||
CGFloat maxKeyWidth = 0;
|
CGFloat maxKeyWidth = 0;
|
||||||
|
@ -672,8 +675,8 @@ - (void)fillWithWidgetValue: (void *)wvptr
|
||||||
- (EmacsMenu *)addSubmenuWithTitle: (const char *)title
|
- (EmacsMenu *)addSubmenuWithTitle: (const char *)title
|
||||||
{
|
{
|
||||||
NSString *titleStr = [NSString stringWithUTF8String: title];
|
NSString *titleStr = [NSString stringWithUTF8String: title];
|
||||||
NSMenuItem *item = [self addItemWithTitle: titleStr
|
NSMenuItem *item = (NSMenuItem *)[self addItemWithTitle: titleStr
|
||||||
action: (SEL)nil /*@selector (menuDown:) */
|
action: (SEL)nil
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
EmacsMenu *submenu = [[EmacsMenu alloc] initWithTitle: titleStr];
|
EmacsMenu *submenu = [[EmacsMenu alloc] initWithTitle: titleStr];
|
||||||
[self setSubmenu: submenu forItem: item];
|
[self setSubmenu: submenu forItem: item];
|
||||||
|
@ -711,6 +714,26 @@ - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
|
||||||
: Qnil;
|
: Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NS_IMPL_GNUSTEP
|
||||||
|
/* GNUstep seems to have a number of required methods in
|
||||||
|
NSMenuDelegate that are optional in Cocoa. */
|
||||||
|
|
||||||
|
- (void) menuWillOpen:(NSMenu *)menu
|
||||||
|
{
|
||||||
|
}
|
||||||
|
- (void) menuDidClose:(NSMenu *)menu
|
||||||
|
{
|
||||||
|
}
|
||||||
|
- (NSRect)confinementRectForMenu:(NSMenu *)menu
|
||||||
|
onScreen:(NSScreen *)screen
|
||||||
|
{
|
||||||
|
return NSZeroRect;
|
||||||
|
}
|
||||||
|
- (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
@end /* EmacsMenu */
|
@end /* EmacsMenu */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -504,6 +504,10 @@ typedef id instancetype;
|
||||||
NSPoint grabOffset;
|
NSPoint grabOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NS_IMPL_GNUSTEP
|
||||||
|
- (NSInteger) orderedIndex;
|
||||||
|
#endif
|
||||||
|
|
||||||
- (BOOL)restackWindow:(NSWindow *)win above:(BOOL)above;
|
- (BOOL)restackWindow:(NSWindow *)win above:(BOOL)above;
|
||||||
- (void)setAppearance;
|
- (void)setAppearance;
|
||||||
@end
|
@end
|
||||||
|
|
10
src/nsterm.m
10
src/nsterm.m
|
@ -8763,6 +8763,16 @@ - (void)makeKeyAndOrderFront:(id)sender
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef NS_IMPL_GNUSTEP
|
||||||
|
/* orderedIndex isn't yet available in GNUstep, but it seems pretty
|
||||||
|
easy to implement. */
|
||||||
|
- (NSInteger) orderedIndex
|
||||||
|
{
|
||||||
|
return [[NSApp orderedWindows] indexOfObjectIdenticalTo:self];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* The array returned by [NSWindow parentWindow] may already be
|
/* The array returned by [NSWindow parentWindow] may already be
|
||||||
sorted, but the documentation doesn't tell us whether or not it is,
|
sorted, but the documentation doesn't tell us whether or not it is,
|
||||||
so to be safe we'll sort it. */
|
so to be safe we'll sort it. */
|
||||||
|
|
Loading…
Add table
Reference in a new issue