@@ -1108,8 +1108,6 @@ -(void)save_figure:(id)sender
11081108
11091109 self->height = height;
11101110
1111- const char * basedir;
1112-
11131111 obj = PyObject_GetAttrString ((PyObject*)self, " canvas" );
11141112 if (obj==NULL )
11151113 {
@@ -1130,8 +1128,6 @@ -(void)save_figure:(id)sender
11301128 return -1 ;
11311129 }
11321130
1133- if (!PyArg_ParseTuple (args, " s" , &basedir)) return -1 ;
1134-
11351131 NSRect bounds = [view bounds ];
11361132 NSWindow * window = [view window ];
11371133
@@ -1141,35 +1137,24 @@ -(void)save_figure:(id)sender
11411137 bounds.size .height += height;
11421138 [window setContentSize: bounds.size];
11431139
1144- NSString * dir = [NSString stringWithCString: basedir
1145- encoding: NSASCIIStringEncoding];
1140+ char * images[7 ];
1141+ char * tooltips[7 ];
1142+ if (!PyArg_ParseTuple (args, " (sssssss)(sssssss)" ,
1143+ &images[0 ], &images[1 ], &images[2 ], &images[3 ],
1144+ &images[4 ], &images[5 ], &images[6 ],
1145+ &tooltips[0 ], &tooltips[1 ], &tooltips[2 ], &tooltips[3 ],
1146+ &tooltips[4 ], &tooltips[5 ], &tooltips[6 ])) {
1147+ return -1 ;
1148+ }
11461149
11471150 NSButton * buttons[7 ];
1148-
1149- NSString * images[7 ] = {@" home.pdf" ,
1150- @" back.pdf" ,
1151- @" forward.pdf" ,
1152- @" move.pdf" ,
1153- @" zoom_to_rect.pdf" ,
1154- @" subplots.pdf" ,
1155- @" filesave.pdf" };
1156-
1157- NSString * tooltips[7 ] = {@" Reset original view" ,
1158- @" Back to previous view" ,
1159- @" Forward to next view" ,
1160- @" Pan axes with left mouse, zoom with right" ,
1161- @" Zoom to rectangle" ,
1162- @" Configure subplots" ,
1163- @" Save the figure" };
1164-
11651151 SEL actions[7 ] = {@selector (home: ),
11661152 @selector (back: ),
11671153 @selector (forward: ),
11681154 @selector (pan: ),
11691155 @selector (zoom: ),
11701156 @selector (configure_subplots: ),
11711157 @selector (save_figure: )};
1172-
11731158 NSButtonType buttontypes[7 ] = {NSMomentaryLightButton ,
11741159 NSMomentaryLightButton ,
11751160 NSMomentaryLightButton ,
@@ -1194,9 +1179,11 @@ -(void)save_figure:(id)sender
11941179 rect.origin .x = gap;
11951180 rect.origin .y = 0.5 *(height - rect.size .height );
11961181
1197- for (i = 0 ; i < 7 ; i++)
1198- {
1199- NSString * filename = [dir stringByAppendingPathComponent: images[i]];
1182+ for (i = 0 ; i < 7 ; i++) {
1183+ NSString * filename = [NSString stringWithCString: images[i]
1184+ encoding: NSUTF8StringEncoding];
1185+ NSString * tooltip = [NSString stringWithCString: tooltips[i]
1186+ encoding: NSUTF8StringEncoding];
12001187 NSImage * image = [[NSImage alloc ] initWithContentsOfFile: filename];
12011188 buttons[i] = [[NSButton alloc ] initWithFrame: rect];
12021189 [image setSize: size];
0 commit comments