only notify search change when widget was inactive
parent
2a9a57daff
commit
3ab49fdb5f
|
|
@ -223,6 +223,13 @@ pub const SearchOverlay = extern struct {
|
||||||
gtk.Widget.initTemplate(self.as(gtk.Widget));
|
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.
|
/// Grab focus on the search entry and select all text.
|
||||||
pub fn grabFocus(self: *Self) void {
|
pub fn grabFocus(self: *Self) void {
|
||||||
const priv = self.private();
|
const priv = self.private();
|
||||||
|
|
@ -231,10 +238,6 @@ pub const SearchOverlay = extern struct {
|
||||||
// Select all text in the search entry field. -1 is distance from
|
// Select all text in the search entry field. -1 is distance from
|
||||||
// the end, causing the entire text to be selected.
|
// the end, causing the entire text to be selected.
|
||||||
priv.search_entry.as(gtk.Editable).selectRegion(0, -1);
|
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 the total number of search matches.
|
/// Set the total number of search matches.
|
||||||
|
|
|
||||||
|
|
@ -1964,6 +1964,17 @@ pub const Surface = extern struct {
|
||||||
SearchOverlay.properties.active.name,
|
SearchOverlay.properties.active.name,
|
||||||
&value,
|
&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) {
|
if (active) {
|
||||||
priv.search_overlay.grabFocus();
|
priv.search_overlay.grabFocus();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue