From 079437d97cee8e61e4b4214d8d685e8d84d1eb28 Mon Sep 17 00:00:00 2001 From: Ronald Oussoren Date: Sat, 9 Dec 2023 11:05:01 +0100 Subject: [PATCH 1/4] gh-88516: show file proxy icon in IDLE editor windows on macOS The platform standard on macOS is to show a proxy icon for open files in the titlebar of Windows. Make sure IDLE matches this behaviour. --- Lib/idlelib/editor.py | 4 ++++ .../next/IDLE/2023-12-09-11-04-26.gh-issue-88516.SIIvfs.rst | 2 ++ 2 files changed, 6 insertions(+) create mode 100644 Misc/NEWS.d/next/IDLE/2023-12-09-11-04-26.gh-issue-88516.SIIvfs.rst diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index 6ad383f460c7ee..bb2b743f7cb826 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -1058,6 +1058,10 @@ def saved_change_hook(self): self.top.wm_title(title) self.top.wm_iconname(icon) + if macosx.isCocoaTk(): + # Add a proxy icon to the window title + self.top.wm_attributes("-titlepath", long) + def get_saved(self): return self.undo.get_saved() diff --git a/Misc/NEWS.d/next/IDLE/2023-12-09-11-04-26.gh-issue-88516.SIIvfs.rst b/Misc/NEWS.d/next/IDLE/2023-12-09-11-04-26.gh-issue-88516.SIIvfs.rst new file mode 100644 index 00000000000000..b6dea5029bf353 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2023-12-09-11-04-26.gh-issue-88516.SIIvfs.rst @@ -0,0 +1,2 @@ +On macOS show a proxy icon in the title bar of editor windows to match +platform behaviour. From 37295a1b94309898e7b213aef79495839c5ea48c Mon Sep 17 00:00:00 2001 From: Ronald Oussoren Date: Sat, 9 Dec 2023 14:21:29 +0100 Subject: [PATCH 2/4] Don't use both the long and short names in the window title The behaviour of other editors (such as Text Editor) is to show only the short name with the proxy icon. --- Lib/idlelib/editor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index bb2b743f7cb826..10fbc6da6a2147 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -1043,7 +1043,9 @@ def open_recent_file(fn_closure=file_name): def saved_change_hook(self): short = self.short_title() long = self.long_title() - if short and long: + if short and long and not macosx.isCocoaTk(): + # Don't use both values on macOS because + # that doesn't match platform conventions. title = short + " - " + long + _py_version elif short: title = short From 1611a590daa3f67c0ff3b384da3c53b41f079203 Mon Sep 17 00:00:00 2001 From: Ronald Oussoren Date: Sat, 9 Dec 2023 14:28:05 +0100 Subject: [PATCH 3/4] Also maintain the window modification status --- Lib/idlelib/editor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index 10fbc6da6a2147..2ef0569822f003 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -1054,7 +1054,7 @@ def saved_change_hook(self): else: title = "untitled" icon = short or long or title - if not self.get_saved(): + if not self.get_saved() and not macosx.isCocoaTk(): title = "*%s*" % title icon = "*%s" % icon self.top.wm_title(title) @@ -1064,6 +1064,9 @@ def saved_change_hook(self): # Add a proxy icon to the window title self.top.wm_attributes("-titlepath", long) + # Maintain the modification status for the window + self.top.wm_attributes("-modified", not self.get_saved()) + def get_saved(self): return self.undo.get_saved() From b27b37445b46a981db82f30713ad50b8d65257fb Mon Sep 17 00:00:00 2001 From: Ronald Oussoren Date: Sat, 10 Feb 2024 11:56:18 +0100 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Terry Jan Reedy --- Lib/idlelib/editor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index 2ef0569822f003..9cf62255e037b9 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -1054,7 +1054,7 @@ def saved_change_hook(self): else: title = "untitled" icon = short or long or title - if not self.get_saved() and not macosx.isCocoaTk(): + if not self.get_saved(): title = "*%s*" % title icon = "*%s" % icon self.top.wm_title(title)