771
774
NSOpenPanel *op = [[NSOpenPanel alloc] init];
772
775
[op setPrompt:@"Boot image"];
773
776
[op setMessage:@"Select the disk image you want to boot.\n\nHit the \"Cancel\" button to quit"];
774
[op beginSheetForDirectory:nil file:nil types:[NSArray arrayWithObjects:@"img",@"iso",@"dmg",@"qcow",@"cow",@"cloop",@"vmdk",nil]
777
NSArray *filetypes = [NSArray arrayWithObjects:@"img", @"iso", @"dmg",
778
@"qcow", @"cow", @"cloop", @"vmdk", nil];
779
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
780
[op setAllowedFileTypes:filetypes];
781
[op beginSheetModalForWindow:normalWindow
782
completionHandler:^(NSInteger returnCode)
783
{ [self openPanelDidEnd:op
784
returnCode:returnCode contextInfo:NULL ]; } ];
786
// Compatibility code for pre-10.6, using deprecated method
787
[op beginSheetForDirectory:nil file:nil types:filetypes
775
788
modalForWindow:normalWindow modalDelegate:self
776
789
didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:NULL];
778
792
// or launch QEMU, with the global args
779
793
[self startEmulationWithArgc:gArgc argv:(char **)gArgv];
811
825
} else if(returnCode == NSOKButton) {
812
826
const char *bin = "qemu";
813
char *img = (char*)[ [ sheet filename ] cStringUsingEncoding:NSASCIIStringEncoding];
827
char *img = (char*)[ [ [ sheet URL ] path ] cStringUsingEncoding:NSASCIIStringEncoding];
815
829
char **argv = (char**)malloc( sizeof(char*)*3 );
855
typedef struct CPSProcessSerNum
861
OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn);
862
OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
863
OSErr CPSSetFrontProcess( CPSProcessSerNum *psn);
865
868
int main (int argc, const char * argv[]) {
868
871
gArgv = (char **)argv;
869
CPSProcessSerNum PSN;
872
874
/* In case we don't need to display a window, let's not do that */
892
894
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
896
// Pull this console process up to being a fully-fledged graphical
897
// app with a menubar and Dock icon
898
ProcessSerialNumber psn = { 0, kCurrentProcess };
899
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
893
901
[NSApplication sharedApplication];
895
if (!CPSGetCurrentProcess(&PSN))
896
if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
897
if (!CPSSetFrontProcess(&PSN))
898
[NSApplication sharedApplication];
902
905
NSMenuItem *menuItem;
960
963
static void cocoa_update(DisplayChangeListener *dcl,
961
964
int x, int y, int w, int h)
966
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
963
968
COCOA_DEBUG("qemu_cocoa: cocoa_update\n");
973
978
h * [cocoaView cdy]);
975
980
[cocoaView setNeedsDisplayInRect:rect];
978
985
static void cocoa_switch(DisplayChangeListener *dcl,
979
986
DisplaySurface *surface)
981
COCOA_DEBUG("qemu_cocoa: cocoa_resize\n");
988
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
990
COCOA_DEBUG("qemu_cocoa: cocoa_switch\n");
983
991
[cocoaView switchSurface:surface];
986
995
static void cocoa_refresh(DisplayChangeListener *dcl)
997
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
988
999
COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n");
990
1001
if (kbd_mouse_is_absolute()) {