Skip to content

Commit

Permalink
Add getter for metadata object.
Browse files Browse the repository at this point in the history
  • Loading branch information
saivert committed May 10, 2024
1 parent fad5cba commit ac9da6a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/backend/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ mod imp {
pub(crate) device_model: gio::ListStore,

pub metadata_om: OnceCell<wp::registry::ObjectManager>,
#[property(get)]
pub metadata: RefCell<Option<wp::pw::Metadata>>,

#[property(get)]
Expand Down
6 changes: 3 additions & 3 deletions src/backend/pwnodeobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ impl PwNodeObject {

let manager = PwvucontrolManager::default();

if let Some(metadata) = manager.imp().metadata.borrow().as_ref() {
if let Some(metadata) = manager.metadata() {
metadata.set(self.boundid(), Some("target.node"), Some("Spa:Id"), Some(&target_node.boundid().to_string()));
metadata.set(self.boundid(), Some("target.object"), Some("Spa:Id"), Some(&target_node.serial().to_string()));
} else {
Expand Down Expand Up @@ -510,7 +510,7 @@ impl PwNodeObject {
let manager = PwvucontrolManager::default();

let om = manager.imp().wp_object_manager.get().unwrap();
if let Some(metadata) = manager.imp().metadata.borrow().as_ref() {
if let Some(metadata) = manager.metadata() {
if let Some(target_serial) = metadata.find_notype(self.boundid(), "target.object") {
if target_serial != "-1" {
if let Some(sinknode) = om.lookup([
Expand Down Expand Up @@ -545,7 +545,7 @@ impl PwNodeObject {
pub(crate) fn unset_default_target(&self) {
let manager = PwvucontrolManager::default();

if let Some(metadata) = manager.imp().metadata.borrow().as_ref() {
if let Some(metadata) = manager.metadata() {
metadata.set(self.boundid(), Some("target.node"), Some("Spa:Id"), Some("-1"));
metadata.set(self.boundid(), Some("target.object"), Some("Spa:Id"), Some("-1"));
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/volumebox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ mod imp {
fn dispose(&self) {
if let Some(sid) = self.metadata_changed_event.take() {
let manager = PwvucontrolManager::default();
if let Some(metadata) = manager.imp().metadata.borrow().as_ref() {
if let Some(metadata) = manager.metadata() {
metadata.disconnect(sid);
};
};
Expand Down

0 comments on commit ac9da6a

Please sign in to comment.