mdeutils/mbiff/main.c
2025-11-18 20:34:20 +09:00

58 lines
1.1 KiB
C

#include "mbiff.h"
#include "mailempty.xpm"
#include "mailfull.xpm"
MwWidget window, image;
MwLLPixmap empty, full;
static int waiting = 0;
static void resize(MwWidget handle, void* user, void* client){
int w = MwGetInteger(handle, MwNwidth);
int h = MwGetInteger(handle, MwNheight);
int iw = w < h ? w : h;
(void)user;
(void)client;
MwVaApply(image,
MwNx, (w - iw) / 2,
MwNy, (h - iw) / 2,
MwNwidth, iw,
MwNheight, iw,
NULL);
}
static void tick(MwWidget handle, void* user, void* client){
(void)user;
(void)client;
waiting += MwWaitMS;
if(waiting >= 1000){
check_mail();
waiting = 0;
}
}
int main() {
init_mail();
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 48, 48,
MwNtitle, "mbiff",
NULL);
empty = MwLoadXPM(window, mailempty);
full = MwLoadXPM(window, mailfull);
image = MwVaCreateWidget(MwImageClass, "image", window, 0, 0, 48, 48,
MwNpixmap, empty,
NULL);
MwAddUserHandler(window, MwNtickHandler, tick, NULL);
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
MwLoop(window);
}