From nobody Mon Feb 9 11:05:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551090435314813.0756211841983; Mon, 25 Feb 2019 02:27:15 -0800 (PST) Received: from localhost ([127.0.0.1]:34777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyDTb-0007c5-0o for importer@patchew.org; Mon, 25 Feb 2019 05:27:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyDRY-0006Ls-4v for qemu-devel@nongnu.org; Mon, 25 Feb 2019 05:25:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gyDRO-000387-06 for qemu-devel@nongnu.org; Mon, 25 Feb 2019 05:24:58 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:35540) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gyDRE-00030I-5v for qemu-devel@nongnu.org; Mon, 25 Feb 2019 05:24:44 -0500 Received: by mail-wm1-x342.google.com with SMTP id y15so7502054wma.0 for ; Mon, 25 Feb 2019 02:24:43 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v10sm1764692wrn.26.2019.02.25.02.24.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 02:24:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qKHYmK4Qjd/L8Bxby+U0AcrdM9zpOx8LLP3umMgo5pY=; b=v/u0vHn9KwcBYMfLhyQQm3KF4O/JStEDEgcg5HhwD6BX4sX82HvKXrCzcAC8xkzLf+ QGk9ZWjij1sVIBB08UkSGEIHs+mqlz7YyBQZwuVPVNBfXhM92JTkMs8tTZ8YkfUzHDey TEmMOPiIwK0fw1KXYOETlYKuGxJ3pcypG/nvNzbyRqcuxoSyxaT7FjMVdgl1WyZJLj0c bXtIJpTSO83ws+NaWClIlRDWikI0jxKsGqvfkrmMeaN+ZxmdlSUcL1SZSmh/VQbVoejs UC3UWd6hOcsog5TFuqN7UBIAXFM72avUuA3V77/hDkKEg4xyg4iwXb8qmL0wH9C2uBx/ DnQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qKHYmK4Qjd/L8Bxby+U0AcrdM9zpOx8LLP3umMgo5pY=; b=hg/IWcKm8YWcHt84SeOHyILxeDWGfQmz/+ZaQxzaVkz0UrVPZrTmIG8lAQFU8B/IYh TeZNdXi4yAXkK/EwzxwlVS22j9ExsBhW+Ub4xzNkqOCuvHprMghloXYOJjjeAjoPdytd NUq8WoM+a2G8s2dDGRxIy9Y8V+JjSqflmHbT0Rps2gr+fVXMjEh4P6WqW76pwOYkrNe7 n6cu5xu/lfzjjBU34shU871ynbfiOqR6L4QQ0WflRmINXDeq0AiR973dIYbHMUVnm5p6 foDlolu16eAOBIVjQHtt3HTC4Otmsja7IM0COeC45onxpXfc4PSZUS1ByxvyO6YJE2J4 GaVA== X-Gm-Message-State: AHQUAuY1jh3G1HlY0OqL/JAm2IlgfFReGFTXHKQWNYZYQBgfyl6EOXB2 tKMZICOCyIPyjJIb45vYwT/oXBioUec= X-Google-Smtp-Source: AHgI3IaG9i0vQrA6L2HJT6rbuYYcTmyFUkielQ0yg2ZvqxbgLuZjzZ0C2mhfz/8AZPD3zy8DIfnQsA== X-Received: by 2002:a1c:5fc5:: with SMTP id t188mr9784494wmb.86.1551090282499; Mon, 25 Feb 2019 02:24:42 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 25 Feb 2019 10:24:30 +0000 Message-Id: <20190225102433.22401-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190225102433.22401-1-peter.maydell@linaro.org> References: <20190225102433.22401-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PATCH v3 4/7] ui/cocoa: Move console/device menu creation code up in file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov , patches@linaro.org, John Arbuckle , Gerd Hoffmann , Ben Hekster , Berkus Decker Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Move the console/device menu creation code functions further up in the source file, next to the code which creates the initial menus. We're going to want to change the location we call these functions from in the next patch. This commit is a pure code move with no other changes. Signed-off-by: Peter Maydell Reviewed-by: BALATON Zoltan Reviewed-by: Roman Bolshakov Tested-by: Roman Bolshakov Message-id: 20190214102816.3393-5-peter.maydell@linaro.org --- ui/cocoa.m | 184 ++++++++++++++++++++++++++--------------------------- 1 file changed, 92 insertions(+), 92 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 4baec0b2ff..d1fc1a6aff 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1552,6 +1552,98 @@ static void create_initial_menus(void) [[NSApp mainMenu] addItem:menuItem]; } =20 +/* Returns a name for a given console */ +static NSString * getConsoleName(QemuConsole * console) +{ + return [NSString stringWithFormat: @"%s", qemu_console_get_label(conso= le)]; +} + +/* Add an entry to the View menu for each console */ +static void add_console_menu_entries(void) +{ + NSMenu *menu; + NSMenuItem *menuItem; + int index =3D 0; + + menu =3D [[[NSApp mainMenu] itemWithTitle:@"View"] submenu]; + + [menu addItem:[NSMenuItem separatorItem]]; + + while (qemu_console_lookup_by_index(index) !=3D NULL) { + menuItem =3D [[[NSMenuItem alloc] initWithTitle: getConsoleName(qe= mu_console_lookup_by_index(index)) + action: @selector(displayCo= nsole:) keyEquivalent: @""] autorelease]; + [menuItem setTag: index]; + [menu addItem: menuItem]; + index++; + } +} + +/* Make menu items for all removable devices. + * Each device is given an 'Eject' and 'Change' menu item. + */ +static void addRemovableDevicesMenuItems(void) +{ + NSMenu *menu; + NSMenuItem *menuItem; + BlockInfoList *currentDevice, *pointerToFree; + NSString *deviceName; + + currentDevice =3D qmp_query_block(NULL); + pointerToFree =3D currentDevice; + if(currentDevice =3D=3D NULL) { + NSBeep(); + QEMU_Alert(@"Failed to query for block devices!"); + return; + } + + menu =3D [[[NSApp mainMenu] itemWithTitle:@"Machine"] submenu]; + + // Add a separator between related groups of menu items + [menu addItem:[NSMenuItem separatorItem]]; + + // Set the attributes to the "Removable Media" menu item + NSString *titleString =3D @"Removable Media"; + NSMutableAttributedString *attString=3D[[NSMutableAttributedString all= oc] initWithString:titleString]; + NSColor *newColor =3D [NSColor blackColor]; + NSFontManager *fontManager =3D [NSFontManager sharedFontManager]; + NSFont *font =3D [fontManager fontWithFamily:@"Helvetica" + traits:NSBoldFontMask|NSItalicFo= ntMask + weight:0 + size:14]; + [attString addAttribute:NSFontAttributeName value:font range:NSMakeRan= ge(0, [titleString length])]; + [attString addAttribute:NSForegroundColorAttributeName value:newColor = range:NSMakeRange(0, [titleString length])]; + [attString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber = numberWithInt: 1] range:NSMakeRange(0, [titleString length])]; + + // Add the "Removable Media" menu item + menuItem =3D [NSMenuItem new]; + [menuItem setAttributedTitle: attString]; + [menuItem setEnabled: NO]; + [menu addItem: menuItem]; + + /* Loop through all the block devices in the emulator */ + while (currentDevice) { + deviceName =3D [[NSString stringWithFormat: @"%s", currentDevice->= value->device] retain]; + + if(currentDevice->value->removable) { + menuItem =3D [[NSMenuItem alloc] initWithTitle: [NSString stri= ngWithFormat: @"Change %s...", currentDevice->value->device] + action: @selector(change= DeviceMedia:) + keyEquivalent: @""]; + [menu addItem: menuItem]; + [menuItem setRepresentedObject: deviceName]; + [menuItem autorelease]; + + menuItem =3D [[NSMenuItem alloc] initWithTitle: [NSString stri= ngWithFormat: @"Eject %s", currentDevice->value->device] + action: @selector(ejectD= eviceMedia:) + keyEquivalent: @""]; + [menu addItem: menuItem]; + [menuItem setRepresentedObject: deviceName]; + [menuItem autorelease]; + } + currentDevice =3D currentDevice->next; + } + qapi_free_BlockInfoList(pointerToFree); +} + int main (int argc, const char * argv[]) { =20 gArgc =3D argc; @@ -1680,98 +1772,6 @@ static void cocoa_cleanup(void) .dpy_refresh =3D cocoa_refresh, }; =20 -/* Returns a name for a given console */ -static NSString * getConsoleName(QemuConsole * console) -{ - return [NSString stringWithFormat: @"%s", qemu_console_get_label(conso= le)]; -} - -/* Add an entry to the View menu for each console */ -static void add_console_menu_entries(void) -{ - NSMenu *menu; - NSMenuItem *menuItem; - int index =3D 0; - - menu =3D [[[NSApp mainMenu] itemWithTitle:@"View"] submenu]; - - [menu addItem:[NSMenuItem separatorItem]]; - - while (qemu_console_lookup_by_index(index) !=3D NULL) { - menuItem =3D [[[NSMenuItem alloc] initWithTitle: getConsoleName(qe= mu_console_lookup_by_index(index)) - action: @selector(displayCo= nsole:) keyEquivalent: @""] autorelease]; - [menuItem setTag: index]; - [menu addItem: menuItem]; - index++; - } -} - -/* Make menu items for all removable devices. - * Each device is given an 'Eject' and 'Change' menu item. - */ -static void addRemovableDevicesMenuItems(void) -{ - NSMenu *menu; - NSMenuItem *menuItem; - BlockInfoList *currentDevice, *pointerToFree; - NSString *deviceName; - - currentDevice =3D qmp_query_block(NULL); - pointerToFree =3D currentDevice; - if(currentDevice =3D=3D NULL) { - NSBeep(); - QEMU_Alert(@"Failed to query for block devices!"); - return; - } - - menu =3D [[[NSApp mainMenu] itemWithTitle:@"Machine"] submenu]; - - // Add a separator between related groups of menu items - [menu addItem:[NSMenuItem separatorItem]]; - - // Set the attributes to the "Removable Media" menu item - NSString *titleString =3D @"Removable Media"; - NSMutableAttributedString *attString=3D[[NSMutableAttributedString all= oc] initWithString:titleString]; - NSColor *newColor =3D [NSColor blackColor]; - NSFontManager *fontManager =3D [NSFontManager sharedFontManager]; - NSFont *font =3D [fontManager fontWithFamily:@"Helvetica" - traits:NSBoldFontMask|NSItalicFo= ntMask - weight:0 - size:14]; - [attString addAttribute:NSFontAttributeName value:font range:NSMakeRan= ge(0, [titleString length])]; - [attString addAttribute:NSForegroundColorAttributeName value:newColor = range:NSMakeRange(0, [titleString length])]; - [attString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber = numberWithInt: 1] range:NSMakeRange(0, [titleString length])]; - - // Add the "Removable Media" menu item - menuItem =3D [NSMenuItem new]; - [menuItem setAttributedTitle: attString]; - [menuItem setEnabled: NO]; - [menu addItem: menuItem]; - - /* Loop through all the block devices in the emulator */ - while (currentDevice) { - deviceName =3D [[NSString stringWithFormat: @"%s", currentDevice->= value->device] retain]; - - if(currentDevice->value->removable) { - menuItem =3D [[NSMenuItem alloc] initWithTitle: [NSString stri= ngWithFormat: @"Change %s...", currentDevice->value->device] - action: @selector(change= DeviceMedia:) - keyEquivalent: @""]; - [menu addItem: menuItem]; - [menuItem setRepresentedObject: deviceName]; - [menuItem autorelease]; - - menuItem =3D [[NSMenuItem alloc] initWithTitle: [NSString stri= ngWithFormat: @"Eject %s", currentDevice->value->device] - action: @selector(ejectD= eviceMedia:) - keyEquivalent: @""]; - [menu addItem: menuItem]; - [menuItem setRepresentedObject: deviceName]; - [menuItem autorelease]; - } - currentDevice =3D currentDevice->next; - } - qapi_free_BlockInfoList(pointerToFree); -} - static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts) { COCOA_DEBUG("qemu_cocoa: cocoa_display_init\n"); --=20 2.17.2 (Apple Git-113)