2023-09-05 19:22:54 -04:00
|
|
|
const { Box, Label } = ags.Widget;
|
2023-09-12 14:07:20 -04:00
|
|
|
const { toggleWindow, openWindow } = ags.App;
|
2023-09-05 19:22:54 -04:00
|
|
|
const { DateTime } = imports.gi.GLib;
|
|
|
|
|
2023-09-11 21:10:00 -04:00
|
|
|
import { EventBox } from '../misc/cursorbox.js';
|
2023-09-13 19:04:23 -04:00
|
|
|
import { closeAll } from '../misc/closer.js';
|
2023-09-11 21:10:00 -04:00
|
|
|
|
2023-09-05 19:22:54 -04:00
|
|
|
const ClockModule = ({
|
|
|
|
interval = 1000,
|
2023-09-10 23:24:58 -04:00
|
|
|
...params
|
2023-09-05 19:22:54 -04:00
|
|
|
}) => Label({
|
2023-09-10 23:24:58 -04:00
|
|
|
...params,
|
2023-09-05 19:22:54 -04:00
|
|
|
className: 'clock',
|
2023-09-05 19:57:34 -04:00
|
|
|
connections: [
|
|
|
|
[interval, label => {
|
|
|
|
var time = DateTime.new_now_local();
|
|
|
|
label.label = time.format('%a. ') + time.get_day_of_month() + time.format(' %b. %H:%M');
|
|
|
|
}],
|
|
|
|
],
|
2023-09-05 19:22:54 -04:00
|
|
|
});
|
|
|
|
|
2023-09-11 21:10:00 -04:00
|
|
|
export const Clock = EventBox({
|
2023-09-05 19:22:54 -04:00
|
|
|
className: 'toggle-off',
|
2023-09-12 09:37:48 -04:00
|
|
|
onPrimaryClickRelease: () => toggleWindow('calendar'),
|
|
|
|
connections: [
|
|
|
|
[ags.App, (box, windowName, visible) => {
|
|
|
|
if (windowName == 'calendar') {
|
2023-09-12 14:07:20 -04:00
|
|
|
if (visible) {
|
|
|
|
Clock.toggleClassName('toggle-on', true);
|
|
|
|
openWindow('closer');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Clock.toggleClassName('toggle-on', false);
|
2023-09-12 14:42:53 -04:00
|
|
|
closeAll();
|
2023-09-12 14:07:20 -04:00
|
|
|
}
|
2023-09-12 09:37:48 -04:00
|
|
|
}
|
|
|
|
}],
|
|
|
|
],
|
2023-09-11 21:10:00 -04:00
|
|
|
child: Box({
|
|
|
|
child: ClockModule({}),
|
|
|
|
}),
|
2023-09-05 19:22:54 -04:00
|
|
|
});
|