Skip to content

Commit

Permalink
MdH = allow compilation on recent Mac OS X without compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Michiel de Hoon authored and Michiel de Hoon committed Jul 22, 2012
1 parent 13a11b4 commit a4ed0cf
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions src/_macosx.m
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

0 comments on commit a4ed0cf

Please sign in to comment.