Skip to content

Commit

Permalink
ui: fix unselect for the popupmenu
Browse files Browse the repository at this point in the history
  • Loading branch information
vhakulinen committed Nov 29, 2022
1 parent 1c380dc commit 19dbfbf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ui/src/components/popupmenu/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ impl ObjectImpl for Popupmenu {
row.set_item(&item.borrow());
});

self.selection_model.set_autoselect(false);
self.selection_model.set_can_unselect(true);
self.selection_model.set_model(Some(&*self.store.borrow()));
self.listview.set_model(Some(&self.selection_model));
self.listview.set_factory(Some(&factory));
Expand Down
7 changes: 6 additions & 1 deletion ui/src/components/popupmenu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ impl Popupmenu {
let imp = self.imp();

if n < 0 {
imp.selection_model.unselect_all();
// NOTE(ville): unselect_all is not supported on gtk::SingleSelection model,
// so we'll have to unselected the selected item manually.
let selected = imp.selection_model.selected();
if selected != gtk::INVALID_LIST_POSITION {
imp.selection_model.unselect_item(selected);
}
} else {
let n = n as u32;
imp.selection_model.select_item(n, true);
Expand Down

0 comments on commit 19dbfbf

Please sign in to comment.