Skip to content

Commit

Permalink
Cleanup run, move imports to outer scope
Browse files Browse the repository at this point in the history
  • Loading branch information
saivert committed Dec 22, 2023
1 parent 8078730 commit 5949278
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 78 deletions.
3 changes: 1 addition & 2 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use gtk::{gio, glib, prelude::*, subclass::prelude::*};

use adw::subclass::prelude::*;

use once_cell::unsync::OnceCell;
use crate::{
config::{APP_ID, VERSION},
manager::PwvucontrolManager,
Expand All @@ -12,7 +12,6 @@ use crate::{

mod imp {
use super::*;
use once_cell::unsync::OnceCell;

pub struct PwvucontrolApplication {
pub(super) window: OnceCell<PwvucontrolWindow>,
Expand Down
5 changes: 2 additions & 3 deletions src/channelbox.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-or-later

use crate::pwchannelobject::PwChannelObject;
use std::cell::RefCell;
use gtk::{prelude::*, subclass::prelude::*};

mod imp {

use super::*;
use std::cell::RefCell;
use gtk::{prelude::*, subclass::prelude::*};

#[derive(Debug, Default, gtk::CompositeTemplate, glib::Properties)]
#[template(resource = "/com/saivert/pwvucontrol/gtk/channelbox.ui")]
Expand Down
30 changes: 17 additions & 13 deletions src/manager.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
// SPDX-License-Identifier: GPL-3.0-or-later

use gtk::{
use gtk::{
gio,
glib::{self, clone},
glib::{self, clone, Properties},
prelude::*,
subclass::prelude::*,
};

use wireplumber as wp;
use wp::{plugin::PluginFeatures, pw::MetadataExt, registry::{ObjectManager, Interest, Constraint, ConstraintType}};

use crate::{PwvucontrolWindow, PwvucontrolApplication};
use wp::{
plugin::{PluginFeatures, *},
pw::{MetadataExt, ProxyExt, PipewireObjectExt2},
registry::{ObjectManager, Interest, Constraint, ConstraintType}
};
use std::{str::FromStr, cell::RefCell};
use crate::{
pwnodeobject::PwNodeObject,
window::PwvucontrolWindowView,
pwnodemodel::PwNodeModel,
pwdeviceobject::PwDeviceObject,
PwvucontrolWindow,
PwvucontrolApplication
};
use once_cell::unsync::OnceCell;

mod imp {
use std::{str::FromStr, cell::RefCell};

use crate::{pwnodeobject::PwNodeObject, window::PwvucontrolWindowView, pwnodemodel::PwNodeModel, pwdeviceobject::PwDeviceObject};

use super::*;
use glib::Properties;
use once_cell::unsync::OnceCell;
use wp::{pw::{ProxyExt, PipewireObjectExt2}, plugin::*};

#[derive(Default, Properties)]
#[properties(wrapper_type = super::PwvucontrolManager)]
Expand Down
11 changes: 4 additions & 7 deletions src/profile_dropdown.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
// SPDX-License-Identifier: GPL-3.0-or-later

use crate::pwdeviceobject::PwDeviceObject;
use crate::{pwdeviceobject::PwDeviceObject, pwprofileobject::{PwProfileObject, ProfileAvailability}};
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;

mod imp {
use glib::clone;
use wp::pw::ProxyExt;

use crate::pwprofileobject::{PwProfileObject, ProfileAvailability};

use super::*;

#[derive(Debug, Default, gtk::CompositeTemplate, glib::Properties)]
Expand All @@ -26,7 +23,7 @@ mod imp {

pub(super) block_signal: Cell<bool>,

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

#[glib::object_subclass]
Expand Down
3 changes: 0 additions & 3 deletions src/pwchannelobject.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-3.0-or-later

use crate::pwnodeobject::PwNodeObject;

use std::cell::{Cell, RefCell};

use gtk::{
glib::{self, Properties, Value},
prelude::*,
subclass::prelude::*
};

use wireplumber as wp;

mod imp {
Expand Down
32 changes: 6 additions & 26 deletions src/pwdeviceobject.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
// SPDX-License-Identifier: GPL-3.0-or-later

use glib::{self, clone, subclass::prelude::*, Object, ObjectExt};

use gtk::{gio, prelude::ListModelExt};
use crate::pwprofileobject::PwProfileObject;
use glib::{self, clone, subclass::{prelude::*, Signal}, Object, ObjectExt, ParamSpec, Properties, Value};
use gtk::{gio, prelude::*, subclass::prelude::*};
use wireplumber as wp;
use wp::{
pw::{PipewireObjectExt, PipewireObjectExt2},
spa::SpaPodBuilder,
};

use crate::pwprofileobject::PwProfileObject;
use im_rc::Vector;
use once_cell::sync::{OnceCell, Lazy};
use std::cell::{Cell, RefCell};

pub mod imp {
use super::*;

use glib::{ParamSpec, Properties, Value, subclass::Signal};
use gtk::{gio, glib, prelude::*, subclass::prelude::*};
use im_rc::Vector;
use once_cell::sync::{OnceCell, Lazy};
use std::cell::{Cell, RefCell};

#[derive(Default, Properties)]
#[properties(wrapper_type = super::PwDeviceObject)]
pub struct PwDeviceObject {
Expand Down Expand Up @@ -242,19 +237,4 @@ impl PwDeviceObject {
fn update_icon_name(&self) {
self.set_iconname("soundcard-symbolic");
}

// pub(crate) fn serial(&self) -> u32 {
// let serial: i32 = self
// .wpdevice()
// .pw_property("object.serial")
// .expect("object.serial");

// serial as u32
// }

// pub(crate) fn device_property<T: FromPipewirePropertyString>(&self, property: &str) -> T {
// self.wpdevice()
// .pw_property(property)
// .expect("object.serial")
// }
}
7 changes: 2 additions & 5 deletions src/pwnodemodel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

use crate::pwnodeobject::PwNodeObject;
use gtk::{gio, glib, prelude::*, subclass::prelude::*};
use std::cell::RefCell;
use im_rc::Vector;

mod imp {
use super::*;

use std::cell::RefCell;

// Use `im-rc::Vector` here as it has much better insert/delete performance than a plain `Vec`.
use im_rc::Vector;

#[derive(Debug, Default)]
pub struct PwNodeModel(pub(super) RefCell<Vector<PwNodeObject>>);
Expand Down
17 changes: 4 additions & 13 deletions src/pwnodeobject.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// SPDX-License-Identifier: GPL-3.0-or-later

use glib::{self, clone, subclass::prelude::*, Object, ObjectExt};

use wireplumber as wp;
use wp::{pw::{GlobalProxyExt, PipewireObjectExt, PipewireObjectExt2, ProxyExt, MetadataExt, FromPipewirePropertyString}, spa::SpaPodBuilder, registry::{Constraint, ConstraintType, Interest}};

use std::cell::{Cell, RefCell};
use glib::{self, clone, subclass::{prelude::*, Signal}, Object, ObjectExt, ParamSpec, Properties, Value};
use once_cell::sync::{Lazy, OnceCell};
use crate::{NodeType, application::PwvucontrolApplication};

mod mixerapi;

#[derive(Copy, Clone, Debug)]
pub struct AudioFormat {
pub channels: i32,
Expand All @@ -25,16 +26,6 @@ pub(crate) enum PropertyChanged {
pub mod imp {
use super::*;

use std::cell::{Cell, RefCell};
use glib::{
ParamSpec,
Properties,
Value,
subclass::Signal,
};
use once_cell::sync::{Lazy, OnceCell};

// Object holding the state
#[derive(Default, Properties)]
#[properties(wrapper_type = super::PwNodeObject)]
pub struct PwNodeObject {
Expand Down
5 changes: 1 addition & 4 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use gtk::{
};
use glib::clone;
use adw::subclass::prelude::*;

use crate::{pwdeviceobject::PwDeviceObject, devicebox::PwDeviceBox};
use crate::{
application::PwvucontrolApplication,
volumebox::PwVolumeBox,
Expand All @@ -16,16 +16,13 @@ use crate::{
outputbox::PwOutputBox,
config::{APP_ID, PROFILE}
};

use wireplumber as wp;

pub(crate) enum PwvucontrolWindowView {
Connected,
Disconnected
}
mod imp {
use crate::{pwdeviceobject::PwDeviceObject, devicebox::PwDeviceBox};

use super::*;

#[derive(Debug, gtk::CompositeTemplate)]
Expand Down
3 changes: 1 addition & 2 deletions src/withdefaultlistmodel.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-or-later

use crate::pwnodemodel::PwNodeModel;
use glib::{Properties, closure_local};
use gtk::{gio, glib, prelude::*, subclass::prelude::*};
use std::cell::RefCell;

mod imp {
use glib::{Properties, closure_local};

use super::*;

#[derive(Debug, Default, Properties)]
Expand Down

0 comments on commit 5949278

Please sign in to comment.