* validate profile image and create fallback * Update modules/menus/dashboard/profile/index.ts Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com> * Update modules/menus/dashboard/profile/index.ts Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com> * Update options.ts Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com> * Update modules/menus/dashboard/profile/index.ts Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com> * Update modules/menus/dashboard/profile/index.ts --------- Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>
89 lines
3.3 KiB
TypeScript
89 lines
3.3 KiB
TypeScript
import icons from "../../../icons/index.js";
|
|
import powermenu from "../../power/helpers/actions.js";
|
|
import { PowerOptions } from "lib/types/options.js";
|
|
import GdkPixbuf from "types/@girs/gdkpixbuf-2.0/gdkpixbuf-2.0.js";
|
|
|
|
import options from "options";
|
|
const { image, name } = options.menus.dashboard.powermenu.avatar;
|
|
|
|
const Profile = () => {
|
|
const handleClick = (action: PowerOptions) => {
|
|
App.closeWindow("dashboardmenu");
|
|
return powermenu.action(action);
|
|
};
|
|
|
|
return Widget.Box({
|
|
class_name: "profiles-container",
|
|
hpack: "fill",
|
|
hexpand: true,
|
|
children: [
|
|
Widget.Box({
|
|
class_name: "profile-picture-container dashboard-card",
|
|
hexpand: true,
|
|
vertical: true,
|
|
children: [
|
|
Widget.Icon({
|
|
hpack: "center",
|
|
class_name: "profile-picture",
|
|
icon: image.bind("value").as(i => {
|
|
try {
|
|
GdkPixbuf.Pixbuf.new_from_file(i);
|
|
return i;
|
|
} catch {
|
|
return "avatar-default-symbolic";
|
|
}
|
|
}),
|
|
}),
|
|
Widget.Label({
|
|
hpack: "center",
|
|
class_name: "profile-name",
|
|
label: name.bind("value").as((v) => {
|
|
if (v === "system") {
|
|
return Utils.exec("bash -c whoami");
|
|
}
|
|
return v;
|
|
}),
|
|
}),
|
|
],
|
|
}),
|
|
Widget.Box({
|
|
class_name: "power-menu-container dashboard-card",
|
|
vertical: true,
|
|
vexpand: true,
|
|
children: [
|
|
Widget.Button({
|
|
class_name: "dashboard-button shutdown",
|
|
on_clicked: () => handleClick("shutdown"),
|
|
tooltip_text: "Shut Down",
|
|
vexpand: true,
|
|
child: Widget.Icon(icons.powermenu.shutdown),
|
|
}),
|
|
Widget.Button({
|
|
class_name: "dashboard-button restart",
|
|
on_clicked: () => handleClick("reboot"),
|
|
tooltip_text: "Restart",
|
|
vexpand: true,
|
|
child: Widget.Icon(icons.powermenu.reboot),
|
|
}),
|
|
Widget.Button({
|
|
class_name: "dashboard-button lock",
|
|
on_clicked: () => handleClick("logout"),
|
|
tooltip_text: "Log Out",
|
|
vexpand: true,
|
|
child: Widget.Icon(icons.powermenu.logout),
|
|
}),
|
|
Widget.Button({
|
|
class_name: "dashboard-button sleep",
|
|
on_clicked: () => handleClick("sleep"),
|
|
tooltip_text: "Sleep",
|
|
vexpand: true,
|
|
child: Widget.Icon(icons.powermenu.sleep),
|
|
}),
|
|
],
|
|
}),
|
|
],
|
|
});
|
|
};
|
|
|
|
export { Profile };
|