2121#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
2222#define COMPILING_FOR_10_5
2323#endif
24+ #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
25+ #define COMPILING_FOR_10_6
26+ #endif
2427
2528static int nwin = 0 ; /* The number of open windows */
2629
@@ -346,7 +349,11 @@ - (void)masterCloses:(NSNotification*)notification;
346349- (void )close ;
347350@end
348351
352+ #ifdef COMPILING_FOR_10_6
353+ @interface View : NSView <NSWindowDelegate >
354+ #else
349355@interface View : NSView
356+ #endif
350357{ PyObject* canvas;
351358 NSRect rubberband;
352359 BOOL inside;
@@ -4113,14 +4120,22 @@ -(void)save_figure:(id)sender
41134120 self->handler = [self ->handler initWithToolbar: (PyObject*)self ];
41144121 for (i = 0 ; i < 9 ; i++)
41154122 {
4116- ScrollableButton * button;
4123+ NSButton * button;
41174124 SEL scrollWheelUpAction = scroll_actions[i][0 ];
41184125 SEL scrollWheelDownAction = scroll_actions[i][1 ];
4119- if (scrollWheelUpAction || scrollWheelDownAction)
4120- button = [ScrollableButton alloc ];
4126+ if (scrollWheelUpAction && scrollWheelDownAction)
4127+ {
4128+ ScrollableButton* scrollable_button = [ScrollableButton alloc ];
4129+ [scrollable_button initWithFrame: rect];
4130+ [scrollable_button setScrollWheelUpAction: scrollWheelUpAction];
4131+ [scrollable_button setScrollWheelDownAction: scrollWheelDownAction];
4132+ button = (NSButton *)scrollable_button;
4133+ }
41214134 else
4135+ {
41224136 button = [NSButton alloc ];
4123- [button initWithFrame: rect];
4137+ [button initWithFrame: rect];
4138+ }
41244139 PyObject* imagedata = PyDict_GetItemString (images, imagenames[i]);
41254140 NSImage * image = _read_ppm_image (imagedata);
41264141 [button setBezelStyle: NSShadowlessSquareBezelStyle ];
@@ -4133,10 +4148,6 @@ -(void)save_figure:(id)sender
41334148 [button setToolTip: tooltips[i]];
41344149 [button setTarget: self ->handler];
41354150 [button setAction: actions[i]];
4136- if (scrollWheelUpAction)
4137- [button setScrollWheelUpAction: scrollWheelUpAction];
4138- if (scrollWheelDownAction)
4139- [button setScrollWheelDownAction: scrollWheelDownAction];
41404151 [[window contentView ] addSubview: button];
41414152 [button release ];
41424153 rect.origin .x += rect.size .width + smallgap;
@@ -4778,7 +4789,16 @@ -(void)save_figure:(id)sender
47784789 result = [panel runModal ];
47794790 if (result == NSOKButton )
47804791 {
4792+ #ifdef COMPILING_FOR_10_6
4793+ NSURL * url = [panel URL ];
4794+ NSString * filename = [url path ];
4795+ if (!filename) {
4796+ PyErr_SetString (PyExc_RuntimeError, " Failed to obtain filename" );
4797+ return 0 ;
4798+ }
4799+ #else
47814800 NSString * filename = [panel filename ];
4801+ #endif
47824802 unsigned int n = [filename length ];
47834803 unichar * buffer = malloc (n*sizeof (unichar ));
47844804 [filename getCharacters: buffer];
0 commit comments