GTK: followup update search state on activation (#9766)
followup from comment in this PR https://github.com/ghostty-org/ghostty/pull/9765pull/9777/head
commit
09f7e38b45
|
|
@ -43,7 +43,14 @@ pub const SearchOverlay = extern struct {
|
|||
bool,
|
||||
.{
|
||||
.default = false,
|
||||
.accessor = C.privateShallowFieldAccessor("active"),
|
||||
.accessor = gobject.ext.typedAccessor(
|
||||
Self,
|
||||
bool,
|
||||
.{
|
||||
.getter = getSearchActive,
|
||||
.setter = setSearchActive,
|
||||
},
|
||||
),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
|
@ -231,10 +238,16 @@ pub const SearchOverlay = extern struct {
|
|||
// Select all text in the search entry field. -1 is distance from
|
||||
// the end, causing the entire text to be selected.
|
||||
priv.search_entry.as(gtk.Editable).selectRegion(0, -1);
|
||||
}
|
||||
|
||||
// update search state with the active text
|
||||
const text = priv.search_entry.as(gtk.Editable).getText();
|
||||
signals.@"search-changed".impl.emit(self, null, .{text}, null);
|
||||
// Set active status, and update search on activation
|
||||
fn setSearchActive(self: *Self, active: bool) void {
|
||||
const priv = self.private();
|
||||
if (!priv.active and active) {
|
||||
const text = priv.search_entry.as(gtk.Editable).getText();
|
||||
signals.@"search-changed".impl.emit(self, null, .{text}, null);
|
||||
}
|
||||
priv.active = active;
|
||||
}
|
||||
|
||||
/// Set the total number of search matches.
|
||||
|
|
@ -261,6 +274,10 @@ pub const SearchOverlay = extern struct {
|
|||
}
|
||||
}
|
||||
|
||||
fn getSearchActive(self: *Self) bool {
|
||||
return self.private().active;
|
||||
}
|
||||
|
||||
fn getSearchTotal(self: *Self) u64 {
|
||||
return self.private().search_total orelse 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1964,6 +1964,7 @@ pub const Surface = extern struct {
|
|||
SearchOverlay.properties.active.name,
|
||||
&value,
|
||||
);
|
||||
|
||||
if (active) {
|
||||
priv.search_overlay.grabFocus();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue