From nobody Sun Nov 9 19:09:40 2025 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 1551718468409879.7787862091523; Mon, 4 Mar 2019 08:54:28 -0800 (PST) Received: from localhost ([127.0.0.1]:57192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0qrB-0007TP-Ao for importer@patchew.org; Mon, 04 Mar 2019 11:54:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0qn2-0004PI-QS for qemu-devel@nongnu.org; Mon, 04 Mar 2019 11:50:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h0qn0-0005ja-HG for qemu-devel@nongnu.org; Mon, 04 Mar 2019 11:50:08 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:46994) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h0qn0-0005is-7Y for qemu-devel@nongnu.org; Mon, 04 Mar 2019 11:50:06 -0500 Received: by mail-wr1-x429.google.com with SMTP id i16so6301901wrs.13 for ; Mon, 04 Mar 2019 08:50:06 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id x74sm7238018wmf.22.2019.03.04.08.50.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Mar 2019 08:50:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Pxt797vQucLvBuTIV10DF3TxQ62OxtVpLOBlzSBO6oA=; b=JmqBpM22Ey2dnHokss3u9dcRGqf5ewGy1nej8uIXiNEZKmNkCNqwOCjXQrXmclLMfQ pm9ysvBvPGDvXynjFpoNmnk3sB4DsS2LpIHI4Pgn+3cSqBEtCOmtJ4JZ6+DjK0MM3pC/ ZKjsUTA86GpmluG80Ar9JKho7K3ksmnsyH7CKb30pDT8jleeInRuke3B/lT+gAMa2ip0 6XKq1HOkamAoaX1xIJzoqPFvU0n8x9Hdq5uiJSVAoVXf43JeMkBtm39jYjxLK5dFpXoJ PVdADTyTCYc4y+vxpM1MtyQeTc8ocLlAa9uJV4xxmsUUDw3uQU5ITvx9rOj3zWkvQ7HI p+gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Pxt797vQucLvBuTIV10DF3TxQ62OxtVpLOBlzSBO6oA=; b=afJ6VMtkivKFHsRUDC5cZFySP6Mkic60ZFQC+sSgSeTjQ8ph+ER9qMy1/TQ+UeB0y3 2UdJ0+L+W6COKaf9HUQZSbCfGib+2fuqjAqCyyV71qz6OZwQc6zyJ1j256CEAifUAZTp 1JtkaoCN11EcZ9BBCnUuDfPhjS1+O+VRrWT0AWfn0kpebNMBnR4TssUwXIhDE+o3QiNU gUR1PZOH9qhCw/iT7R84/4JoRc3mgTKNQymSCss9b9WNMt/dcH2UrpVhJiADcvwVD4r0 h3dNDmdfTUD6fMdfPIZhQs9+9p33nXTAqKjs7FsFMDKEWip39npsKfDOaoS1QElDjSCQ hezg== X-Gm-Message-State: APjAAAWY3QUMdS8+lHzuEQ+m8xJnYHSwFRNIZYr4Xybs6N+Nlhwwppjd ZaAZwb8dI/v7xMO/e50SUJj/JGbPkgE= X-Google-Smtp-Source: APXvYqwMgI7SpCyFlutxPNnmSasNhXCFpdXv4l2qr+S2/qPp/Eg/UY6gr92VvpkUGI2bJD1wjJ+0wA== X-Received: by 2002:adf:9d1d:: with SMTP id k29mr12787112wre.211.1551718204866; Mon, 04 Mar 2019 08:50:04 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Mar 2019 16:49:55 +0000 Message-Id: <20190304164958.9362-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190304164958.9362-1-peter.maydell@linaro.org> References: <20190304164958.9362-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::429 Subject: [Qemu-devel] [PULL 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: , 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: 20190225102433.22401-5-peter.maydell@linaro.org 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 4baec0b2ff7..d1fc1a6aff4 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 const DisplayChangeListenerOps dcl_ops =3D { .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.20.1