From patchwork Tue Mar 9 12:22:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12124975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 180B3C433DB for ; Tue, 9 Mar 2021 12:59:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 85C8C6525D for ; Tue, 9 Mar 2021 12:59:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 85C8C6525D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJbx6-0001A7-Ez for qemu-devel@archiver.kernel.org; Tue, 09 Mar 2021 07:59:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJbNq-0007VI-50 for qemu-devel@nongnu.org; Tue, 09 Mar 2021 07:22:42 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:54345) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJbNo-0004bj-Da for qemu-devel@nongnu.org; Tue, 09 Mar 2021 07:22:41 -0500 Received: by mail-pj1-x1031.google.com with SMTP id i14so805708pjz.4 for ; Tue, 09 Mar 2021 04:22:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0HHs9kfrDykWDzCr/qBTGO36y5GOBIOPNefhyhNJLMo=; b=nd5URoPesuvKmPSADLkVITFavFYhTm0fseAHZavic63H99v6FlO0fqMdimKYNXStVa cPGdAeGwu5EUxIP9munPGts6IcbEMv2hY0yYXNHlSrszJCBu4SMfkwJbTk4B1I57oX9J oKIneLSY9GfIcK2RSBvvajGo5/8CnXSt/Um2UnVeijdSlvzxDMiC5b57QjqSgzsjVg71 HEaSYrZoxFPwY1NZtg0LxmPCU4RrxxgogLbKvELQqcjg8ElXuMyNNAAMZW35YfsNs66y u+i2HQC0QbqfPCirHcCtpOH2cOz+eYma4h7xIpKucQ0AAR6OjzzTzvXe1tEpqdDruwcz jTcw== 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:mime-version :content-transfer-encoding; bh=0HHs9kfrDykWDzCr/qBTGO36y5GOBIOPNefhyhNJLMo=; b=nKikV8T9PBkHxkKSw0vyB5DsDaIxqTZ966rjcHhqnmkwCc9hZ2NWdX2K/Mi4gp4cJq MQo8yP+CvfLlid3m98zLhrWccIm2JqESJBKjmHfvEuNbjdWgNnX0c1MWhQB/22Z1QjAL Jk3Ry6DoaAjdMznUgbTmw2ln/VqAArN2s/zLSU9Jpr33m7QfoaLSNHSwvRpj3k7dNrpM dMi7lWMm3dw37si4xUDXqkz2VrLb7v7o52JmS63DLvw/fmbhu9t6Nv9FdNT94Gkeu+G9 1vE1bStYkIPEFNk1d4gsjsX6yRIWnvSlbkLCTGcVdpnRs1+eats6z/DpAjVxcGinWzqq xF3Q== X-Gm-Message-State: AOAM530Un7eLV3lMSu9rt/8o/qIMFcV772qQAyieaYFOEhc0GZlJ3NJ1 lOWXIONx3gw+Iwn8kjXS8wR6s9MVpvPb9w== X-Google-Smtp-Source: ABdhPJyvZf4cqJ4VK9BqTghZJCFOAVB+uLfSdS3eRi6kUEs4V9ozmwKb/rhmtdxSUKEa4kaBUnZ0kA== X-Received: by 2002:a17:902:e54c:b029:e6:42ee:18ae with SMTP id n12-20020a170902e54cb02900e642ee18aemr3757448plf.68.1615292558387; Tue, 09 Mar 2021 04:22:38 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c360:8200:d12c:1da1:5934:88c6]) by smtp.gmail.com with ESMTPSA id l4sm9910596pgi.19.2021.03.09.04.22.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Mar 2021 04:22:37 -0800 (PST) From: Akihiko Odaki To: Subject: [PATCH 1/2] ui/cocoa: Show QEMU icon in the about window Date: Tue, 9 Mar 2021 21:22:25 +0900 Message-Id: <20210309122226.23117-1-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=akihiko.odaki@gmail.com; helo=mail-pj1-x1031.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Akihiko Odaki , Gerd Hoffmann Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Akihiko Odaki --- ui/cocoa.m | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 0ef5fdf3b7a..d8eacea6d22 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -39,6 +39,7 @@ #include "qapi/qapi-commands-misc.h" #include "sysemu/blockdev.h" #include "qemu-version.h" +#include "qemu/cutils.h" #include "qemu/main-loop.h" #include "qemu/module.h" #include @@ -1401,18 +1402,13 @@ - (void)make_about_window y = about_height - picture_height - 10; NSRect picture_rect = NSMakeRect(x, y, picture_width, picture_height); - /* Get the path to the QEMU binary */ - NSString *binary_name = [NSString stringWithCString: gArgv[0] - encoding: NSASCIIStringEncoding]; - binary_name = [binary_name lastPathComponent]; - NSString *program_path = [[NSString alloc] initWithFormat: @"%@/%@", - [[NSBundle mainBundle] bundlePath], binary_name]; - /* Make the picture of QEMU */ NSImageView *picture_view = [[NSImageView alloc] initWithFrame: picture_rect]; - NSImage *qemu_image = [[NSWorkspace sharedWorkspace] iconForFile: - program_path]; + char *qemu_image_path_c = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/512x512/apps/qemu.png"); + NSString *qemu_image_path = [NSString stringWithUTF8String:qemu_image_path_c]; + g_free(qemu_image_path_c); + NSImage *qemu_image = [[NSImage alloc] initWithContentsOfFile:qemu_image_path]; [picture_view setImage: qemu_image]; [picture_view setImageScaling: NSImageScaleProportionallyUpOrDown]; [superView addSubview: picture_view]; From patchwork Tue Mar 9 12:22:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 12124983 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A68DC43381 for ; Tue, 9 Mar 2021 13:02:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DA44365256 for ; Tue, 9 Mar 2021 13:02:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA44365256 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJc0F-0004mK-FT for qemu-devel@archiver.kernel.org; Tue, 09 Mar 2021 08:02:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJbNw-0007az-3Q for qemu-devel@nongnu.org; Tue, 09 Mar 2021 07:22:48 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:52311) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJbNu-0004gZ-Ij for qemu-devel@nongnu.org; Tue, 09 Mar 2021 07:22:47 -0500 Received: by mail-pj1-x102d.google.com with SMTP id fu20so810098pjb.2 for ; Tue, 09 Mar 2021 04:22:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tpimQkkd/08GAgP446IN11jO++3Y9xP+PLHlyIh3/fc=; b=i8AbzbTrgo/4pPRJ9uCLnCaKVQ2W+lnqAcTEBsDoA1Z+SDCXucmP4Bn4WGzE6GROgt vThlJkiK53fQn9kDY20cNsb6TOEdVSa2hL2QXOtNE7j+GgJYvAvwwV3IFfneUcbjb3Ad uUk/ql/q3N9KZ8NbARVxf9vU21lyX4STZsitMrD29zBvf6ZWVj7CN4VUdWk/evfB8OFc 1gUTq9PDFCaHGsKTMzxVSEHLKZIrH4yM36VlryzjTFkVP2ttRru+rukpdIsL//SIEaE8 tkkgxq+K1Ru2jRzHVEl/w3OnhKZUC8wOHcV8kyTHPJjY+sDaZk/Ffs7zgFN9OHZXqsIN P2og== 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=tpimQkkd/08GAgP446IN11jO++3Y9xP+PLHlyIh3/fc=; b=fqla2NQgn3Zb6oQDsjH0a1zgSDPlXRimo5HZJ6M4X0yVxtmYzlV3vJV/YN96Vqu0T1 ZKjb9IuCJDcYJP2jmN21KuAJI/bvZGf0DTFAP/aPLh9TbO1RKfbUgflnenRyGCxM7zYx zZC8FhnysU3oLnrBhLgYPFaJ1FDsAWghG3lMltc4Aji6cYuAxtxDOVTJBgqfbCzvJF5H T7ozHOhCzBpylrsy8amq2mjeqYu3xO+nNTB1YHcvc5vIIyjYjVdSC/3iZVyik2WK0jC8 CxmUckq2HNBxNtV1LJVhMs1f4a0phFnZclP45sfCImOV7wrY0g2O2uP/F4Pz2H1UWSjL GqrQ== X-Gm-Message-State: AOAM533YICLqsCTeleBvObnkFzbWx7aoELkL4VzS5Xbg6XQlrRcYy1W/ qJP4Dbc+JX4dOTB3rSxFPD6nqcw6+pKZ9A== X-Google-Smtp-Source: ABdhPJwj+96DQCTVuVTARWJnTq8dS1DV0fIirYTD0rlgoEzVgXyZblhFpWUVb2ljhv+QnJCeyVDT7w== X-Received: by 2002:a17:902:509:b029:e5:9944:f763 with SMTP id 9-20020a1709020509b02900e59944f763mr26027291plf.35.1615292564987; Tue, 09 Mar 2021 04:22:44 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c360:8200:d12c:1da1:5934:88c6]) by smtp.gmail.com with ESMTPSA id l4sm9910596pgi.19.2021.03.09.04.22.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Mar 2021 04:22:44 -0800 (PST) From: Akihiko Odaki To: Subject: [PATCH 2/2] ui/cocoa: Do not rely on the first argument Date: Tue, 9 Mar 2021 21:22:26 +0900 Message-Id: <20210309122226.23117-2-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210309122226.23117-1-akihiko.odaki@gmail.com> References: <20210309122226.23117-1-akihiko.odaki@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=akihiko.odaki@gmail.com; helo=mail-pj1-x102d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Akihiko Odaki , Gerd Hoffmann Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The first argument of the executable was used to get its path, but it is not reliable because the executer can specify any arbitrary string. Use the interfaces provided by QEMU and the platform to get those paths. Signed-off-by: Akihiko Odaki --- ui/cocoa.m | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index d8eacea6d22..6e94301c0d6 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1414,20 +1414,21 @@ - (void)make_about_window [superView addSubview: picture_view]; /* Make the name label */ - x = 0; - y = y - 25; - int name_width = about_width, name_height = 20; - NSRect name_rect = NSMakeRect(x, y, name_width, name_height); - NSTextField *name_label = [[NSTextField alloc] initWithFrame: name_rect]; - [name_label setEditable: NO]; - [name_label setBezeled: NO]; - [name_label setDrawsBackground: NO]; - [name_label setAlignment: NSTextAlignmentCenter]; - NSString *qemu_name = [[NSString alloc] initWithCString: gArgv[0] - encoding: NSASCIIStringEncoding]; - qemu_name = [qemu_name lastPathComponent]; - [name_label setStringValue: qemu_name]; - [superView addSubview: name_label]; + NSBundle *bundle = [NSBundle mainBundle]; + if (bundle) { + x = 0; + y = y - 25; + int name_width = about_width, name_height = 20; + NSRect name_rect = NSMakeRect(x, y, name_width, name_height); + NSTextField *name_label = [[NSTextField alloc] initWithFrame: name_rect]; + [name_label setEditable: NO]; + [name_label setBezeled: NO]; + [name_label setDrawsBackground: NO]; + [name_label setAlignment: NSTextAlignmentCenter]; + NSString *qemu_name = [[bundle executablePath] lastPathComponent]; + [name_label setStringValue: qemu_name]; + [superView addSubview: name_label]; + } /* Set the version label's attributes */ x = 0;