@@ -355,7 +355,11 @@ - (void)masterCloses:(NSNotification*)notification;
355
355
- (void )close ;
356
356
@end
357
357
358
+ #ifdef COMPILING_FOR_10_6
359
+ @interface View : NSView <NSWindowDelegate >
360
+ #else
358
361
@interface View : NSView
362
+ #endif
359
363
{ PyObject* canvas;
360
364
NSRect rubberband;
361
365
BOOL inside;
@@ -4244,14 +4248,22 @@ -(void)save_figure:(id)sender
4244
4248
self->handler = [self ->handler initWithToolbar: (PyObject*)self ];
4245
4249
for (i = 0 ; i < 9 ; i++)
4246
4250
{
4247
- ScrollableButton * button;
4251
+ NSButton * button;
4248
4252
SEL scrollWheelUpAction = scroll_actions[i][0 ];
4249
4253
SEL scrollWheelDownAction = scroll_actions[i][1 ];
4250
- if (scrollWheelUpAction || scrollWheelDownAction)
4251
- button = [ScrollableButton alloc ];
4254
+ if (scrollWheelUpAction && scrollWheelDownAction)
4255
+ {
4256
+ ScrollableButton* scrollable_button = [ScrollableButton alloc ];
4257
+ [scrollable_button initWithFrame: rect];
4258
+ [scrollable_button setScrollWheelUpAction: scrollWheelUpAction];
4259
+ [scrollable_button setScrollWheelDownAction: scrollWheelDownAction];
4260
+ button = (NSButton *)scrollable_button;
4261
+ }
4252
4262
else
4263
+ {
4253
4264
button = [NSButton alloc ];
4254
- [button initWithFrame: rect];
4265
+ [button initWithFrame: rect];
4266
+ }
4255
4267
PyObject* imagedata = PyDict_GetItemString (images, imagenames[i]);
4256
4268
NSImage * image = _read_ppm_image (imagedata);
4257
4269
[button setBezelStyle: NSShadowlessSquareBezelStyle ];
@@ -4264,10 +4276,6 @@ -(void)save_figure:(id)sender
4264
4276
[button setToolTip: tooltips[i]];
4265
4277
[button setTarget: self ->handler];
4266
4278
[button setAction: actions[i]];
4267
- if (scrollWheelUpAction)
4268
- [button setScrollWheelUpAction: scrollWheelUpAction];
4269
- if (scrollWheelDownAction)
4270
- [button setScrollWheelDownAction: scrollWheelDownAction];
4271
4279
[[window contentView ] addSubview: button];
4272
4280
[button release ];
4273
4281
rect.origin .x += rect.size .width + smallgap;
@@ -4929,7 +4937,16 @@ -(void)save_figure:(id)sender
4929
4937
[ns_default_filename release ];
4930
4938
if (result == NSOKButton )
4931
4939
{
4940
+ #ifdef COMPILING_FOR_10_6
4941
+ NSURL * url = [panel URL ];
4942
+ NSString * filename = [url path ];
4943
+ if (!filename) {
4944
+ PyErr_SetString (PyExc_RuntimeError, " Failed to obtain filename" );
4945
+ return 0 ;
4946
+ }
4947
+ #else
4932
4948
NSString * filename = [panel filename ];
4949
+ #endif
4933
4950
unsigned int n = [filename length ];
4934
4951
unichar * buffer = malloc (n*sizeof (unichar ));
4935
4952
[filename getCharacters: buffer];
0 commit comments