Compare commits
No commits in common. "1f5a8f2c21af290aed9479c7ebae5cd6a234d70e" and "97cb8ff4768950f771ea6e83f2dc129592af55fa" have entirely different histories.
1f5a8f2c21
...
97cb8ff476
4
run.sh
4
run.sh
@ -6,8 +6,8 @@ cd "$SRC_DIR" || exit
|
|||||||
#export DESTDIR=~/.local
|
#export DESTDIR=~/.local
|
||||||
#export PKGDATADIR=~/.local/share
|
#export PKGDATADIR=~/.local/share
|
||||||
|
|
||||||
meson build || exit
|
~/.local/bin/meson build || exit
|
||||||
sudo meson install -C build || exit
|
sudo ~/.local/bin/meson install -C build || exit
|
||||||
RUST_BACKTRACE=1 audio-device-manager || exit
|
RUST_BACKTRACE=1 audio-device-manager || exit
|
||||||
|
|
||||||
#git add .
|
#git add .
|
||||||
|
|||||||
@ -42,7 +42,7 @@ enum Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct RegisteredObjects {
|
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 {
|
impl RegisteredObjects {
|
||||||
@ -166,11 +166,8 @@ 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.item(i) {
|
while let Some(p) = model.string(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;}
|
||||||
@ -178,9 +175,7 @@ fn handle_profile_discovered(device_id: usize, registered_objects: Rc<RefCell<Re
|
|||||||
i += 1
|
i += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
let profile_label = gtk::Label::new(Some(&profile_name));
|
model.splice(i, 0, &[&profile_name]);
|
||||||
|
|
||||||
model.splice(i, 0, &[profile_label]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,17 +193,7 @@ fn handle_active_profile_set(device_id: usize, registered_objects: Rc<RefCell<Re
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut i = 0;
|
let i = model.find(&profile_name);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@ -272,38 +257,9 @@ 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 factory = gtk::SignalListItemFactory::new();
|
let model = gtk::StringList::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(&[]);
|
|
||||||
|
|
||||||
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));
|
||||||
@ -317,12 +273,7 @@ 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
|
let selected_profile_name = model.string(model_entry).unwrap().to_string();
|
||||||
.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 {
|
||||||
@ -336,35 +287,9 @@ impl PipewireManager {
|
|||||||
tx.send(
|
tx.send(
|
||||||
Command::DeviceCommand(device_id, DeviceCommand::SetProfile(selected_profile_id))
|
Command::DeviceCommand(device_id, DeviceCommand::SetProfile(selected_profile_id))
|
||||||
).unwrap();
|
).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 Some((_, name)) = active_profile {
|
||||||
if let Ok(position) = profile_names.binary_search(&&name) {
|
if let Ok(position) = profile_names.binary_search(&&name) {
|
||||||
combo_row.set_selected(position as u32)
|
combo_row.set_selected(position as u32)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user