chore: make all snake_case

This commit is contained in:
Fabio Lenherr / DashieTM 2023-12-05 16:15:24 +01:00
parent 391182607d
commit d50ee65bdd
52 changed files with 766 additions and 783 deletions

View file

@ -45,26 +45,26 @@ fn setup_callbacks(
let bluetooth_box_ref = bluetooth_box.clone();
let imp = bluetooth_box.imp();
// let bluetooth_box_ref = bluetooth_box.clone();
imp.resetVisibility.set_activatable(true);
imp.resetVisibility.set_action_name(Some("navigation.push"));
imp.resetVisibility
imp.reset_visibility.set_activatable(true);
imp.reset_visibility.set_action_name(Some("navigation.push"));
imp.reset_visibility
.set_action_target_value(Some(&Variant::from("visibility")));
imp.resetBluetoothMainTab
imp.reset_bluetooth_main_tab
.set_action_name(Some("navigation.pop"));
// TODO add a manual search button here
imp.resetBluetoothSwitch.connect_state_set(move |_, state| {
imp.reset_bluetooth_switch.connect_state_set(move |_, state| {
if !state {
let imp = bluetooth_box_ref.imp();
for x in imp
.resetBluetoothConnectedDevices
.reset_bluetooth_connected_devices
.observe_children()
.iter::<Object>()
.flatten()
{
// todo test this
if let Some(item) = x.downcast_ref::<Widget>() {
imp.resetBluetoothAvailableDevices.remove(item);
imp.reset_bluetooth_available_devices.remove(item);
}
}
listeners.bluetooth_listener.store(false, Ordering::SeqCst);
@ -108,13 +108,13 @@ pub fn populate_conntected_bluetooth_devices(bluetooth_box: Arc<BluetoothBox>) {
let imp = ref_box.imp();
let list = imp.reset_model_list.read().unwrap();
imp.resetBluetoothAdapter.set_model(Some(&*list));
imp.reset_bluetooth_adapter.set_model(Some(&*list));
let map = imp.reset_bluetooth_adapters.read().unwrap();
let device = imp.reset_current_bluetooth_adapter.borrow();
if let Some(index) = map.get(&device.alias) {
imp.resetBluetoothAdapter.set_selected(index.1);
imp.reset_bluetooth_adapter.set_selected(index.1);
}
imp.resetBluetoothAdapter.connect_selected_notify(
imp.reset_bluetooth_adapter.connect_selected_notify(
clone!(@weak imp => move |dropdown| {
let selected = dropdown.selected_item();
if selected.is_none() {
@ -142,9 +142,9 @@ pub fn populate_conntected_bluetooth_devices(bluetooth_box: Arc<BluetoothBox>) {
.borrow_mut()
.insert(path, (bluetooth_entry.clone(), entry.clone(), device));
if connected {
imp.resetBluetoothConnectedDevices.append(&*entry);
imp.reset_bluetooth_connected_devices.append(&*entry);
} else {
imp.resetBluetoothAvailableDevices.append(&*entry);
imp.reset_bluetooth_available_devices.append(&*entry);
}
}
});
@ -207,9 +207,9 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
(bluetooth_entry.clone(), entry.clone(), ir.bluetooth_device),
);
if connected {
imp.resetBluetoothConnectedDevices.append(&*entry);
imp.reset_bluetooth_connected_devices.append(&*entry);
} else {
imp.resetBluetoothAvailableDevices.append(&*entry);
imp.reset_bluetooth_available_devices.append(&*entry);
}
});
});
@ -228,7 +228,7 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
let imp = bluetooth_box.imp();
let map = imp.available_devices.borrow_mut();
if let Some(list_entry) = map.get(&ir.bluetooth_device) {
imp.resetBluetoothConnectedDevices.remove(&*list_entry.1);
imp.reset_bluetooth_connected_devices.remove(&*list_entry.1);
}
});
});
@ -249,18 +249,18 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
if let Some(list_entry) = map.get(&ir.bluetooth_device.path) {
if list_entry.2.connected != ir.bluetooth_device.connected {
if ir.bluetooth_device.connected {
imp.resetBluetoothConnectedDevices.append(&*list_entry.1);
imp.resetBluetoothAvailableDevices.remove(&*list_entry.1);
imp.reset_bluetooth_connected_devices.append(&*list_entry.1);
imp.reset_bluetooth_available_devices.remove(&*list_entry.1);
} else {
imp.resetBluetoothAvailableDevices.append(&*list_entry.1);
imp.resetBluetoothConnectedDevices.remove(&*list_entry.1);
imp.reset_bluetooth_available_devices.append(&*list_entry.1);
imp.reset_bluetooth_connected_devices.remove(&*list_entry.1);
}
}
if list_entry.2.paired != ir.bluetooth_device.paired {
if ir.bluetooth_device.paired {
list_entry.0.imp().resetBluetoothButton.set_sensitive(true);
list_entry.0.imp().reset_bluetooth_button.set_sensitive(true);
} else {
list_entry.0.imp().resetBluetoothButton.set_sensitive(false);
list_entry.0.imp().reset_bluetooth_button.set_sensitive(false);
}
}
}
@ -285,13 +285,13 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
glib::idle_add_once(move || {
let imp = loop_box.imp();
for x in imp
.resetBluetoothAvailableDevices
.reset_bluetooth_available_devices
.observe_children()
.iter::<Object>()
.flatten()
{
if let Some(item) = x.downcast_ref::<Widget>() {
imp.resetBluetoothAvailableDevices.remove(item);
imp.reset_bluetooth_available_devices.remove(item);
}
}
});

View file

@ -15,24 +15,23 @@ use crate::components::bluetooth::bluetooth_entry::BluetoothEntry;
type BluetoothMap =
RefCell<HashMap<Path<'static>, (Arc<BluetoothEntry>, Arc<ListEntry>, BluetoothDevice)>>;
#[allow(non_snake_case)]
#[derive(Default, CompositeTemplate)]
#[template(resource = "/org/Xetibo/ReSet/resetBluetooth.ui")]
pub struct BluetoothBox {
#[template_child]
pub resetBluetoothSwitch: TemplateChild<Switch>,
pub reset_bluetooth_switch: TemplateChild<Switch>,
#[template_child]
pub resetBluetoothAvailableDevices: TemplateChild<gtk::Box>,
pub reset_bluetooth_available_devices: TemplateChild<gtk::Box>,
#[template_child]
pub resetBluetoothRefreshButton: TemplateChild<Button>,
pub reset_bluetooth_refresh_button: TemplateChild<Button>,
#[template_child]
pub resetBluetoothAdapter: TemplateChild<ComboRow>,
pub reset_bluetooth_adapter: TemplateChild<ComboRow>,
#[template_child]
pub resetBluetoothConnectedDevices: TemplateChild<gtk::Box>,
pub reset_bluetooth_connected_devices: TemplateChild<gtk::Box>,
#[template_child]
pub resetVisibility: TemplateChild<ActionRow>,
pub reset_visibility: TemplateChild<ActionRow>,
#[template_child]
pub resetBluetoothMainTab: TemplateChild<ListEntry>,
pub reset_bluetooth_main_tab: TemplateChild<ListEntry>,
pub available_devices: BluetoothMap,
pub connected_devices: BluetoothMap,
pub reset_bluetooth_adapters: Arc<RwLock<HashMap<String, (BluetoothAdapter, u32)>>>,

View file

@ -24,27 +24,27 @@ impl BluetoothEntry {
pub fn new(device: &BluetoothDevice) -> Self {
let entry: BluetoothEntry = Object::builder().build();
let entry_imp = entry.imp();
entry_imp.resetBluetoothLabel.get().set_text(&device.alias);
entry_imp.reset_bluetooth_label.get().set_text(&device.alias);
entry_imp
.resetBluetoothAddress
.reset_bluetooth_address
.get()
.set_text(&device.address);
if device.icon.is_empty() {
entry_imp
.resetBluetoothDeviceType
.reset_bluetooth_device_type
.set_icon_name(Some("dialog-question-symbolic"));
} else {
entry_imp
.resetBluetoothDeviceType
.reset_bluetooth_device_type
.set_icon_name(Some(&device.icon));
}
if device.paired {
entry_imp.resetBluetoothButton.set_sensitive(true);
entry_imp.reset_bluetooth_button.set_sensitive(true);
} else {
entry_imp.resetBluetoothButton.set_sensitive(false);
entry_imp.reset_bluetooth_button.set_sensitive(false);
}
let path = Arc::new(device.path.clone());
entry_imp.resetBluetoothButton.connect_clicked(move |_| {
entry_imp.reset_bluetooth_button.connect_clicked(move |_| {
remove_device_pairing((*path).clone());
});
let gesture = GestureClick::new();

View file

@ -3,18 +3,17 @@ use gtk::subclass::prelude::*;
use gtk::{glib, Button, CompositeTemplate, Image, Label};
use std::cell::RefCell;
#[allow(non_snake_case)]
#[derive(Default, CompositeTemplate)]
#[template(resource = "/org/Xetibo/ReSet/resetBluetoothEntry.ui")]
pub struct BluetoothEntry {
#[template_child]
pub resetBluetoothDeviceType: TemplateChild<Image>,
pub reset_bluetooth_device_type: TemplateChild<Image>,
#[template_child]
pub resetBluetoothLabel: TemplateChild<Label>,
pub reset_bluetooth_label: TemplateChild<Label>,
#[template_child]
pub resetBluetoothAddress: TemplateChild<Label>,
pub reset_bluetooth_address: TemplateChild<Label>,
#[template_child]
pub resetBluetoothButton: TemplateChild<Button>,
pub reset_bluetooth_button: TemplateChild<Button>,
pub device_name: RefCell<String>,
}