only update search when going from inactive to active
parent
3ab49fdb5f
commit
27c82f739e
|
|
@ -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,
|
||||
},
|
||||
),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
|
@ -223,13 +230,6 @@ pub const SearchOverlay = extern struct {
|
|||
gtk.Widget.initTemplate(self.as(gtk.Widget));
|
||||
}
|
||||
|
||||
/// Update search contents when widget is activated
|
||||
pub fn updateSearch(self: *Self) void {
|
||||
const priv = self.private();
|
||||
const text = priv.search_entry.as(gtk.Editable).getText();
|
||||
signals.@"search-changed".impl.emit(self, null, .{text}, null);
|
||||
}
|
||||
|
||||
/// Grab focus on the search entry and select all text.
|
||||
pub fn grabFocus(self: *Self) void {
|
||||
const priv = self.private();
|
||||
|
|
@ -240,6 +240,16 @@ pub const SearchOverlay = extern struct {
|
|||
priv.search_entry.as(gtk.Editable).selectRegion(0, -1);
|
||||
}
|
||||
|
||||
// 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.
|
||||
pub fn setSearchTotal(self: *Self, total: ?usize) void {
|
||||
const priv = self.private();
|
||||
|
|
@ -264,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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1965,16 +1965,6 @@ pub const Surface = extern struct {
|
|||
&value,
|
||||
);
|
||||
|
||||
var is_active = gobject.ext.Value.newFrom(false);
|
||||
defer is_active.unset();
|
||||
gobject.Object.getProperty(
|
||||
priv.search_overlay.as(gobject.Object),
|
||||
SearchOverlay.properties.active.name,
|
||||
&is_active
|
||||
);
|
||||
if (active and !is_active) {
|
||||
priv.search_overlay.updateSearch();
|
||||
}
|
||||
if (active) {
|
||||
priv.search_overlay.grabFocus();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue