favorites: display properties as well

As in element list, display properties when selected
This commit is contained in:
Stéphane Cerveau 2022-01-28 16:16:29 +01:00
parent b84483057b
commit 18606b687c

View file

@ -53,6 +53,15 @@ pub fn setup_favorite_list(app: &GPSApp) {
app.add_new_element(&element_name); app.add_new_element(&element_name);
} }
}); });
let app_weak = app.downgrade();
favorite_list.connect_cursor_changed(move |tree_view| {
let app = upgrade_weak!(app_weak);
let selection = tree_view.selection();
if let Some((model, iter)) = selection.selected() {
let element_name = model.get::<String>(&iter, 0);
display_properties(&app, &element_name);
}
});
let gesture = gtk::GestureClick::new(); let gesture = gtk::GestureClick::new();
gesture.set_button(0); gesture.set_button(0);
let app_weak = app.downgrade(); let app_weak = app.downgrade();
@ -138,7 +147,13 @@ pub fn setup_elements_list(app: &GPSApp) {
let selection = tree_view.selection(); let selection = tree_view.selection();
if let Some((model, iter)) = selection.selected() { if let Some((model, iter)) = selection.selected() {
let element_name = model.get::<String>(&iter, 0); let element_name = model.get::<String>(&iter, 0);
let description = GPS::ElementInfo::element_description(&element_name) display_properties(&app, &element_name);
}
});
}
pub fn display_properties(app: &GPSApp, element_name: &str) {
let description = GPS::ElementInfo::element_description(element_name)
.expect("Unable to get element description from GStreamer"); .expect("Unable to get element description from GStreamer");
let box_property: Box = app let box_property: Box = app
.builder .builder
@ -156,5 +171,3 @@ pub fn setup_elements_list(app: &GPSApp) {
label.set_selectable(true); label.set_selectable(true);
box_property.append(&label); box_property.append(&label);
} }
});
}