From patchwork Wed Mar 23 14:32:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 601253 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qVXCB3cyfz9sDb for ; Thu, 24 Mar 2016 01:34:46 +1100 (AEDT) Received: from localhost ([::1]:44309 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aijrw-0006gX-Jv for incoming@patchwork.ozlabs.org; Wed, 23 Mar 2016 10:34:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aijpt-0003iT-OQ for qemu-devel@nongnu.org; Wed, 23 Mar 2016 10:32:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aijpo-0002s8-5f for qemu-devel@nongnu.org; Wed, 23 Mar 2016 10:32:37 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:56257) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aijpn-0002qQ-V5 for qemu-devel@nongnu.org; Wed, 23 Mar 2016 10:32:32 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1aijpd-0005eB-CK for qemu-devel@nongnu.org; Wed, 23 Mar 2016 14:32:21 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Wed, 23 Mar 2016 14:32:18 +0000 Message-Id: <1458743540-3065-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1458743540-3065-1-git-send-email-peter.maydell@linaro.org> References: <1458743540-3065-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 1/3] ui/cocoa.m: fix help menus 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 From: John Arbuckle Make the help menus actually work. The code will search thru three different locations for the help file. If it can't be found a dialog will tell the user the file can't be found. Signed-off-by: John Arbuckle Message-id: F6B689F9-4DBD-4C50-BC38-35E5DD03D396@gmail.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- ui/cocoa.m | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 7063a02..9295233 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -858,6 +858,7 @@ QemuCocoaView *cocoaView; - (void)ejectDeviceMedia:(id)sender; - (void)changeDeviceMedia:(id)sender; - (BOOL)verifyQuit; +- (void)openDocumentation:(NSString *)filename; @end @implementation QemuCocoaAppController @@ -994,20 +995,42 @@ QemuCocoaView *cocoaView; [cocoaView toggleFullScreen:sender]; } +/* Tries to find then open the specified filename */ +- (void) openDocumentation: (NSString *) filename +{ + /* Where to look for local files */ + NSString *path_array[] = {@"../share/doc/qemu/", @"../doc/qemu/", @"../"}; + NSString *full_file_path; + + /* iterate thru the possible paths until the file is found */ + int index; + for (index = 0; index < ARRAY_SIZE(path_array); index++) { + full_file_path = [[NSBundle mainBundle] executablePath]; + full_file_path = [full_file_path stringByDeletingLastPathComponent]; + full_file_path = [NSString stringWithFormat: @"%@/%@%@", full_file_path, + path_array[index], filename]; + if ([[NSWorkspace sharedWorkspace] openFile: full_file_path] == YES) { + return; + } + } + + /* If none of the paths opened a file */ + NSBeep(); + QEMU_Alert(@"Failed to open file"); +} + - (void)showQEMUDoc:(id)sender { COCOA_DEBUG("QemuCocoaAppController: showQEMUDoc\n"); - [[NSWorkspace sharedWorkspace] openFile:[NSString stringWithFormat:@"%@/../doc/qemu/qemu-doc.html", - [[NSBundle mainBundle] resourcePath]] withApplication:@"Help Viewer"]; + [self openDocumentation: @"qemu-doc.html"]; } - (void)showQEMUTec:(id)sender { COCOA_DEBUG("QemuCocoaAppController: showQEMUTec\n"); - [[NSWorkspace sharedWorkspace] openFile:[NSString stringWithFormat:@"%@/../doc/qemu/qemu-tech.html", - [[NSBundle mainBundle] resourcePath]] withApplication:@"Help Viewer"]; + [self openDocumentation: @"qemu-tech.html"]; } /* Stretches video to fit host monitor size */