Skip to content

Commit

Permalink
Another round of rustfmt and imports cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
saivert committed May 9, 2024
1 parent 1e244b9 commit 3903a14
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 198 deletions.
6 changes: 3 additions & 3 deletions src/backend/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ use wp::{
};
use std::{str::FromStr, cell::RefCell};
use crate::{
backend::pwnodeobject::PwNodeObject,
backend::PwNodeObject,
ui::PwvucontrolWindowView,
backend::pwnodemodel::PwNodeModel,
backend::pwdeviceobject::PwDeviceObject,
backend::PwNodeModel,
backend::PwDeviceObject,
ui::PwvucontrolWindow,
PwvucontrolApplication,
backend::NodeType,
Expand Down
3 changes: 1 addition & 2 deletions src/backend/pwchannelobject.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// SPDX-License-Identifier: GPL-3.0-or-later

use crate::backend::pwnodeobject::PwNodeObject;
use crate::{backend::PwNodeObject, macros::*};
use std::cell::{Cell, RefCell};
use gtk::{
glib::{self, Properties, Value},
prelude::*,
subclass::prelude::*
};
use wireplumber as wp;
use crate::macros::*;

mod imp {
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion src/backend/pwdeviceobject.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later

use crate::backend::pwprofileobject::PwProfileObject;
use crate::backend::PwProfileObject;
use glib::{
self, clone,
subclass::{prelude::*, Signal},
Expand Down
2 changes: 1 addition & 1 deletion src/backend/pwnodemodel.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later

use crate::backend::pwnodeobject::PwNodeObject;
use crate::backend::PwNodeObject;
use gtk::{gio, glib, prelude::*, subclass::prelude::*};
use std::cell::RefCell;
use im_rc::Vector;
Expand Down
4 changes: 1 addition & 3 deletions src/ui/devicebox.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-or-later

use crate::backend::PwDeviceObject;
use crate::ui::PwProfileDropDown;
use crate::{backend::PwDeviceObject, ui::PwProfileDropDown};
use gtk::{prelude::*, subclass::prelude::*};
use std::cell::RefCell;


mod imp {
use super::*;

Expand Down
1 change: 0 additions & 1 deletion src/ui/levelprovider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::{fmt::Debug, time::Duration};
use glib::{self, clone, ControlFlow};
use pipewire::{properties, spa, stream::*, Context, Loop};
use std::os::fd::AsRawFd;

use crate::ui::PwVolumeBox;

pub struct LevelbarProvider {
Expand Down
33 changes: 11 additions & 22 deletions src/ui/outputbox.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
// SPDX-License-Identifier: GPL-3.0-or-later

use crate::{
backend::PwvucontrolManager,
backend::PwNodeObject,
ui::PwVolumeBox,
ui::PwVolumeBoxImpl,
ui::PwOutputDropDown,
backend::{PwNodeObject, PwvucontrolManager},
macros::*,
ui::{PwOutputDropDown, PwVolumeBox, PwVolumeBoxImpl},
};
use glib::{closure_local, clone};
use glib::{clone, closure_local};
use gtk::{prelude::*, subclass::prelude::*};
use wireplumber as wp;
use crate::macros::*;

use super::volumebox::PwVolumeBoxExt;

Expand All @@ -23,25 +20,24 @@ mod imp {
#[template_child]
pub output_dropdown: TemplateChild<PwOutputDropDown>,
}

#[glib::object_subclass]
impl ObjectSubclass for PwOutputBox {
const NAME: &'static str = "PwOutputBox";
type Type = super::PwOutputBox;
type ParentType = PwVolumeBox;

fn class_init(klass: &mut Self::Class) {
klass.bind_template();
}

fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
obj.init_template();
}
}

impl ObjectImpl for PwOutputBox {
fn constructed(&self) {

let manager = PwvucontrolManager::default();

let obj = self.obj();
Expand All @@ -53,7 +49,6 @@ mod imp {

self.parent_constructed();


if let Some(metadata) = manager.imp().metadata.borrow().as_ref() {
let boundid = item.boundid();
let widget = self.obj();
Expand All @@ -75,15 +70,12 @@ mod imp {
widget.obj().update_output_device_dropdown();
}));
}

}
impl WidgetImpl for PwOutputBox {}
impl ListBoxRowImpl for PwOutputBox {}
impl PwVolumeBoxImpl for PwOutputBox {}

impl PwOutputBox {

}
impl PwOutputBox {}
}

glib::wrapper! {
Expand All @@ -94,9 +86,7 @@ glib::wrapper! {

impl PwOutputBox {
pub(crate) fn new(node_object: &impl glib::IsA<PwNodeObject>) -> Self {
glib::Object::builder()
.property("node-object", node_object)
.build()
glib::Object::builder().property("node-object", node_object).build()
}

pub(crate) fn update_output_device_dropdown(&self) {
Expand Down Expand Up @@ -141,7 +131,7 @@ impl PwOutputBox {
deftarget.boundid(),
deftarget.serial()
);
output_dropdown.set_selected_no_send(pos+1);
output_dropdown.set_selected_no_send(pos + 1);
}
} else {
output_dropdown.set_selected_no_send(0);
Expand All @@ -163,5 +153,4 @@ impl PwOutputBox {
// }
}
}

}
41 changes: 19 additions & 22 deletions src/ui/profile_dropdown.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// SPDX-License-Identifier: GPL-3.0-or-later

use crate::backend::PwDeviceObject;
use crate::{
backend::{PwDeviceObject, PwProfileObject},
macros::*,
ui::PwProfileRow,
};
use glib::clone;
use glib::closure_local;
use gtk::{self, prelude::*, subclass::prelude::*};
use glib::clone;
use wp::pw::ProxyExt;
use std::cell::{Cell, RefCell};
use wireplumber as wp;
use crate::ui::PwProfileRow;
use crate::macros::*;
use wp::pw::ProxyExt;
mod imp {
use crate::backend::PwProfileObject;

use super::*;

#[derive(Debug, Default, gtk::CompositeTemplate, glib::Properties)]
Expand All @@ -25,7 +25,6 @@ mod imp {
pub profile_dropdown: TemplateChild<gtk::DropDown>,

pub(super) block_signal: Cell<bool>,

//pub(super) stringlist: RefCell<gtk::StringList>,
}

Expand Down Expand Up @@ -114,26 +113,27 @@ mod imp {

self.block_signal.set(false);

deviceobject.connect_local("pre-update-profile", false,
deviceobject.connect_local(
"pre-update-profile",
false,
clone!(@weak self as widget => @default-return None, move |_| {
widget.block_signal.set(true);

None
})
}),
);
deviceobject.connect_local("post-update-profile", false,
clone!(@weak self as widget => @default-return None, move |_| {
deviceobject.connect_local(
"post-update-profile",
false,
clone!(@weak self as widget => @default-return None, move |_| {
widget.block_signal.set(false);
widget.update_selected();

None
})
}),
);


deviceobject.connect_profile_index_notify(
clone!(@weak self as widget => move |_| widget.update_selected())
);
deviceobject.connect_profile_index_notify(clone!(@weak self as widget => move |_| widget.update_selected()));
} else {
self.profile_dropdown.set_model(gtk::gio::ListModel::NONE);
}
Expand All @@ -159,10 +159,7 @@ mod imp {

fn bind_handler(item: &glib::Object, dropdown: &gtk::DropDown) {
let item: &gtk::ListItem = item.downcast_ref().expect("ListItem");
let profilerow = item
.child()
.and_downcast::<PwProfileRow>()
.expect("PwProfileRow child");
let profilerow = item.child().and_downcast::<PwProfileRow>().expect("PwProfileRow child");

let signal = dropdown.connect_selected_item_notify(clone!(@weak item => move |dropdown| {
let profilerow = item
Expand Down Expand Up @@ -208,7 +205,7 @@ mod imp {

if let Some(deviceobject) = widget.deviceobject() {
pwvucontrol_critical!("Had set profile to {}", dropdown.selected());

deviceobject.set_profile(dropdown.selected() as i32);
}
});
Expand Down
1 change: 0 additions & 1 deletion src/ui/profilerow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use glib::closure_local;
use gtk::{prelude::*, subclass::prelude::*};
use std::cell::RefCell;

use crate::backend::ParamAvailability;

mod imp {
Expand Down
43 changes: 20 additions & 23 deletions src/ui/route_dropdown.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// SPDX-License-Identifier: GPL-3.0-or-later

use crate::{
backend::{NodeType, PwNodeObject, PwRouteFilterModel, PwRouteObject},
macros::*,
ui::PwProfileRow,
};
use glib::clone;
use glib::closure_local;
use gtk::{self, prelude::*, subclass::prelude::*};
use glib::clone;
use wp::pw::ProxyExt;
use std::cell::{Cell, RefCell};
use wireplumber as wp;
use crate::ui::PwProfileRow;
use crate::macros::*;
use wp::pw::ProxyExt;

mod imp {
use crate::backend::{NodeType, PwNodeObject, PwRouteFilterModel, PwRouteObject};

use super::*;

#[derive(Debug, Default, gtk::CompositeTemplate, glib::Properties)]
Expand Down Expand Up @@ -60,7 +61,7 @@ mod imp {
match nodeobject.nodetype() {
NodeType::Source => Some(deviceobject.route_index_input()),
NodeType::Sink => Some(deviceobject.route_index_output()),
_ => None
_ => None,
}
}

Expand All @@ -72,15 +73,14 @@ mod imp {
match nodeobject.nodetype() {
NodeType::Source => Some(deviceobject.routemodel_input()),
NodeType::Sink => Some(deviceobject.routemodel_output()),
_ => None
_ => None,
}
}

pub fn set_nodeobject(&self, new_nodeobject: Option<&PwNodeObject>) {
self.nodeobject.replace(new_nodeobject.cloned());

if let Some(nodeobject) = new_nodeobject {

let deviceobject = nodeobject.get_device().expect("device");

self.block_signal.set(true);
Expand All @@ -93,27 +93,29 @@ mod imp {

self.block_signal.set(false);

deviceobject.connect_local("pre-update-route", false,
deviceobject.connect_local(
"pre-update-route",
false,
clone!(@weak self as widget => @default-return None, move |_| {
widget.block_signal.set(true);

None
})
}),
);

deviceobject.connect_local("post-update-route", false,
clone!(@weak self as widget => @default-return None, move |_| {
deviceobject.connect_local(
"post-update-route",
false,
clone!(@weak self as widget => @default-return None, move |_| {
widget.block_signal.set(false);
pwvucontrol_info!("About to call widget.update_selected() inside post-update-route handler");
widget.update_selected();

None
})
}),
);

deviceobject.connect_route_index_output_notify(
clone!(@weak self as widget => move |_| widget.update_selected())
);
deviceobject.connect_route_index_output_notify(clone!(@weak self as widget => move |_| widget.update_selected()));
} else {
self.route_dropdown.set_model(gtk::gio::ListModel::NONE);
}
Expand All @@ -139,10 +141,7 @@ mod imp {

fn bind_handler(item: &glib::Object, dropdown: &gtk::DropDown) {
let item: &gtk::ListItem = item.downcast_ref().expect("ListItem");
let profilerow = item
.child()
.and_downcast::<PwProfileRow>()
.expect("PwProfileRow child");
let profilerow = item.child().and_downcast::<PwProfileRow>().expect("PwProfileRow child");

let signal = dropdown.connect_selected_item_notify(clone!(@weak item => move |dropdown| {
let profilerow = item
Expand Down Expand Up @@ -176,7 +175,6 @@ mod imp {
self.route_dropdown.set_factory(Some(&factory));
self.route_dropdown.set_list_factory(Some(&list_factory));


let widget = self.obj();
let selected_handler = closure_local!(
@watch widget => move |dropdown: &gtk::DropDown, _pspec: &glib::ParamSpec| {
Expand Down Expand Up @@ -206,7 +204,6 @@ glib::wrapper! {
}

impl PwRouteDropDown {

pub fn set_selected_no_send(&self, position: u32) {
let imp = self.imp();

Expand Down
Loading

0 comments on commit 3903a14

Please sign in to comment.