2024-01-30 11:29:07 -05:00
|
|
|
const { Box, Calendar, Label } = Widget;
|
2023-10-02 12:06:35 -04:00
|
|
|
|
2024-01-22 10:23:32 -05:00
|
|
|
const { new_now_local } = imports.gi.GLib.DateTime;
|
2023-09-11 21:10:00 -04:00
|
|
|
|
2024-01-13 23:38:31 -05:00
|
|
|
import PopupWindow from './misc/popup.ts';
|
2023-09-21 20:01:14 -04:00
|
|
|
|
2023-10-02 12:06:35 -04:00
|
|
|
|
2023-09-11 21:10:00 -04:00
|
|
|
const Divider = () => Box({
|
2023-12-18 18:00:30 -05:00
|
|
|
class_name: 'divider',
|
2023-10-20 23:11:21 -04:00
|
|
|
vertical: true,
|
2023-09-11 21:10:00 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
const Time = () => Box({
|
2023-12-18 18:00:30 -05:00
|
|
|
class_name: 'timebox',
|
2023-10-20 23:11:21 -04:00
|
|
|
vertical: true,
|
2023-09-11 21:10:00 -04:00
|
|
|
|
2023-12-18 18:00:30 -05:00
|
|
|
children: [
|
2023-10-20 23:11:21 -04:00
|
|
|
Box({
|
2023-12-18 18:00:30 -05:00
|
|
|
class_name: 'time-container',
|
2023-11-06 18:37:23 -05:00
|
|
|
hpack: 'center',
|
|
|
|
vpack: 'center',
|
2023-09-11 21:10:00 -04:00
|
|
|
|
2023-12-18 18:00:30 -05:00
|
|
|
children: [
|
2023-10-20 23:11:21 -04:00
|
|
|
Label({
|
2023-12-18 18:00:30 -05:00
|
|
|
class_name: 'content',
|
2023-10-20 23:11:21 -04:00
|
|
|
label: 'hour',
|
2023-12-17 00:01:58 -05:00
|
|
|
setup: (self) => {
|
|
|
|
self.poll(1000, () => {
|
2024-01-22 10:23:32 -05:00
|
|
|
self.label = new_now_local().format('%H') || '';
|
2023-12-17 00:01:58 -05:00
|
|
|
});
|
|
|
|
},
|
2023-10-20 23:11:21 -04:00
|
|
|
}),
|
2023-09-11 21:10:00 -04:00
|
|
|
|
2023-10-20 23:11:21 -04:00
|
|
|
Divider(),
|
2023-09-11 21:10:00 -04:00
|
|
|
|
2023-10-20 23:11:21 -04:00
|
|
|
Label({
|
2023-12-18 18:00:30 -05:00
|
|
|
class_name: 'content',
|
2023-10-20 23:11:21 -04:00
|
|
|
label: 'minute',
|
2023-12-17 00:01:58 -05:00
|
|
|
setup: (self) => {
|
|
|
|
self.poll(1000, () => {
|
2024-01-22 10:23:32 -05:00
|
|
|
self.label = new_now_local().format('%M') || '';
|
2023-12-17 00:01:58 -05:00
|
|
|
});
|
|
|
|
},
|
2023-10-20 23:11:21 -04:00
|
|
|
}),
|
2023-09-11 21:10:00 -04:00
|
|
|
|
2023-10-20 23:11:21 -04:00
|
|
|
],
|
|
|
|
}),
|
2023-09-11 21:10:00 -04:00
|
|
|
|
2023-10-20 23:11:21 -04:00
|
|
|
Box({
|
2023-12-18 18:00:30 -05:00
|
|
|
class_name: 'date-container',
|
2023-11-06 18:37:23 -05:00
|
|
|
hpack: 'center',
|
2023-12-18 18:00:30 -05:00
|
|
|
|
2023-10-20 23:11:21 -04:00
|
|
|
child: Label({
|
2023-11-06 18:37:23 -05:00
|
|
|
css: 'font-size: 20px',
|
2023-10-20 23:11:21 -04:00
|
|
|
label: 'complete date',
|
2023-12-18 18:00:30 -05:00
|
|
|
|
2023-12-17 00:01:58 -05:00
|
|
|
setup: (self) => {
|
|
|
|
self.poll(1000, () => {
|
2024-01-22 10:23:32 -05:00
|
|
|
const time = new_now_local();
|
2023-12-17 00:01:58 -05:00
|
|
|
|
2024-01-22 10:23:32 -05:00
|
|
|
const dayNameMonth = time.format('%A, %B ');
|
|
|
|
const dayNum = time.get_day_of_month();
|
|
|
|
const date = time.format(', %Y');
|
|
|
|
|
|
|
|
if (dayNum && dayNameMonth && date) {
|
|
|
|
self.label = dayNameMonth + dayNum + date;
|
|
|
|
}
|
2023-12-17 00:01:58 -05:00
|
|
|
});
|
|
|
|
},
|
2023-10-20 23:11:21 -04:00
|
|
|
}),
|
|
|
|
}),
|
2023-09-11 21:10:00 -04:00
|
|
|
|
2023-10-20 23:11:21 -04:00
|
|
|
],
|
2023-09-11 21:10:00 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
const CalendarWidget = () => Box({
|
2023-12-18 18:00:30 -05:00
|
|
|
class_name: 'cal-box',
|
|
|
|
|
2023-11-06 18:37:23 -05:00
|
|
|
child: Calendar({
|
2023-12-18 18:00:30 -05:00
|
|
|
show_day_names: true,
|
|
|
|
show_heading: true,
|
|
|
|
class_name: 'cal',
|
2023-10-20 23:11:21 -04:00
|
|
|
}),
|
2023-09-11 21:10:00 -04:00
|
|
|
});
|
|
|
|
|
2023-11-21 01:29:46 -05:00
|
|
|
const TOP_MARGIN = 6;
|
|
|
|
|
2023-10-16 18:11:19 -04:00
|
|
|
export default () => PopupWindow({
|
2023-12-18 18:00:30 -05:00
|
|
|
name: 'calendar',
|
2023-12-05 11:35:40 -05:00
|
|
|
anchor: ['top'],
|
|
|
|
margins: [TOP_MARGIN, 0, 0, 0],
|
2023-12-18 18:00:30 -05:00
|
|
|
|
2024-04-10 21:04:19 -04:00
|
|
|
child: Box({
|
2023-12-18 18:00:30 -05:00
|
|
|
class_name: 'date',
|
2023-10-20 23:11:21 -04:00
|
|
|
vertical: true,
|
2023-12-18 18:00:30 -05:00
|
|
|
|
2023-10-20 23:11:21 -04:00
|
|
|
children: [
|
|
|
|
Time(),
|
|
|
|
CalendarWidget(),
|
|
|
|
],
|
|
|
|
}),
|
2023-09-11 21:10:00 -04:00
|
|
|
});
|