From 72b3c14833d11053681605948c35eae5a8f744ad Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 29 Nov 2025 20:16:48 -0800 Subject: [PATCH] clean up some stuff --- src/apprt/gtk/class/search_overlay.zig | 30 ++++++++----------------- src/apprt/gtk/ui/1.2/search-overlay.blp | 6 ++--- src/apprt/gtk/ui/1.2/surface.blp | 2 -- 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/apprt/gtk/class/search_overlay.zig b/src/apprt/gtk/class/search_overlay.zig index 396946062..e469e1903 100644 --- a/src/apprt/gtk/class/search_overlay.zig +++ b/src/apprt/gtk/class/search_overlay.zig @@ -184,32 +184,23 @@ pub const SearchOverlay = extern struct { //--------------------------------------------------------------- // Template callbacks - fn stopSearch(_: *gtk.SearchEntry, self: *Self) callconv(.c) void { - signals.@"stop-search".impl.emit(self, null, .{}, null); - } - - fn stopSearchButton(_: *gtk.Button, self: *Self) callconv(.c) void { - signals.@"stop-search".impl.emit(self, null, .{}, null); - } - fn searchChanged(entry: *gtk.SearchEntry, self: *Self) callconv(.c) void { const text = entry.as(gtk.Editable).getText(); signals.@"search-changed".impl.emit(self, null, .{text}, null); } - fn nextMatch(_: *gtk.Button, self: *Self) callconv(.c) void { + // NOTE: The callbacks below use anyopaque for the first parameter + // because they're shared with multiple widgets in the template. + + fn stopSearch(_: *anyopaque, self: *Self) callconv(.c) void { + signals.@"stop-search".impl.emit(self, null, .{}, null); + } + + fn nextMatch(_: *anyopaque, self: *Self) callconv(.c) void { signals.@"next-match".impl.emit(self, null, .{}, null); } - fn previousMatch(_: *gtk.Button, self: *Self) callconv(.c) void { - signals.@"previous-match".impl.emit(self, null, .{}, null); - } - - fn nextMatchEntry(_: *gtk.SearchEntry, self: *Self) callconv(.c) void { - signals.@"next-match".impl.emit(self, null, .{}, null); - } - - fn previousMatchEntry(_: *gtk.SearchEntry, self: *Self) callconv(.c) void { + fn previousMatch(_: *anyopaque, self: *Self) callconv(.c) void { signals.@"previous-match".impl.emit(self, null, .{}, null); } @@ -267,13 +258,10 @@ pub const SearchOverlay = extern struct { // Template Callbacks class.bindTemplateCallback("stop_search", &stopSearch); - class.bindTemplateCallback("stop_search_button", &stopSearchButton); class.bindTemplateCallback("search_changed", &searchChanged); class.bindTemplateCallback("match_label_closure", &closureMatchLabel); class.bindTemplateCallback("next_match", &nextMatch); class.bindTemplateCallback("previous_match", &previousMatch); - class.bindTemplateCallback("next_match_entry", &nextMatchEntry); - class.bindTemplateCallback("previous_match_entry", &previousMatchEntry); // Properties gobject.ext.registerProperties(class, &.{ diff --git a/src/apprt/gtk/ui/1.2/search-overlay.blp b/src/apprt/gtk/ui/1.2/search-overlay.blp index 0d2dd659b..7ca5fded7 100644 --- a/src/apprt/gtk/ui/1.2/search-overlay.blp +++ b/src/apprt/gtk/ui/1.2/search-overlay.blp @@ -23,8 +23,8 @@ template $GhosttySearchOverlay: Adw.Bin { hexpand: true; stop-search => $stop_search(); search-changed => $search_changed(); - next-match => $next_match_entry(); - previous-match => $previous_match_entry(); + next-match => $next_match(); + previous-match => $previous_match(); } Label { @@ -69,7 +69,7 @@ template $GhosttySearchOverlay: Adw.Bin { Button close_button { icon-name: "window-close-symbolic"; tooltip-text: _("Close"); - clicked => $stop_search_button(); + clicked => $stop_search(); cursor: Gdk.Cursor { name: "pointer"; diff --git a/src/apprt/gtk/ui/1.2/surface.blp b/src/apprt/gtk/ui/1.2/surface.blp index 0abc6c356..4ebfeabfb 100644 --- a/src/apprt/gtk/ui/1.2/surface.blp +++ b/src/apprt/gtk/ui/1.2/surface.blp @@ -149,8 +149,6 @@ Overlay terminal_page { [overlay] $GhosttySearchOverlay search_overlay { - halign: end; - valign: start; stop-search => $search_stop(); search-changed => $search_changed(); next-match => $search_next_match();