[AGS] Fix Bluetooth menu
This commit is contained in:
parent
08347196f2
commit
dabb325436
@ -3,48 +3,21 @@ import { Gtk } from "astal/gtk4";
|
|||||||
import AstalBluetooth from "gi://AstalBluetooth";
|
import AstalBluetooth from "gi://AstalBluetooth";
|
||||||
import BTDevice from "./Device";
|
import BTDevice from "./Device";
|
||||||
const ALIGN = Gtk.Align;
|
const ALIGN = Gtk.Align;
|
||||||
const MAX_RETRY = 20;
|
|
||||||
|
|
||||||
const bt = AstalBluetooth.get_default();
|
const bt = AstalBluetooth.get_default();
|
||||||
|
|
||||||
// const LaunchBluetoothModule = () => {
|
|
||||||
// const box = new Gtk.Box();
|
|
||||||
//
|
|
||||||
// const placeholder = () => {
|
|
||||||
// return <button cssClasses={["toggle-button"]} child={
|
|
||||||
// <box>
|
|
||||||
// <label
|
|
||||||
// cssClasses={['title-2']}
|
|
||||||
// label={"Bluetooth"}></label>
|
|
||||||
// <label label={"Backend missing"}></label>
|
|
||||||
// </box>
|
|
||||||
// }>
|
|
||||||
// </button>
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (bt.adapter) {
|
|
||||||
// box.append(BluetoothModule());
|
|
||||||
// } else {
|
|
||||||
// const p = placeholder();
|
|
||||||
// box.append(p);
|
|
||||||
//
|
|
||||||
// let count = 0;
|
|
||||||
// const i = interval(1000, () => {
|
|
||||||
// if (bt.adapter !== null) {
|
|
||||||
// box.remove(p);
|
|
||||||
// box.append(BluetoothModule());
|
|
||||||
// i.cancel();
|
|
||||||
// } else if (count >= MAX_RETRY) {
|
|
||||||
// i.cancel();
|
|
||||||
// }
|
|
||||||
// count++;
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return box;
|
|
||||||
// }
|
|
||||||
|
|
||||||
const BluetoothModule = () => {
|
const BluetoothModule = () => {
|
||||||
|
const picker = BluetoothPicker();
|
||||||
|
|
||||||
|
const openBTPicker = () => {
|
||||||
|
try {
|
||||||
|
bt.adapter.start_discovery();
|
||||||
|
} catch (e) {
|
||||||
|
printerr(e);
|
||||||
|
}
|
||||||
|
picker.popup();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<box>
|
<box>
|
||||||
<button
|
<button
|
||||||
@ -106,13 +79,6 @@ const BluetoothModule = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const openBTPicker = () => {
|
|
||||||
picker.popup();
|
|
||||||
try {
|
|
||||||
bt.adapter.start_discovery();
|
|
||||||
} catch (_) { }
|
|
||||||
};
|
|
||||||
|
|
||||||
const BluetoothPickerList = () => {
|
const BluetoothPickerList = () => {
|
||||||
let btEnableState = false;
|
let btEnableState = false;
|
||||||
|
|
||||||
@ -240,13 +206,17 @@ const BluetoothPicker = () => {
|
|||||||
const popover = new Gtk.Popover();
|
const popover = new Gtk.Popover();
|
||||||
|
|
||||||
popover.set_child(BluetoothPickerList());
|
popover.set_child(BluetoothPickerList());
|
||||||
popover.connect("closed", () => bt.adapter.stop_discovery());
|
popover.connect("closed", () => {
|
||||||
|
try {
|
||||||
|
bt.adapter.stop_discovery();
|
||||||
|
} catch (e) {
|
||||||
|
printerr(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return popover;
|
return popover;
|
||||||
};
|
};
|
||||||
|
|
||||||
const picker = BluetoothPicker();
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
BluetoothModule,
|
BluetoothModule,
|
||||||
};
|
};
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#window {
|
#window {
|
||||||
background-color: @background;
|
background-color: @background;
|
||||||
border-color: @accent-two;
|
border-color: @accent;
|
||||||
border: 1px;
|
border: 1px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
@ -26,7 +26,7 @@ button:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
button:focus {
|
button:focus {
|
||||||
background-color: rgb(89, 22, 65);
|
background-color: rgb(151, 16, 58);
|
||||||
color: rgb(230, 230, 230);
|
color: rgb(230, 230, 230);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user