apprt/gtk: hook up close search button

pull/9756/head
Mitchell Hashimoto 2025-11-29 15:31:28 -08:00
parent 76496d40fd
commit eebce6a78c
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
3 changed files with 10 additions and 4 deletions

View File

@ -187,6 +187,10 @@ pub const SearchOverlay = extern struct {
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);
@ -262,6 +266,7 @@ 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);

View File

@ -3197,10 +3197,10 @@ pub const Surface = extern struct {
}
fn searchStop(_: *SearchOverlay, self: *Self) callconv(.c) void {
// Note: at the time of writing this, this behavior doesn't match
// macOS. But I think it makes more sense on Linux/GTK to do this.
// We may follow suit on macOS in the future.
self.setSearchActive(false);
const surface = self.core() orelse return;
_ = surface.performBindingAction(.end_search) catch |err| {
log.warn("unable to perform end_search action err={}", .{err});
};
_ = self.private().gl_area.as(gtk.Widget).grabFocus();
}

View File

@ -69,6 +69,7 @@ template $GhosttySearchOverlay: Adw.Bin {
Button close_button {
icon-name: "window-close-symbolic";
tooltip-text: _("Close");
clicked => $stop_search_button();
cursor: Gdk.Cursor {
name: "pointer";