toroface/src/c/main_window.c

33 lines
802 B
C
Raw Normal View History

2025-10-11 19:40:53 +05:00
#include "main_window.h"
2025-10-12 01:03:49 +05:00
#include "clock_layer.h"
2025-10-11 19:40:53 +05:00
static Window *s_main_window;
2025-10-12 01:03:49 +05:00
static void main_window_tick(struct tm *time, TimeUnits units) {
clock_layer_update();
}
2025-10-11 19:40:53 +05:00
2025-10-12 01:03:49 +05:00
static void main_window_load(Window *window) {
clock_layer_init(s_main_window, GPoint(0, 60));
tick_timer_service_subscribe(SECOND_UNIT, main_window_tick);
2025-10-11 19:40:53 +05:00
}
static void main_window_unload(Window *window) {
2025-10-12 01:03:49 +05:00
tick_timer_service_unsubscribe();
clock_layer_deinit();
2025-10-11 19:40:53 +05:00
}
void main_window_init(void) {
s_main_window = window_create();
window_set_window_handlers(s_main_window, (WindowHandlers) {
.load = main_window_load,
.unload = main_window_unload
});
window_stack_push(s_main_window, true);
}
void main_window_deinit(void) {
window_stack_remove(s_main_window, true);
window_destroy(s_main_window);
}