mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2024-12-19 14:38:44 +00:00
graphmanager: can remove property
Add public remove_property to PropertyExt
This commit is contained in:
parent
8059f73f51
commit
a21350b4a0
3 changed files with 28 additions and 4 deletions
|
@ -344,6 +344,14 @@ impl PropertyExt for Node {
|
|||
self.update_description();
|
||||
}
|
||||
|
||||
/// Remove a port property with a name.
|
||||
///
|
||||
fn remove_property(&self, name: &str) {
|
||||
let private = imp::Node::from_instance(self);
|
||||
trace!("property name={} removed", name);
|
||||
private.properties.borrow_mut().remove(name);
|
||||
}
|
||||
|
||||
/// Retrieves node properties.
|
||||
///
|
||||
fn properties(&self) -> Ref<HashMap<String, String>> {
|
||||
|
|
|
@ -22,7 +22,7 @@ use gtk::{
|
|||
prelude::*,
|
||||
subclass::prelude::*,
|
||||
};
|
||||
use log::info;
|
||||
use log::trace;
|
||||
use std::cell::RefCell;
|
||||
use std::cell::{Cell, Ref};
|
||||
use std::collections::HashMap;
|
||||
|
@ -223,17 +223,25 @@ impl SelectionExt for Port {
|
|||
}
|
||||
|
||||
impl PropertyExt for Port {
|
||||
/// Add a node property with a name and a value.
|
||||
/// Add a port property with a name and a value.
|
||||
///
|
||||
fn add_property(&self, name: &str, value: &str) {
|
||||
let private = imp::Port::from_instance(self);
|
||||
info!("property name={} updated with value={}", name, value);
|
||||
trace!("property name={} updated with value={}", name, value);
|
||||
private
|
||||
.properties
|
||||
.borrow_mut()
|
||||
.insert(name.to_string(), value.to_string());
|
||||
}
|
||||
|
||||
/// Remove a port property with a name.
|
||||
///
|
||||
fn remove_property(&self, name: &str) {
|
||||
let private = imp::Port::from_instance(self);
|
||||
trace!("property name={} removed", name);
|
||||
private.properties.borrow_mut().remove(name);
|
||||
}
|
||||
|
||||
/// Retrieves node properties.
|
||||
///
|
||||
fn properties(&self) -> Ref<HashMap<String, String>> {
|
||||
|
|
|
@ -28,13 +28,21 @@ pub trait PropertyExt {
|
|||
///
|
||||
fn add_property(&self, name: &str, value: &str);
|
||||
|
||||
/// Add a node property with a name and a value.
|
||||
///
|
||||
fn remove_property(&self, name: &str);
|
||||
|
||||
/// Update the properties.
|
||||
///
|
||||
/// Update the PropertyExt properties.
|
||||
///
|
||||
fn update_properties(&self, new_properties: &HashMap<String, String>) {
|
||||
for (key, value) in new_properties {
|
||||
self.add_property(key, value);
|
||||
if value.is_empty() {
|
||||
self.remove_property(key);
|
||||
} else {
|
||||
self.add_property(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue