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 PKGDATADIR=~/.local/share
~/.local/bin/meson build || exit
sudo ~/.local/bin/meson install -C build || exit
meson build || exit
sudo meson install -C build || exit
RUST_BACKTRACE=1 audio-device-manager || exit
#git add .

View File

@ -42,7 +42,7 @@ enum Command {
}
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 {
@ -166,8 +166,11 @@ fn handle_profile_discovered(device_id: usize, registered_objects: Rc<RefCell<Re
let mut i = 0;
while let Some(p) = model.string(i) {
match p.to_string().cmp(&profile_name) {
while let Some(p) = model.item(i) {
let label = p.downcast::<gtk::Label>().unwrap().label().to_string();
match label.cmp(&profile_name) {
Ordering::Less => {}
Ordering::Equal => return,
Ordering::Greater => {break;}
@ -175,7 +178,9 @@ fn handle_profile_discovered(device_id: usize, registered_objects: Rc<RefCell<Re
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;
}
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);
@ -257,9 +272,18 @@ impl PipewireManager {
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 {
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));
@ -273,7 +297,12 @@ impl PipewireManager {
self.tx,
move |c| {
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;
for (profile_id, profile) in &devices.borrow()[&device_id].profiles {

0
subprojects/.wraplock Normal file
View File