From patchwork Mon Mar 7 16:03:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 8520691 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 92BA29F2B4 for ; Mon, 7 Mar 2016 16:04:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 932A920274 for ; Mon, 7 Mar 2016 16:04:15 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 33E962026F for ; Mon, 7 Mar 2016 16:04:14 +0000 (UTC) Received: from localhost ([::1]:56724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acxdl-0002DD-K4 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 07 Mar 2016 11:04:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48269) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acxdc-0002BW-89 for qemu-devel@nongnu.org; Mon, 07 Mar 2016 11:04:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1acxdX-0002LF-61 for qemu-devel@nongnu.org; Mon, 07 Mar 2016 11:04:04 -0500 Received: from mail-io0-x244.google.com ([2607:f8b0:4001:c06::244]:33606) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acxdX-0002LB-1R for qemu-devel@nongnu.org; Mon, 07 Mar 2016 11:03:59 -0500 Received: by mail-io0-x244.google.com with SMTP id g203so11478278iof.0 for ; Mon, 07 Mar 2016 08:03:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-transfer-encoding:subject:date:message-id:cc:to :mime-version; bh=ETbv9MvUu6FGYqCAwj94gFQQOxCLEQ4UUnlMk0MrXdo=; b=yV835+iQ4bRjAFCc5uepWjat0fNWWluiD4rdZ7l4YhjqYp/B1aHMYcvQCzgrbkGXX5 eyD6BxH5g09DWcK2jTXeN7Gz+89yVH82m2I0rt/ImpfKnBpEY3j1ikNRbcc9IqvEotOc Xg2JMobleblUgCZDYfe7Qrd7J+qejyAZhTQyAH4SYdeQSsVqLmigjjWbfTml6mDDfo9/ kwhe+bWF51tbBWT88GfrIXJqu2hRfP/9oEPAMXMUvIb2bMNghZWACB+Roy87iZGJM3aj fzPxWxmsU0sRQFrDQJLzAQB7ApNG8ItRVu2SBl3Ot4EmXd0qSDx4mM5ihA0GCno7zF5H FkIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:content-transfer-encoding:subject:date :message-id:cc:to:mime-version; bh=ETbv9MvUu6FGYqCAwj94gFQQOxCLEQ4UUnlMk0MrXdo=; b=i76BQ7CGA6nYSw9dVM432+ECL9Ptd0pU+jE9sP7Ac6j0IkWkwBW8Vg6m0631SZaDC6 cQ4oQMVRyIfL+rtFhsjf5snBmN4z5YGWDzVg4aKf3R1Q5fyimVYrY4O/bf0OjaA5dK3B EZrc0oOcnAKOykP91rR2E5yKwDMnOvcwC+zvAzAmecLSWFFZMwXrSYyXKVOfi+b77A2h +K9kjVkHuY/JeG8B7An5zSQPT/WJZUBAQKvTOzU/YJoX3Q2m9aunDbFyP3QgTfBvbD1G SDduXr+EnV2j6CHSX9hgjIpxEOqharVjViyhho+0f+Vjj0aJ6U6iMikw3d4xxPWn0FY1 /hyQ== X-Gm-Message-State: AD7BkJL1YVgQLwwLY8mBZPOlzZJ63NopEAB3WQNpa07ufrOkOeGPYWFjdXvnQgNXdw9QEQ== X-Received: by 10.107.168.30 with SMTP id r30mr4761794ioe.141.1457366638094; Mon, 07 Mar 2016 08:03:58 -0800 (PST) Received: from [192.168.0.5] (d199-74-164-53.col.wideopenwest.com. [74.199.53.164]) by smtp.gmail.com with ESMTPSA id j1sm4919093ige.19.2016.03.07.08.03.57 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Mar 2016 08:03:57 -0800 (PST) From: Programmingkid Date: Mon, 7 Mar 2016 11:03:56 -0500 Message-Id: <7496E78D-73BB-464E-929D-9F93E18FF179@gmail.com> To: Peter Maydell Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4001:c06::244 Cc: qemu-devel qemu-devel Subject: [Qemu-devel] [PATCH v2] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MIME_QP_LONG_LINE, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make the help menus actually work. The code will search thru three different locations for the help file. If it can't be found, it will look on the web for it. Signed-off-by: John Arbuckle --- Moved opening code to one method. Searches three different locations on the user's computer first. Attempts to open file on web if file can't be found on user's computer. ui/cocoa.m | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 3ee5549..66f0f79 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,48 @@ 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; + const int number_of_paths = 3; + + /* iterate thru the possible paths until the file is found */ + int index; + for (index = 0; index < number_of_paths; 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; + } + } + + /* Try to open the file on the web if possible */ + full_file_path = [NSString stringWithFormat: @"%s%@", + "http://qemu.weilnetz.de/", filename]; + NSURL *url = [NSURL URLWithString: full_file_path]; + if ([[NSWorkspace sharedWorkspace] openURL: url] == NO) { + 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 */