apprt/gtk: hook up close search button
parent
76496d40fd
commit
eebce6a78c
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
Loading…
Reference in New Issue