Compare commits

..

No commits in common. "1f5a8f2c21af290aed9479c7ebae5cd6a234d70e" and "97cb8ff4768950f771ea6e83f2dc129592af55fa" have entirely different histories.

3 changed files with 10 additions and 85 deletions

4
run.sh
View File

@ -6,8 +6,8 @@ cd "$SRC_DIR" || exit
#export DESTDIR=~/.local
#export PKGDATADIR=~/.local/share
meson build || exit
sudo meson install -C build || exit
~/.local/bin/meson build || exit
sudo ~/.local/bin/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, adw::gio::ListStore)>
profile_combo_rows: HashMap<uuid::Uuid, (usize, adw::ComboRow, gtk::StringList)>
}
impl RegisteredObjects {
@ -166,11 +166,8 @@ fn handle_profile_discovered(device_id: usize, registered_objects: Rc<RefCell<Re
let mut i = 0;
while let Some(p) = model.item(i) {
let label = p.downcast::<gtk::Label>().unwrap().label().to_string();
match label.cmp(&profile_name) {
while let Some(p) = model.string(i) {
match p.to_string().cmp(&profile_name) {
Ordering::Less => {}
Ordering::Equal => return,
Ordering::Greater => {break;}
@ -178,9 +175,7 @@ fn handle_profile_discovered(device_id: usize, registered_objects: Rc<RefCell<Re
i += 1
}
let profile_label = gtk::Label::new(Some(&profile_name));
model.splice(i, 0, &[profile_label]);
model.splice(i, 0, &[&profile_name]);
}
}
@ -198,17 +193,7 @@ fn handle_active_profile_set(device_id: usize, registered_objects: Rc<RefCell<Re
continue;
}
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;
}
let i = model.find(&profile_name);
combo_row.set_selected(i);
@ -272,38 +257,9 @@ impl PipewireManager {
Some((id, self.devices.borrow()[&device_id].profiles[&id].description.clone()))
});
let factory = gtk::SignalListItemFactory::new();
factory.connect_setup(move |factory, item| {
let label = gtk::Label::new(None);
item.downcast_ref::<gtk::ListItem>()
.unwrap()
.set_child(Some(&label));
});
factory.connect_bind(move |factory, item| {
let list_item = item.downcast_ref::<gtk::ListItem>().unwrap();
let label = list_item.child().unwrap().downcast::<gtk::Label>().unwrap();
// using list_item.set_child( Some(&>label<) )
// instead of label.set_label( >label<.label() )
// results in weird broken behavior
label.set_label(&list_item.item().unwrap().downcast::<gtk::Label>().unwrap().label())
});
combo_row.set_factory(Some(&factory));
let model = adw::gio::ListStore::new::<gtk::Label>();
//let model = gtk::StringList::new(&[]);
let model = gtk::StringList::new(&[]);
for name in &profile_names {
let label = gtk::Label::new(Some(name));
label.set_tooltip_text(Some(name));
model.append(&label);
model.append(name);
}
combo_row.set_model(Some(&model));
@ -317,12 +273,7 @@ impl PipewireManager {
self.tx,
move |c| {
let model_entry = c.selected();
let selected_profile_name = model
.item(model_entry)
.unwrap()
.downcast::<gtk::Label>()
.unwrap()
.label();
let selected_profile_name = model.string(model_entry).unwrap().to_string();
let mut selected_profile_id = None;
for (profile_id, profile) in &devices.borrow()[&device_id].profiles {
@ -336,35 +287,9 @@ impl PipewireManager {
tx.send(
Command::DeviceCommand(device_id, DeviceCommand::SetProfile(selected_profile_id))
).unwrap();
println!("{}", &selected_profile_name);
}
));
/*
// works, TODO: figure out preferred style
combo_row.set_use_subtitle(true);
combo_row.connect_subtitle_notify(clone!(
#[weak]
model,
move |c| {
let model_entry = c.selected();
let selected_profile_name = model
.item(model_entry)
.unwrap()
.downcast::<gtk::Label>()
.unwrap()
.label();
c.set_subtitle(&selected_profile_name);
}
));
*/
if let Some((_, name)) = active_profile {
if let Ok(position) = profile_names.binary_search(&&name) {
combo_row.set_selected(position as u32)

View File