Replies: 1 comment
-
|
I managed to get something working using the gtk4 book example. Maybe this is helpful. fn init(
_: Self::Init,
root: Self::Root,
_sender: ComponentSender<Self>,
) -> ComponentParts<Self> {
let model = Self {};
let selection_model = gtk::gio::ListStore::new::<gtk::StringObject>();
let sort_function = | to_insert: >k::glib::Object, existing: >k::glib::Object | -> std::cmp::Ordering { to_insert.cmp(existing) };
selection_model.insert_sorted(>k::StringObject::new("Test"), &sort_function);
selection_model.insert_sorted(>k::StringObject::new("Test2"), &sort_function);
selection_model.insert_sorted(>k::StringObject::new("Test3"), &sort_function);
let selection = 2;
view! {
widgets = root.clone() {
add = &adw::PreferencesPage::new() {
add = &adw::PreferencesGroup::new() {
set_title: "Terminal settings",
add = &adw::ComboRow::new() {
set_title: "Terminal",
#[wrap(Some)]
set_model = >k::SingleSelection::new(Some(selection_model)),
#[watch]
set_selected: selection,
},
},
},
}
}
ComponentParts { model, widgets }
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
On gtk4-rs side, dropdown usage is really a mess. GObject inheriting complicates things and if I need to set a model to a dropdown like this, it is really a mess:
Basically the goal is: show a list of countries and when a country selected, get the selected country's id to call an api with it (like weather status).
On Pure GTK4 Side, I need to define a PropertyExpression and a model. And inherit the GObject stuff for my model struct to handle it.
Is there any example about how can I create a DropDown with a model and expression easily? Should I follow what I do exactly on pure gtk4 side? Is there an easy way to do it (like factory? but I suppose it doesn't fit in this case?)?
Beta Was this translation helpful? Give feedback.
All reactions