gtk(command_palette): address feedback related to selections

See #7173, #7175
pull/7167/head
Leah Amelia Chen 2025-04-24 12:39:36 +08:00
parent 7293d91f10
commit 2800e0c99b
No known key found for this signature in database
2 changed files with 5 additions and 6 deletions

View File

@ -30,7 +30,7 @@ search: *gtk.SearchEntry,
view: *gtk.ListView,
/// The model that provides filtered data for the view to display.
model: *gio.ListModel,
model: *gtk.SingleSelection,
/// The list that serves as the data source of the model.
/// This is where all command data is ultimately stored.
@ -50,7 +50,7 @@ pub fn init(self: *CommandPalette, window: *Window) !void {
.dialog = builder.getObject(adw.Dialog, "command-palette").?,
.search = builder.getObject(gtk.SearchEntry, "search").?,
.view = builder.getObject(gtk.ListView, "view").?,
.model = builder.getObject(gio.ListModel, "model").?,
.model = builder.getObject(gtk.SingleSelection, "model").?,
.source = builder.getObject(gio.ListStore, "source").?,
};
@ -143,9 +143,8 @@ fn searchStopped(_: *gtk.SearchEntry, self: *CommandPalette) callconv(.c) void {
}
fn searchActivated(_: *gtk.SearchEntry, self: *CommandPalette) callconv(.c) void {
// If Enter is pressed in the search bar,
// then activate the first entry (if any)
self.activated(0);
// If Enter is pressed, activate the selected entry
self.activated(self.model.getSelected());
}
fn rowActivated(_: *gtk.ListView, pos: c_uint, self: *CommandPalette) callconv(.c) void {

View File

@ -28,7 +28,7 @@ Adw.Dialog command-palette {
show-separators: true;
single-click-activate: true;
model: NoSelection model {
model: SingleSelection model {
model: FilterListModel {
incremental: true;