From cbd6cc8ec516c5b6675e4f023da176a028bd357c Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Fri, 8 Nov 2024 22:23:27 +0900 Subject: [PATCH 1/2] UnsafePasteDialog: Fix unsafe_ignored flag being a dead code --- src/Dialogs/UnsafePasteDialog.vala | 8 -------- src/Widgets/TerminalWidget.vala | 1 + 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Dialogs/UnsafePasteDialog.vala b/src/Dialogs/UnsafePasteDialog.vala index 53b13bd3de..fa14fe1b56 100644 --- a/src/Dialogs/UnsafePasteDialog.vala +++ b/src/Dialogs/UnsafePasteDialog.vala @@ -42,7 +42,6 @@ public class Terminal.UnsafePasteDialog : Granite.MessageDialog { var ignore_button = (Gtk.Button) add_button (_("Paste Anyway"), Gtk.ResponseType.ACCEPT); ignore_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION); - ignore_button.clicked.connect (on_ignore); set_default_response (Gtk.ResponseType.CANCEL); @@ -50,11 +49,4 @@ public class Terminal.UnsafePasteDialog : Granite.MessageDialog { "unsafe-paste-alert", show_protection_warnings, "active", SettingsBindFlags.DEFAULT ); } - - private void on_ignore () { - var terminal_window = get_transient_for (); - if (terminal_window is MainWindow) { - ((MainWindow) terminal_window).unsafe_ignored = true; - } - } } diff --git a/src/Widgets/TerminalWidget.vala b/src/Widgets/TerminalWidget.vala index f26628c2dc..f25debdc3f 100644 --- a/src/Widgets/TerminalWidget.vala +++ b/src/Widgets/TerminalWidget.vala @@ -542,6 +542,7 @@ namespace Terminal { dialog.response.connect ((res) => { dialog.destroy (); if (res == Gtk.ResponseType.ACCEPT) { + toplevel.unsafe_ignored = true; feed_child (text.data); } }); From 8c8198225324b4684225a8f2d70e583f19e2e2ff Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Sat, 9 Nov 2024 07:59:25 +0900 Subject: [PATCH 2/2] Remove extra unsafe_ignored flag We can now toggle unsafe paste warning from prerferences menu, so this feature that prevents unsafe paste warning from being shown just during the session is useless. --- src/MainWindow.vala | 1 - src/Widgets/TerminalWidget.vala | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 9d3db77c95..073550e2b0 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -54,7 +54,6 @@ namespace Terminal { private const int MAXIMIZED = 1; private const int FULLSCREEN = 2; - public bool unsafe_ignored; public bool focus_restored_tabs { get; construct; default = true; } public bool recreate_tabs { get; construct; default = true; } public Menu context_menu_model { get; private set; } diff --git a/src/Widgets/TerminalWidget.vala b/src/Widgets/TerminalWidget.vala index f25debdc3f..522566e2e4 100644 --- a/src/Widgets/TerminalWidget.vala +++ b/src/Widgets/TerminalWidget.vala @@ -526,10 +526,7 @@ namespace Terminal { // Check pasted and dropped text before feeding to child; private void validated_feed (string? text) { if (text != null && text.validate ()) { - unowned var toplevel = (MainWindow) get_toplevel (); - if (!toplevel.unsafe_ignored && - Application.settings.get_boolean ("unsafe-paste-alert")) { - + if (Application.settings.get_boolean ("unsafe-paste-alert")) { string? warn_text = null; if ("\n" in text) { warn_text = _("The pasted text may contain multiple commands"); @@ -538,11 +535,11 @@ namespace Terminal { } if (warn_text != null) { + unowned var toplevel = (MainWindow) get_toplevel (); var dialog = new UnsafePasteDialog (toplevel, warn_text, text.strip ()); dialog.response.connect ((res) => { dialog.destroy (); if (res == Gtk.ResponseType.ACCEPT) { - toplevel.unsafe_ignored = true; feed_child (text.data); } });