From patchwork Tue May 19 08:23:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 48731 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3047A21411 for ; Tue, 19 May 2015 08:26:24 +0000 (UTC) Received: by wiz9 with SMTP id 9sf4321786wiz.3 for ; Tue, 19 May 2015 01:26:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=2tp8tJ52AhkbpT9lEc79SXB4LWkIqBydd2aLwJa6bpk=; b=FZFoGKtQgJZnkWIgmNnU8NDg78SnLwf3i+l1HFtykkrMafcu3BU1xMIgjA7Klz2xR4 s/ZFCc0r0iC2qkYlYA8GQicvhesSSGM63AzVEuWwOAdsgh2VRAcnZeK68QUIX/3NMBpb ZNkFqBBACD3D+LOQUgx0eMAeFvH6fhlaSF1eFwIFQ6PPu13L6rpWowHPTknXxxe6qjgX a4v8YLyRJcrA3Z/D2W9DOE/BvX0u7xqBmkCKkO+AtqA5c1qIfhJtLH8psdhNrl+dcRFr uu4yyJklwlQpdbVKlqAKm+XUJ3GVZcbqTVccTLvYyT9DDhf41a0i/PPiN/sYKXbmAEPO Exag== X-Gm-Message-State: ALoCoQk5mQ8TdU9+KxZBBMNl+wwq6LgXxQh6EZngnMWeetgMXvj8eNIIxbovhTdOSt0dMD7HeKw3 X-Received: by 10.112.160.197 with SMTP id xm5mr21003268lbb.15.1432023983463; Tue, 19 May 2015 01:26:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.100 with SMTP id j4ls25103lah.92.gmail; Tue, 19 May 2015 01:26:23 -0700 (PDT) X-Received: by 10.153.4.43 with SMTP id cb11mr20979291lad.122.1432023983320; Tue, 19 May 2015 01:26:23 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id r6si8363920lag.118.2015.05.19.01.26.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 May 2015 01:26:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by labbd9 with SMTP id bd9so11635627lab.2 for ; Tue, 19 May 2015 01:26:22 -0700 (PDT) X-Received: by 10.152.27.1 with SMTP id p1mr20104862lag.112.1432023982894; Tue, 19 May 2015 01:26:22 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp626139lbb; Tue, 19 May 2015 01:26:22 -0700 (PDT) X-Received: by 10.141.23.201 with SMTP id z192mr33567987qhd.82.1432023981505; Tue, 19 May 2015 01:26:21 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z64si13033763qge.43.2015.05.19.01.26.20 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 19 May 2015 01:26:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:44425 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yucqy-0001S8-EJ for patch@linaro.org; Tue, 19 May 2015 04:26:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yucoj-0006E6-SL for qemu-devel@nongnu.org; Tue, 19 May 2015 04:24:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yucog-0006GX-09 for qemu-devel@nongnu.org; Tue, 19 May 2015 04:24:01 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:34176) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yucof-0006GF-MC for qemu-devel@nongnu.org; Tue, 19 May 2015 04:23:57 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Yucoe-0000c4-Aw; Tue, 19 May 2015 09:23:56 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 19 May 2015 09:23:55 +0100 Message-Id: <1432023835-2274-11-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1432023835-2274-1-git-send-email-peter.maydell@linaro.org> References: <1432023835-2274-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PULL 10/10] ui/cocoa: Add console items to the View menu 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Programmingkid Add any console that is available to the current emulator as a menu item under the View menu. Signed-off-by: John Arbuckle [PMM: Adjusted to apply after zoom-to-fit menu item was added; create the View menu at the same time as all the others, and only add the dynamically-determined items to it later] Signed-off-by: Peter Maydell --- ui/cocoa.m | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 0a51fbc..85cb24c 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -799,6 +799,7 @@ QemuCocoaView *cocoaView; - (void)showQEMUDoc:(id)sender; - (void)showQEMUTec:(id)sender; - (void)zoomToFit:(id) sender; +- (void)displayConsole:(id)sender; @end @implementation QemuCocoaAppController @@ -970,8 +971,13 @@ QemuCocoaView *cocoaView; [sender setState: NSOffState]; } } -@end +/* Displays the console on the screen */ +- (void)displayConsole:(id)sender +{ + console_select([sender tag]); +} +@end int main (int argc, const char * argv[]) { @@ -1144,6 +1150,32 @@ static const DisplayChangeListenerOps dcl_ops = { .dpy_refresh = cocoa_refresh, }; +/* Returns a name for a given console */ +static NSString * getConsoleName(QemuConsole * console) +{ + return [NSString stringWithFormat: @"%s", qemu_console_get_label(console)]; +} + +/* Add an entry to the View menu for each console */ +static void add_console_menu_entries(void) +{ + NSMenu *menu; + NSMenuItem *menuItem; + int index = 0; + + menu = [[[NSApp mainMenu] itemWithTitle:@"View"] submenu]; + + [menu addItem:[NSMenuItem separatorItem]]; + + while (qemu_console_lookup_by_index(index) != NULL) { + menuItem = [[[NSMenuItem alloc] initWithTitle: getConsoleName(qemu_console_lookup_by_index(index)) + action: @selector(displayConsole:) keyEquivalent: @""] autorelease]; + [menuItem setTag: index]; + [menu addItem: menuItem]; + index++; + } +} + void cocoa_display_init(DisplayState *ds, int full_screen) { COCOA_DEBUG("qemu_cocoa: cocoa_display_init\n"); @@ -1162,4 +1194,9 @@ void cocoa_display_init(DisplayState *ds, int full_screen) // register cleanup function atexit(cocoa_cleanup); + + /* At this point QEMU has created all the consoles, so we can add View + * menu entries for them. + */ + add_console_menu_entries(); }