From patchwork Fri Sep 25 18:14:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 522950 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 99A7B140783 for ; Sat, 26 Sep 2015 04:14:44 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=GmURcFhH; dkim-atps=neutral Received: from localhost ([::1]:49693 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfXW6-0005M0-7F for incoming@patchwork.ozlabs.org; Fri, 25 Sep 2015 14:14:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfXVn-00051l-AO for qemu-devel@nongnu.org; Fri, 25 Sep 2015 14:14:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfXVi-0003mP-Ao for qemu-devel@nongnu.org; Fri, 25 Sep 2015 14:14:23 -0400 Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]:33458) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfXVi-0003mB-68 for qemu-devel@nongnu.org; Fri, 25 Sep 2015 14:14:18 -0400 Received: by qkdw123 with SMTP id w123so45448840qkd.0 for ; Fri, 25 Sep 2015 11:14:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version; bh=n2L2BUk4YVJz/wFOIAHTrAdoibgDquUpsC+bWNlucbw=; b=GmURcFhHctHKfvyLreDMykmVUi1F+UgmaEAdPGudJ8krOCec8ZLIGKgIFPWBIuyVGQ eHyoWHvvgjNwwnnKBGCBtDSRPHf7Uq6IuC5eKJ1ey5dY27s8KkYCbRCNimoc6TiWEDKH WPWSKsjgxImdPrLtt77eiXOZU8F8fgVI7olpPqPcta5L+QAM8M1S96N7gu0FiEaYoBrY ysef5EQ+OopJIrwM/z0ikUMRpmMkzt4s6J1it6+OiA+1oZZy3UtiF5ZjtbdMbU0+YNUx NmlQwM8ZuWW3QTHDYTxE6ovbAIbWyfnVvFMj8rLrq2+GK4TENTHbUMnspNXuTp2E9cXt sP7w== X-Received: by 10.55.22.85 with SMTP id g82mr8026683qkh.70.1443204857798; Fri, 25 Sep 2015 11:14:17 -0700 (PDT) Received: from [192.168.0.3] (d199-74-164-53.col.wideopenwest.com. [74.199.53.164]) by smtp.gmail.com with ESMTPSA id f92sm1918813qgf.3.2015.09.25.11.14.16 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Sep 2015 11:14:17 -0700 (PDT) From: Programmingkid Date: Fri, 25 Sep 2015 14:14:15 -0400 Message-Id: <36F0434B-2CA9-4162-9654-9C8A180929F3@gmail.com> To: Peter Maydell , qemu-devel qemu-devel Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c09::22c Subject: [Qemu-devel] [PATCH v3] ui/cocoa.m: remove open dialog code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Removes the open dialog code that runs when no arguments are supplied with QEMU. Not everyone needs a hard drive or cdrom to boot their target. A user might only need to use their target's bios to do work. With that said, this patch removes the unneeded open dialog code. Signed-off-by: John Arbuckle --- Adds checking for the -psn argument. ui/cocoa.m | 66 ++++++++++++----------------------------------------------- 1 files changed, 14 insertions(+), 52 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 334e6f6..adceaaa 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -814,7 +814,6 @@ QemuCocoaView *cocoaView; { } - (void)startEmulationWithArgc:(int)argc argv:(char**)argv; -- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo; - (void)doToggleFullScreen:(id)sender; - (void)toggleFullScreen:(id)sender; - (void)showQEMUDoc:(id)sender; @@ -896,27 +895,20 @@ QemuCocoaView *cocoaView; { COCOA_DEBUG("QemuCocoaAppController: applicationDidFinishLaunching\n"); - // Display an open dialog box if no arguments were passed or - // if qemu was launched from the finder ( the Finder passes "-psn" ) - if( gArgc <= 1 || strncmp ((char *)gArgv[1], "-psn", 4) == 0) { - NSOpenPanel *op = [[NSOpenPanel alloc] init]; - [op setPrompt:@"Boot image"]; - [op setMessage:@"Select the disk image you want to boot.\n\nHit the \"Cancel\" button to quit"]; -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6) - [op setAllowedFileTypes:supportedImageFileTypes]; - [op beginSheetModalForWindow:normalWindow - completionHandler:^(NSInteger returnCode) - { [self openPanelDidEnd:op - returnCode:returnCode contextInfo:NULL ]; } ]; -#else - // Compatibility code for pre-10.6, using deprecated method - [op beginSheetForDirectory:nil file:nil types:filetypes - modalForWindow:normalWindow modalDelegate:self - didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:NULL]; -#endif - } else { - // or launch QEMU, with the global args - [self startEmulationWithArgc:gArgc argv:(char **)gArgv]; + // if the user launched QEMU from the Finder + if (gArgc <= 1 || strncmp(gArgv[1], "-psn", 4) == 0) { + NSAlert *alert = [NSAlert new]; + [alert autorelease]; + [alert setMessageText: @"Please start QEMU from the command line with" + " appropriate arguments"]; + [alert addButtonWithTitle: @"Quit"]; + [alert addButtonWithTitle: @"Continue"]; + if([alert runModal] == NSAlertFirstButtonReturn) { + [NSApp terminate: self]; + } else { + // launch QEMU, with the global args + [self startEmulationWithArgc:gArgc argv:(char **)gArgv]; + } } } @@ -942,36 +934,6 @@ QemuCocoaView *cocoaView; exit(status); } -- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo -{ - COCOA_DEBUG("QemuCocoaAppController: openPanelDidEnd\n"); - - /* The NSFileHandlingPanelOKButton/NSFileHandlingPanelCancelButton values for - * returnCode strictly only apply for the 10.6-and-up beginSheetModalForWindow - * API. For the legacy pre-10.6 beginSheetForDirectory API they are NSOKButton - * and NSCancelButton. However conveniently the values are the same. - * We use the non-legacy names because the others are deprecated in OSX 10.10. - */ - if (returnCode == NSFileHandlingPanelCancelButton) { - exit(0); - } else if (returnCode == NSFileHandlingPanelOKButton) { - char *img = (char*)[ [ [ sheet URL ] path ] cStringUsingEncoding:NSASCIIStringEncoding]; - - char **argv = g_new(char *, 4); - - [sheet close]; - - argv[0] = g_strdup(gArgv[0]); - argv[1] = g_strdup("-hda"); - argv[2] = g_strdup(img); - argv[3] = NULL; - - // printf("Using argc %d argv %s -hda %s\n", 3, gArgv[0], img); - - [self startEmulationWithArgc:3 argv:(char**)argv]; - } -} - /* We abstract the method called by the Enter Fullscreen menu item * because Mac OS 10.7 and higher disables it. This is because of the * menu item's old selector's name toggleFullScreen: