@@ -1108,8 +1108,6 @@ -(void)save_figure:(id)sender
1108
1108
1109
1109
self->height = height;
1110
1110
1111
- const char * basedir;
1112
-
1113
1111
obj = PyObject_GetAttrString ((PyObject*)self, " canvas" );
1114
1112
if (obj==NULL )
1115
1113
{
@@ -1130,8 +1128,6 @@ -(void)save_figure:(id)sender
1130
1128
return -1 ;
1131
1129
}
1132
1130
1133
- if (!PyArg_ParseTuple (args, " s" , &basedir)) return -1 ;
1134
-
1135
1131
NSRect bounds = [view bounds ];
1136
1132
NSWindow * window = [view window ];
1137
1133
@@ -1141,35 +1137,24 @@ -(void)save_figure:(id)sender
1141
1137
bounds.size .height += height;
1142
1138
[window setContentSize: bounds.size];
1143
1139
1144
- NSString * dir = [NSString stringWithCString: basedir
1145
- encoding: NSASCIIStringEncoding];
1140
+ const char * images[7 ];
1141
+ const 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
+ }
1146
1149
1147
1150
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
-
1165
1151
SEL actions[7 ] = {@selector (home: ),
1166
1152
@selector (back: ),
1167
1153
@selector (forward: ),
1168
1154
@selector (pan: ),
1169
1155
@selector (zoom: ),
1170
1156
@selector (configure_subplots: ),
1171
1157
@selector (save_figure: )};
1172
-
1173
1158
NSButtonType buttontypes[7 ] = {NSMomentaryLightButton ,
1174
1159
NSMomentaryLightButton ,
1175
1160
NSMomentaryLightButton ,
@@ -1194,9 +1179,11 @@ -(void)save_figure:(id)sender
1194
1179
rect.origin .x = gap;
1195
1180
rect.origin .y = 0.5 *(height - rect.size .height );
1196
1181
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];
1200
1187
NSImage * image = [[NSImage alloc ] initWithContentsOfFile: filename];
1201
1188
buttons[i] = [[NSButton alloc ] initWithFrame: rect];
1202
1189
[image setSize: size];
@@ -1205,7 +1192,7 @@ -(void)save_figure:(id)sender
1205
1192
[buttons[i] setImage: image];
1206
1193
[buttons[i] scaleUnitSquareToSize: scale];
1207
1194
[buttons[i] setImagePosition: NSImageOnly];
1208
- [buttons[i] setToolTip: tooltips[i] ];
1195
+ [buttons[i] setToolTip: tooltip ];
1209
1196
[[window contentView ] addSubview: buttons[i]];
1210
1197
[buttons[i] release ];
1211
1198
[image release ];
0 commit comments