app: support of caps filter by link name

This commit is contained in:
Stéphane Cerveau 2023-08-11 11:35:39 +02:00
parent aaf47503fe
commit ad6c53a531
2 changed files with 29 additions and 4 deletions

View file

@ -818,6 +818,29 @@ impl GPSApp {
None None
}), }),
); );
let app_weak = self.downgrade();
self.graphview.borrow().connect_local(
"link-double-clicked",
false,
glib::clone!(@weak application => @default-return None, move |values: &[Value]| {
let app = upgrade_weak!(app_weak, None);
let link_id = values[1].get::<u32>().expect("link id args[1]");
GPS_TRACE!("link double clicked id={}", link_id);
let link = app.graphview.borrow().link(link_id).unwrap();
GPSUI::dialog::create_input_dialog(
"Enter caps filter description",
"description",
&link.name(),
&app,
move |app, link_desc| {
GPS_ERROR!("link double clicked id={}", link.id());
app.graphview.borrow().set_link_name(link.id(), link_desc.as_str());
GPS_ERROR!("link double clicked name={}", link.name());
},
);
None
}),
);
// Setup the favorite list // Setup the favorite list
GPSUI::elements::setup_favorite_list(self); GPSUI::elements::setup_favorite_list(self);
@ -959,11 +982,9 @@ impl GPSApp {
node_to_id: u32, node_to_id: u32,
port_from_id: u32, port_from_id: u32,
port_to_id: u32, port_to_id: u32,
active: bool,
) { ) {
let graphview = self.graphview.borrow(); let graphview = self.graphview.borrow();
let link = let link = graphview.create_link(node_from_id, node_to_id, port_from_id, port_to_id);
graphview.create_link(node_from_id, node_to_id, port_from_id, port_to_id, active);
graphview.add_link(link); graphview.add_link(link);
} }

View file

@ -362,6 +362,11 @@ impl Player {
if n_ports > 1 { if n_ports > 1 {
let _ = write!(description, "{unique_name}. ! "); let _ = write!(description, "{unique_name}. ! ");
} else { } else {
if let Some(link) = graphview.port_link(port.id()) {
if !link.name().is_empty() {
let _ = write!(description, "! {} ", link.name());
}
}
description.push_str("! "); description.push_str("! ");
} }
if let Some(node) = graphview.node(node_to) { if let Some(node) = graphview.node(node_to) {
@ -416,7 +421,6 @@ impl Player {
peer_node.id(), peer_node.id(),
port.id(), port.id(),
peer_port.id(), peer_port.id(),
true,
); );
} }
} }