From ad6c53a53196076f4b324539b6175276ee1d110b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Fri, 11 Aug 2023 11:35:39 +0200 Subject: [PATCH] app: support of caps filter by link name --- src/app.rs | 27 ++++++++++++++++++++++++--- src/gps/player.rs | 6 +++++- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/app.rs b/src/app.rs index d18435d..9c015e9 100644 --- a/src/app.rs +++ b/src/app.rs @@ -818,6 +818,29 @@ impl GPSApp { 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::().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 GPSUI::elements::setup_favorite_list(self); @@ -959,11 +982,9 @@ impl GPSApp { node_to_id: u32, port_from_id: u32, port_to_id: u32, - active: bool, ) { let graphview = self.graphview.borrow(); - let link = - graphview.create_link(node_from_id, node_to_id, port_from_id, port_to_id, active); + let link = graphview.create_link(node_from_id, node_to_id, port_from_id, port_to_id); graphview.add_link(link); } diff --git a/src/gps/player.rs b/src/gps/player.rs index f55fa1a..6ddd5ae 100644 --- a/src/gps/player.rs +++ b/src/gps/player.rs @@ -362,6 +362,11 @@ impl Player { if n_ports > 1 { let _ = write!(description, "{unique_name}. ! "); } else { + if let Some(link) = graphview.port_link(port.id()) { + if !link.name().is_empty() { + let _ = write!(description, "! {} ", link.name()); + } + } description.push_str("! "); } if let Some(node) = graphview.node(node_to) { @@ -416,7 +421,6 @@ impl Player { peer_node.id(), port.id(), peer_port.id(), - true, ); } }