The model for dropdown should has no selection

This commit is contained in:
daleclack 2024-01-11 19:12:29 +08:00
parent a1801762c0
commit 42dc2a0fc6
2 changed files with 6 additions and 4 deletions

View File

@ -22,7 +22,9 @@ MainWin::MainWin()
// Create List for column View
main_list = Gio::ListStore<ModelColumns>::create();
selection = Gtk::SingleSelection::create(main_list);
// The list for dropdown to select should has no selection
selection = Gtk::NoSelection::create(main_list);
main_column_view.set_model(selection);
// Add items
@ -162,13 +164,13 @@ void MainWin::bind_version(const Glib::RefPtr<Gtk::ListItem> &item)
void MainWin::btnadd_clicked()
{
// Append a item to the list
main_list->append(ModelColumns::create(" ", " "));
main_list->append(ModelColumns::create("", ""));
}
void MainWin::btnremove_clicked()
{
// Get Position of item
auto pos = selection->get_selected();
auto pos = main_list->get_n_items() - 1;
// Remove item
main_list->remove(pos);

View File

@ -69,7 +69,7 @@ public:
private:
// Main list object for branchs and versions
Glib::RefPtr<Gio::ListStore<ModelColumns>> main_list;
Glib::RefPtr<Gtk::SingleSelection> selection;
Glib::RefPtr<Gtk::NoSelection> selection;
// Factory to renderer string for dropdown
Glib::RefPtr<Gtk::SignalListItemFactory> drop_factory;