Merge pull request #59 from KnoyanMitsu/yorha

Added Power Menu on Settings
This commit is contained in:
flicko
2024-02-17 09:05:54 +05:30
committed by GitHub
2 changed files with 82 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
import { Widget, Variable } from "../imports.js";
import { NierButton } from "../nier/buttons.js";
import { button_label_2 ,settings_title_bottom, settings_title_top } from "../scaling.js";
import { assetsDir } from "../util.js";
const {Label} = Widget;
const {exec} = Utils;
export const PowerGroup = ({
go_to = async (buttons, parent_button) => {},
passAssetsDir = assetsDir
}) => {
return [
Label({ hpack: "start", label: "POWER", classNames: ["heading"], css:`margin-top: ${settings_title_top}px;margin-bottom: ${settings_title_bottom}px;` }),
NierButton({
useAssetsDir: passAssetsDir,
label: "Shutdown",
font_size: button_label_2,
// handleClick: async (self,event) => {
// go_to(
// [
// Label({ hpack: "start", label: "ARE YOU SURE?", classNames: ["heading"] ,css:`margin-top: ${settings_title_top}px;margin-bottom: ${settings_title_bottom}px;` }),
// NierButton({
// useAssetsDir: passAssetsDir,
// label: "YES",
// font_size: 30,
// vpack: "end",
// handleClick: () => {
// exec(
// `bash -c "poweroff"`
// )
// }
// }),
// NierButton({
// useAssetsDir: passAssetsDir,
// label: "NO",
// font_size: 30,
// vpack: "end",
// handleClick: () => {
// //
// }
// }),
// ],
// self
// );
// }
handleClick: () => {
exec(
`bash -c "poweroff"`
)
}
}),
NierButton({
useAssetsDir: passAssetsDir,
label: "Reboot",
font_size: button_label_2,
vpack: "end",
handleClick: () => {
exec(
`bash -c "reboot"`
)
}
}),
];
};

View File

@@ -8,6 +8,7 @@ import { Info } from "../../widgets/info.js";
import { VolumeGroup } from "../../widgets/volume_group.js";
import { WifiGroup } from "../../widgets/wifi_group.js";
import { AppLauncher } from "./applauncher.js";
import { PowerGroup } from "../../widgets/power_menu.js";
const { Window, Label, EventBox, Box, Overlay, Scrollable } = Widget;
@@ -40,6 +41,10 @@ const bluetooth_page = (
return BluetoothGroup({go_to,passAssetsDir:parentAssetsDir});
};
const power_page = (go_to = (button) => {}) => {
return PowerGroup({go_to,passAssetsDir:parentAssetsDir});
};
const ensure_only_selected = (button, page_button) => {
if (button == page_button) {
return button;
@@ -270,6 +275,16 @@ const NierSettingPane = (
);
},
}),
NierButton({
useAssetsDir: parentAssetsDir,
font_size: 30,
label: "POWER",
handleClick: async (self, event) => {
await go_page2(power_page(), self).catch((e) => {
console.log(e);
});
},
}),
Label({
css:`margin-top: ${settings_title_top}px;margin-bottom: ${settings_title_bottom}px;`,
hpack: "start",