From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel =?UTF-8?Q?Mart=C3=ADn?= via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#62234: Toolbar does not work properly (with Emacs 29 or 30) Date: Sat, 18 Mar 2023 02:09:04 +0100 Message-ID: References: <83sfe3eqaf.fsf@gnu.org> <83jzzfegy0.fsf@gnu.org> <87a60a3nrj.fsf@yahoo.com> Reply-To: Daniel =?UTF-8?Q?Mart=C3=ADn?= Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26493"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin) Cc: Eli Zaretskii , 62234@debbugs.gnu.org, Konrad Podczeck To: Po Lu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 18 02:10:18 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pdL5M-0006gb-OZ for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Mar 2023 02:10:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pdL5A-0005Fn-Qw; Fri, 17 Mar 2023 21:10:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pdL58-0005FV-Ry for bug-gnu-emacs@gnu.org; Fri, 17 Mar 2023 21:10:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pdL58-00055o-Ib for bug-gnu-emacs@gnu.org; Fri, 17 Mar 2023 21:10:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pdL58-0007Qs-9k for bug-gnu-emacs@gnu.org; Fri, 17 Mar 2023 21:10:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Mar 2023 01:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62234 X-GNU-PR-Package: emacs Original-Received: via spool by 62234-submit@debbugs.gnu.org id=B62234.167910175828510 (code B ref 62234); Sat, 18 Mar 2023 01:10:02 +0000 Original-Received: (at 62234) by debbugs.gnu.org; 18 Mar 2023 01:09:18 +0000 Original-Received: from localhost ([127.0.0.1]:45917 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pdL4P-0007Pl-OK for submit@debbugs.gnu.org; Fri, 17 Mar 2023 21:09:18 -0400 Original-Received: from sonic308-19.consmr.mail.ir2.yahoo.com ([77.238.178.147]:38701) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pdL4O-0007PV-8T for 62234@debbugs.gnu.org; Fri, 17 Mar 2023 21:09:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1679101749; bh=REtpfRKJ0845+56jZm7zS2dMbshxwBgHAr+frP250rU=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=uF6wW4SBAXXZGBgTCleW/09PRRWE1pcWPnIvkvvZZ5UL8ReZYGlbbH0Jve+gDGWMSDfxFcME50cyyX8k14e4wvQbf+1jGE7TwAmSxJo7eICkCGfDxE56anqEVu31n/nxQkOTifkTuuCXTRZuFNKccqC4f99CypJg1tyIeL2WNOfbHM6hiF4XIPsfrT5FdiQmCvlxsPxdwN11J8USzy+reYfEyti5WnBhPZ1WsvGcxSOvukVXujGUDWmwQK8bvc4FcfkJnqa14YGcwIxQwEle/iQRDbohby/JImQCVObHJud6nfHIqE7pgXWeNgrV+Y0Z04Ps+/auLrPWAkwzwaXlkQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1679101749; bh=T85d/rHcAFJqk/rX3l2u3SIiBYA6ivt25BIQWygswNG=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=MCJ9eIrWw2c9pLpCjj4ZQPlag/hIpzp3X35OtBdI7xurKDTdjaxzCazcRyF7R58dqc+wOCtgbHNZw9cDJJo7as1NIswbzpl2xra8Ge03VB3dZ1wT0pbRyKCPo9QuNyY6kw4NwcNZLVupYFXN5I77gtYknWVPUFre74MWoO70mr/3tko+8ecdKTyr0lrPchZLkPc2FljFFVT9xgWS5rNHvGUUPA653gegOqyoZ31wSd9+Z0fUHKlyVSwdk13uzygWoYU9IbDyKs6UiLIUmqLH72p7DGxTqpto8OeA/yNBRIShmk13Sjx6c+aaU0WZzO6NCWyxfrntlwSLzoQ3uUpWMA== X-YMail-OSG: 3h4EoRYVM1lR0LLOEli.wvntg.xseGyopF0dimnOKLjuArTQaSEQL2HrwbLDdOD 2CCdU.PiAdbqdonBCZgcK9H7AgITOuPy3SkRm2cKUlul.aFkBIlSf88Rph3VV0JfMsvftFRgNTyt 6ojNE20HhoX5eGqUZdIihVRExMlZALSgtWn1RksNvh0cBLv_PN5WkXzMFFvdoda7tUXVj4jhO6N. n5puovNWV_kI6TW8nzwIF1pC6TeOMHSoV7QT8wzHNpWD0mVVpK6DKEPlX6kf4ZsEmS9_VGZrx8Gd JC0xXRde6WeHcCKz.BBara8sO0ulhu.oy4JqKsBzKuQ1bQyO7._LBSEE.p2OjbePybHg941CruVI bxkYJaJ0Q.PUPKPoJI3kq3oDiYAfjuYHdrHfgukZyVgGrt7SdA9HZ6N3pOZ3xum.A2qZTCMiS1v8 3tKwC1lCjNO_4leGw7ZRiLJbXF9pqFPs_UlK0AUXt3RW3Mj0mPCPUnSXRUqDpt3hqJ7lFd_Dkvni Oo1XPu1OPEUmcKC75Uo5f4tC.YISqH5ZYJzTO2ovWJElbk1rfjXqOkrmq33nEVQTf6hmHF4_0H1z fFqVGGPTSpwrtGdMsb1gu5pi_JLN09qOmuUdbnzGt7sr20Mso23FaY7osmxOV7viq2Fbel7r6PQM 28p2rYUMOrFGEgi.1_lr2kh7szO2_kJOpzJw5ff0PpBwPLbGsfKT5vRIxwbW254_CO4oYLEJN.AY sYA8mOMaBmmg1sFZSOWuujO3Ao1_IeTELvqQXK_6eDwNLJO1fKO72.d48R5UNrvg1J2hOeqJya9J 9xJ5hKAqIyiq85zYSyK5aEWP0g7JdStGeFHIkdg3Pi X-Sonic-MF: X-Sonic-ID: 4025179b-3319-45f7-a42f-21395ede07f6 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.ir2.yahoo.com with HTTP; Sat, 18 Mar 2023 01:09:09 +0000 Original-Received: by hermes--production-ir2-5b7d458747-25ckv (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID ebf1ace13c223c4f29f1de536b08e379; Sat, 18 Mar 2023 01:09:05 +0000 (UTC) In-Reply-To: <87a60a3nrj.fsf@yahoo.com> (Po Lu's message of "Sat, 18 Mar 2023 08:29:36 +0800") X-Mailer: WebService/1.1.21311 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:258117 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Po Lu writes: >> I can certainly reproduce an issue with the toolbar in the NS port. I >> think it's the same issue that the OP is describing. Here's some steps >> to reproduce it: >> >> emacs -Q >> >> The Save and the Cut(Kill) icons are enabled. >> >> Resize the Emacs frame a little bit. >> >> The Save and the Cut(Kill) icons are now disabled, as expected, because >> the *scratch* buffer is not backed by a file, and there's no active >> region. > > If it helps, I don't see this at all on GNUstep. Both buttons are > initially disabled. I've browsed some old Apple documentation and I think the way the toolbar validation is implemented in the NS port may not be totally correct. https://web.archive.org/web/20090405012930if_/http://developer.apple.com/do= cumentation/Cocoa/Conceptual/Toolbars/Tasks/ValidatingTBItems.html#//apple_= ref/doc/uid/20000753-1036447 states that "If an image item has a valid target/action pair, then the toolbar will call NSToolbarItemValidation=E2=80=99s validateToolbarItem: on target if the target implements it; otherwise the item is enabled by default.". So I've implemented the above idea in the attached patch and it fixes the issue for me. I've also removed the validateVisibleItems override, which should not be needed (and it's probably incorrect, as Apple's documentation says that if you override this method, you must call super). Could you check if the patch also works fine on GNUStep? If not, perhaps we could make the change conditional to Apple systems. Thanks. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-toolbar-item-validation-in-the-NS-port.patch >From eabab73b0dca6cd7aff67427b4443fd08f3b9bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= Date: Sat, 18 Mar 2023 01:47:32 +0100 Subject: [PATCH] Fix toolbar item validation in the NS port * src/nsmenu.m ([EmacsToolbar validateVisibleItems]): Remove this override, which is not really needed. Also, it doesn't do the right thing, because Apple's documentation states that this method, if overriden, must call super. * src/nsterm.m ([EmacsView validateToolbarItem:]): Implement this NSToolbarItemValidation method instead, which is called by AppKit when it needs to validate an image item. --- src/nsmenu.m | 8 -------- src/nsterm.m | 5 +++++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/nsmenu.m b/src/nsmenu.m index 2c1f575bdf2..f7a401dc407 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -1346,14 +1346,6 @@ - (void) addDisplayItemWithImage: (EmacsImage *)img enablement = (enablement << 1) | (enabled == YES); } -/* This overrides super's implementation, which automatically sets - all items to enabled state (for some reason). */ -- (void)validateVisibleItems -{ - NSTRACE ("[EmacsToolbar validateVisibleItems]"); -} - - /* delegate methods */ - (NSToolbarItem *)toolbar: (NSToolbar *)toolbar diff --git a/src/nsterm.m b/src/nsterm.m index 0e75cbf3f0f..8bb22c0f756 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -8573,6 +8573,11 @@ - (instancetype)toolbarClicked: (id)item return self; } +-(BOOL)validateToolbarItem:(NSToolbarItem *)toolbarItem +{ + return [toolbarItem isEnabled]; +} + - (instancetype)toggleToolbar: (id)sender { -- 2.34.1 --=-=-=--