nixos-configs/modules/ags/config/ts/applauncher/app-item.ts

64 lines
1.3 KiB
TypeScript
Raw Normal View History

const { Box, Icon, Label } = Widget;
const { lookUpIcon } = Utils;
import CursorBox from '../misc/cursorbox.ts';
/* Types */
import { Application } from 'types/service/applications.ts';
2024-01-13 11:15:08 -05:00
export default (app: Application) => {
2023-12-18 18:00:30 -05:00
const icon = Icon({ size: 42 });
const iconString = app.app.get_string('Icon');
if (app.icon_name) {
if (lookUpIcon(app.icon_name)) {
icon.icon = app.icon_name;
}
else if (iconString && iconString !== 'nix-snowflake') {
icon.icon = iconString;
}
else {
icon.icon = '';
}
}
const textBox = Box({
vertical: true,
vpack: 'start',
children: [
Label({
class_name: 'title',
label: app.name,
xalign: 0,
truncate: 'end',
}),
Label({
class_name: 'description',
label: app.description || '',
wrap: true,
xalign: 0,
justification: 'left',
}),
Label(),
],
});
return CursorBox({
2023-12-07 01:18:47 -05:00
hexpand: true,
class_name: 'app',
2023-12-18 18:00:30 -05:00
attribute: { app },
child: Box({
children: [
icon,
textBox,
],
}),
});
};