dev-2025-11-08T00:54:40+01:00

This commit is contained in:
Ada Baumann (she/her) 2025-11-08 00:54:40 +01:00
parent 97cb8ff476
commit 96e7390a2b
3 changed files with 39 additions and 10 deletions

4
run.sh
View File

@ -6,8 +6,8 @@ cd "$SRC_DIR" || exit
#export DESTDIR=~/.local #export DESTDIR=~/.local
#export PKGDATADIR=~/.local/share #export PKGDATADIR=~/.local/share
~/.local/bin/meson build || exit meson build || exit
sudo ~/.local/bin/meson install -C build || exit sudo meson install -C build || exit
RUST_BACKTRACE=1 audio-device-manager || exit RUST_BACKTRACE=1 audio-device-manager || exit
#git add . #git add .

View File

@ -42,7 +42,7 @@ enum Command {
} }
struct RegisteredObjects { struct RegisteredObjects {
profile_combo_rows: HashMap<uuid::Uuid, (usize, adw::ComboRow, gtk::StringList)> profile_combo_rows: HashMap<uuid::Uuid, (usize, adw::ComboRow, adw::gio::ListStore)>
} }
impl RegisteredObjects { impl RegisteredObjects {
@ -166,8 +166,11 @@ fn handle_profile_discovered(device_id: usize, registered_objects: Rc<RefCell<Re
let mut i = 0; let mut i = 0;
while let Some(p) = model.string(i) { while let Some(p) = model.item(i) {
match p.to_string().cmp(&profile_name) {
let label = p.downcast::<gtk::Label>().unwrap().label().to_string();
match label.cmp(&profile_name) {
Ordering::Less => {} Ordering::Less => {}
Ordering::Equal => return, Ordering::Equal => return,
Ordering::Greater => {break;} Ordering::Greater => {break;}
@ -175,7 +178,9 @@ fn handle_profile_discovered(device_id: usize, registered_objects: Rc<RefCell<Re
i += 1 i += 1
} }
model.splice(i, 0, &[&profile_name]); let profile_label = gtk::Label::new(Some(&profile_name));
model.splice(i, 0, &[profile_label]);
} }
} }
@ -193,7 +198,17 @@ fn handle_active_profile_set(device_id: usize, registered_objects: Rc<RefCell<Re
continue; continue;
} }
let i = model.find(&profile_name); let mut i = 0;
while let Some(p) = model.item(i) {
let label = p.downcast::<gtk::Label>().unwrap().label().to_string();
if label == profile_name {
break;
}
i += 1;
}
combo_row.set_selected(i); combo_row.set_selected(i);
@ -257,9 +272,18 @@ impl PipewireManager {
Some((id, self.devices.borrow()[&device_id].profiles[&id].description.clone())) Some((id, self.devices.borrow()[&device_id].profiles[&id].description.clone()))
}); });
let model = gtk::StringList::new(&[]);
let model = adw::gio::ListStore::new::<gtk::Label>();
//let model = gtk::StringList::new(&[]);
for name in &profile_names { for name in &profile_names {
model.append(name);
let label = gtk::Label::new(Some(name));
label.set_tooltip_text(Some(name));
model.append(&label);
} }
combo_row.set_model(Some(&model)); combo_row.set_model(Some(&model));
@ -273,7 +297,12 @@ impl PipewireManager {
self.tx, self.tx,
move |c| { move |c| {
let model_entry = c.selected(); let model_entry = c.selected();
let selected_profile_name = model.string(model_entry).unwrap().to_string(); let selected_profile_name = model
.item(model_entry)
.unwrap()
.downcast::<gtk::Label>()
.unwrap()
.label();
let mut selected_profile_id = None; let mut selected_profile_id = None;
for (profile_id, profile) in &devices.borrow()[&device_id].profiles { for (profile_id, profile) in &devices.borrow()[&device_id].profiles {

0
subprojects/.wraplock Normal file
View File