2023-11-13 15:19:49 -05:00
|
|
|
import App from 'resource:///com/github/Aylur/ags/app.js';
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-09 12:12:43 -05:00
|
|
|
import { Box, Icon, Label } from 'resource:///com/github/Aylur/ags/widget.js';
|
2023-11-13 15:19:49 -05:00
|
|
|
import { lookUpIcon } from 'resource:///com/github/Aylur/ags/utils.js';
|
|
|
|
|
2023-12-18 23:20:32 -05:00
|
|
|
import CursorBox from '../misc/cursorbox.js';
|
2023-11-13 15:19:49 -05:00
|
|
|
|
2024-01-13 11:15:08 -05:00
|
|
|
// Types
|
|
|
|
import { Application } from 'types/service/applications.js';
|
2023-11-13 15:19:49 -05:00
|
|
|
|
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 = '';
|
|
|
|
}
|
|
|
|
}
|
2023-11-13 15:19:49 -05:00
|
|
|
|
2023-12-09 12:12:43 -05:00
|
|
|
const textBox = Box({
|
2023-11-13 15:19:49 -05:00
|
|
|
vertical: true,
|
2023-12-09 12:12:43 -05:00
|
|
|
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(),
|
|
|
|
],
|
2023-11-13 15:19:49 -05:00
|
|
|
});
|
|
|
|
|
2023-12-18 23:20:32 -05:00
|
|
|
return CursorBox({
|
2023-12-07 01:18:47 -05:00
|
|
|
hexpand: true,
|
2023-11-13 15:19:49 -05:00
|
|
|
class_name: 'app',
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-18 18:00:30 -05:00
|
|
|
attribute: { app },
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-20 14:28:56 -05:00
|
|
|
on_primary_click_release: () => {
|
2023-11-13 15:19:49 -05:00
|
|
|
App.closeWindow('applauncher');
|
2023-12-20 14:28:56 -05:00
|
|
|
app.launch();
|
2023-11-13 15:19:49 -05:00
|
|
|
},
|
2023-11-21 01:29:46 -05:00
|
|
|
|
|
|
|
child: Box({
|
|
|
|
children: [
|
|
|
|
icon,
|
|
|
|
textBox,
|
|
|
|
],
|
2023-11-13 15:19:49 -05:00
|
|
|
}),
|
|
|
|
});
|
|
|
|
};
|