mdeutils/mbiff/main.c

77 lines
1.6 KiB
C
Raw Normal View History

2025-11-18 20:34:20 +09:00
#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){
2025-11-18 22:51:48 +09:00
(void)handle;
2025-11-18 20:34:20 +09:00
(void)user;
(void)client;
waiting += MwWaitMS;
if(waiting >= 1000){
check_mail();
waiting = 0;
}
}
2025-11-18 22:51:48 +09:00
static void mouseUp(MwWidget handle, void* user, void* client){
(void)handle;
(void)user;
(void)client;
2025-11-21 19:21:27 +09:00
MwVaApply(window,
MwNiconPixmap, empty,
NULL);
2025-11-18 22:51:48 +09:00
MwVaApply(image,
MwNpixmap, empty,
NULL);
}
2025-11-18 20:34:20 +09:00
int main() {
init_mail();
MwLibraryInit();
2025-11-18 23:25:07 +09:00
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 128, 128,
2025-11-18 20:34:20 +09:00
MwNtitle, "mbiff",
NULL);
2025-11-21 19:17:57 +09:00
empty = MwLoadImage(window, DATADIR "/mde/icons/128x128/mailempty.png");
full = MwLoadImage(window, DATADIR "/mde/icons/128x128/mailfull.png");
2025-11-18 23:25:07 +09:00
if(empty == NULL) empty = MwLoadXPM(window, mailempty);
if(full == NULL) full = MwLoadXPM(window, mailfull);
2025-11-18 20:34:20 +09:00
2025-11-21 19:21:27 +09:00
MwVaApply(window, MwNiconPixmap, empty, NULL);
2025-11-18 23:25:07 +09:00
image = MwVaCreateWidget(MwImageClass, "image", window, 0, 0, 128, 128,
2025-11-18 20:34:20 +09:00
MwNpixmap, empty,
NULL);
2025-11-18 22:51:48 +09:00
MwAddUserHandler(image, MwNmouseUpHandler, mouseUp, NULL);
2025-11-18 20:34:20 +09:00
MwAddUserHandler(window, MwNtickHandler, tick, NULL);
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
MwLoop(window);
}