From e6bb1a56ebd1ef21709fa81846bbc9f06ec891de Mon Sep 17 00:00:00 2001 From: Yotam Gurfinkel Date: Tue, 31 Dec 2024 14:43:26 +0200 Subject: [PATCH 1/2] config: Add the option `toast_on_clipboard_copy` Add a config option to enable/disable the toast shown on clipboard copy --- src/apprt/gtk/Window.zig | 4 +++- src/config/Config.zig | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/apprt/gtk/Window.zig b/src/apprt/gtk/Window.zig index 0bcb19cc0..352d47e5d 100644 --- a/src/apprt/gtk/Window.zig +++ b/src/apprt/gtk/Window.zig @@ -894,7 +894,9 @@ fn gtkActionCopy( return; }; - self.sendToast("Copied to clipboard"); + if (self.app.config.@"toast-on-clipboard-copy") { + self.sendToast("Copied to clipboard"); + } } fn gtkActionPaste( diff --git a/src/config/Config.zig b/src/config/Config.zig index d8b46d46b..447da5281 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -1276,6 +1276,9 @@ keybind: Keybinds = .{}, @"clipboard-read": ClipboardAccess = .ask, @"clipboard-write": ClipboardAccess = .allow, +/// Enables or disables the toast message on a clipboard copy action. +@"toast-on-clipboard-copy": bool = true, + /// Trims trailing whitespace on data that is copied to the clipboard. This does /// not affect data sent to the clipboard via `clipboard-write`. @"clipboard-trim-trailing-spaces": bool = true, From fb8c83e07c7997dfaddc9a21372764579e76cdc3 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 2 Jan 2025 14:15:09 -0800 Subject: [PATCH 2/2] config: change toast config to packed struct --- src/apprt/gtk/Window.zig | 2 +- src/config/Config.zig | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/apprt/gtk/Window.zig b/src/apprt/gtk/Window.zig index 352d47e5d..40fe0bd67 100644 --- a/src/apprt/gtk/Window.zig +++ b/src/apprt/gtk/Window.zig @@ -894,7 +894,7 @@ fn gtkActionCopy( return; }; - if (self.app.config.@"toast-on-clipboard-copy") { + if (self.app.config.@"adw-toast".@"clipboard-copy") { self.sendToast("Copied to clipboard"); } } diff --git a/src/config/Config.zig b/src/config/Config.zig index 447da5281..bf694f2f5 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -1276,9 +1276,6 @@ keybind: Keybinds = .{}, @"clipboard-read": ClipboardAccess = .ask, @"clipboard-write": ClipboardAccess = .allow, -/// Enables or disables the toast message on a clipboard copy action. -@"toast-on-clipboard-copy": bool = true, - /// Trims trailing whitespace on data that is copied to the clipboard. This does /// not affect data sent to the clipboard via `clipboard-write`. @"clipboard-trim-trailing-spaces": bool = true, @@ -1945,6 +1942,22 @@ keybind: Keybinds = .{}, /// Changing this value at runtime will only affect new windows. @"adw-toolbar-style": AdwToolbarStyle = .raised, +/// Control the toasts that Ghostty shows. Toasts are small notifications +/// that appear overlaid on top of the terminal window. They are used to +/// show information that is not critical but may be important. +/// +/// Valid values are: +/// +/// - `clipboard-copy` (default: true) - Show a toast when text is copied +/// to the clipboard. +/// +/// You can prefix any value with `no-` to disable it. For example, +/// `no-clipboard-copy` will disable the clipboard copy toast. Multiple +/// values can be set by separating them with commas. +/// +/// This configuration only applies to GTK with Adwaita enabled. +@"adw-toast": AdwToast = .{}, + /// If `true` (default), then the Ghostty GTK tabs will be "wide." Wide tabs /// are the new typical Gnome style where tabs fill their available space. /// If you set this to `false` then tabs will only take up space they need, @@ -5445,6 +5458,11 @@ pub const AdwToolbarStyle = enum { @"raised-border", }; +/// See adw-toast +pub const AdwToast = packed struct { + @"clipboard-copy": bool = true, +}; + /// See mouse-shift-capture pub const MouseShiftCapture = enum { false,