Skip to content

Commit

Permalink
Drop dead feature that disables unsafe paste warning while Terminal o…
Browse files Browse the repository at this point in the history
…pens (#803)

* UnsafePasteDialog: Fix unsafe_ignored flag being a dead code

* 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.

---------

Co-authored-by: Jeremy Wootten <[email protected]>
  • Loading branch information
ryonakano and jeremypw authored Nov 9, 2024
1 parent 588473c commit f1148c6
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
8 changes: 0 additions & 8 deletions src/Dialogs/UnsafePasteDialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,11 @@ 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);

Terminal.Application.settings.bind (
"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;
}
}
}
1 change: 0 additions & 1 deletion src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
6 changes: 2 additions & 4 deletions src/Widgets/TerminalWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -538,6 +535,7 @@ 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 ();
Expand Down

0 comments on commit f1148c6

Please sign in to comment.