21
21
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
22
22
#define COMPILING_FOR_10_5
23
23
#endif
24
+ #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
25
+ #define COMPILING_FOR_10_6
26
+ #endif
24
27
25
28
static int nwin = 0 ; /* The number of open windows */
26
29
@@ -346,7 +349,11 @@ - (void)masterCloses:(NSNotification*)notification;
346
349
- (void )close ;
347
350
@end
348
351
352
+ #ifdef COMPILING_FOR_10_6
353
+ @interface View : NSView <NSWindowDelegate >
354
+ #else
349
355
@interface View : NSView
356
+ #endif
350
357
{ PyObject* canvas;
351
358
NSRect rubberband;
352
359
BOOL inside;
@@ -4113,14 +4120,22 @@ -(void)save_figure:(id)sender
4113
4120
self->handler = [self ->handler initWithToolbar: (PyObject*)self ];
4114
4121
for (i = 0 ; i < 9 ; i++)
4115
4122
{
4116
- ScrollableButton * button;
4123
+ NSButton * button;
4117
4124
SEL scrollWheelUpAction = scroll_actions[i][0 ];
4118
4125
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
+ }
4121
4134
else
4135
+ {
4122
4136
button = [NSButton alloc ];
4123
- [button initWithFrame: rect];
4137
+ [button initWithFrame: rect];
4138
+ }
4124
4139
PyObject* imagedata = PyDict_GetItemString (images, imagenames[i]);
4125
4140
NSImage * image = _read_ppm_image (imagedata);
4126
4141
[button setBezelStyle: NSShadowlessSquareBezelStyle ];
@@ -4133,10 +4148,6 @@ -(void)save_figure:(id)sender
4133
4148
[button setToolTip: tooltips[i]];
4134
4149
[button setTarget: self ->handler];
4135
4150
[button setAction: actions[i]];
4136
- if (scrollWheelUpAction)
4137
- [button setScrollWheelUpAction: scrollWheelUpAction];
4138
- if (scrollWheelDownAction)
4139
- [button setScrollWheelDownAction: scrollWheelDownAction];
4140
4151
[[window contentView ] addSubview: button];
4141
4152
[button release ];
4142
4153
rect.origin .x += rect.size .width + smallgap;
@@ -4778,7 +4789,16 @@ -(void)save_figure:(id)sender
4778
4789
result = [panel runModal ];
4779
4790
if (result == NSOKButton )
4780
4791
{
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
4781
4800
NSString * filename = [panel filename ];
4801
+ #endif
4782
4802
unsigned int n = [filename length ];
4783
4803
unichar * buffer = malloc (n*sizeof (unichar ));
4784
4804
[filename getCharacters: buffer];
0 commit comments