Skip to content

MdH = allow compilation on recent Mac OS X without compiler warnings #1034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions src/_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
#define COMPILING_FOR_10_5
#endif
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
#define COMPILING_FOR_10_6
#endif

static int nwin = 0; /* The number of open windows */

Expand Down Expand Up @@ -346,7 +349,11 @@ - (void)masterCloses:(NSNotification*)notification;
- (void)close;
@end

#ifdef COMPILING_FOR_10_6
@interface View : NSView <NSWindowDelegate>
#else
@interface View : NSView
#endif
{ PyObject* canvas;
NSRect rubberband;
BOOL inside;
Expand Down Expand Up @@ -4113,14 +4120,22 @@ -(void)save_figure:(id)sender
self->handler = [self->handler initWithToolbar: (PyObject*)self];
for (i = 0; i < 9; i++)
{
ScrollableButton* button;
NSButton* button;
SEL scrollWheelUpAction = scroll_actions[i][0];
SEL scrollWheelDownAction = scroll_actions[i][1];
if (scrollWheelUpAction || scrollWheelDownAction)
button = [ScrollableButton alloc];
if (scrollWheelUpAction && scrollWheelDownAction)
{
ScrollableButton* scrollable_button = [ScrollableButton alloc];
[scrollable_button initWithFrame: rect];
[scrollable_button setScrollWheelUpAction: scrollWheelUpAction];
[scrollable_button setScrollWheelDownAction: scrollWheelDownAction];
button = (NSButton*)scrollable_button;
}
else
{
button = [NSButton alloc];
[button initWithFrame: rect];
[button initWithFrame: rect];
}
PyObject* imagedata = PyDict_GetItemString(images, imagenames[i]);
NSImage* image = _read_ppm_image(imagedata);
[button setBezelStyle: NSShadowlessSquareBezelStyle];
Expand All @@ -4133,10 +4148,6 @@ -(void)save_figure:(id)sender
[button setToolTip: tooltips[i]];
[button setTarget: self->handler];
[button setAction: actions[i]];
if (scrollWheelUpAction)
[button setScrollWheelUpAction: scrollWheelUpAction];
if (scrollWheelDownAction)
[button setScrollWheelDownAction: scrollWheelDownAction];
[[window contentView] addSubview: button];
[button release];
rect.origin.x += rect.size.width + smallgap;
Expand Down Expand Up @@ -4778,7 +4789,16 @@ -(void)save_figure:(id)sender
result = [panel runModal];
if (result == NSOKButton)
{
#ifdef COMPILING_FOR_10_6
NSURL* url = [panel URL];
NSString* filename = [url path];
if (!filename) {
PyErr_SetString(PyExc_RuntimeError, "Failed to obtain filename");
return 0;
}
#else
NSString* filename = [panel filename];
#endif
unsigned int n = [filename length];
unichar* buffer = malloc(n*sizeof(unichar));
[filename getCharacters: buffer];
Expand Down