mdeutils/mbiff/main.c

81 lines
1.7 KiB
C
Raw Normal View History

2025-11-18 20:34:20 +09:00
#include "mbiff.h"
#include "mailempty.xpm"
#include "mailfull.xpm"
2025-12-11 15:24:37 +09:00
MwWidget window, image, mail;
2025-11-27 02:30:24 +09:00
MwLLPixmap empty, full;
static int waiting = 0;
static void* help_about;
2025-11-18 20:34:20 +09:00
2025-11-22 17:57:17 +09:00
static void resize(MwWidget handle, void* user, void* client) {
int w = MwGetInteger(handle, MwNwidth);
2025-12-11 15:24:37 +09:00
int h = MwGetInteger(handle, MwNheight);
2025-11-18 20:34:20 +09:00
int iw = w < h ? w : h;
(void)user;
(void)client;
MwVaApply(image,
2025-11-22 17:57:17 +09:00
MwNx, (w - iw) / 2,
2025-12-11 15:24:37 +09:00
MwNy, (h - iw) / 2,
2025-11-22 17:57:17 +09:00
MwNwidth, iw,
MwNheight, iw,
NULL);
2025-11-18 20:34:20 +09:00
}
2025-11-22 17:57:17 +09:00
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;
2025-11-22 17:57:17 +09:00
if(waiting >= 1000) {
2025-11-18 20:34:20 +09:00
check_mail();
waiting = 0;
}
}
2025-11-22 17:57:17 +09:00
static void mouseUp(MwWidget handle, void* user, void* client) {
2025-11-18 22:51:48 +09:00
(void)handle;
(void)user;
(void)client;
MwVaApply(image,
2025-11-22 17:57:17 +09:00
MwNpixmap, empty,
NULL);
2025-11-18 22:51:48 +09:00
}
2025-11-18 20:34:20 +09:00
int main() {
2025-11-27 02:30:24 +09:00
void* m;
2025-11-18 20:34:20 +09:00
init_mail();
MwLibraryInit();
2025-11-18 23:25:07 +09:00
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 128, 128,
2025-11-22 17:57:17 +09:00
MwNtitle, "mbiff",
NULL);
2025-11-18 20:34:20 +09:00
2025-11-23 02:56:51 +09:00
empty = MwLoadImage(window, ICON128DIR "/mailempty.png");
full = MwLoadImage(window, ICON128DIR "/mailfull.png");
mail = MwLoadImage(window, ICON128DIR "/mail.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-22 15:21:18 +09:00
if(mail == NULL) mail = MwLoadXPM(window, mailempty);
2025-11-18 20:34:20 +09:00
2025-11-22 15:21:18 +09:00
MwVaApply(window, MwNiconPixmap, mail, NULL);
2025-11-21 19:21:27 +09:00
2025-11-27 02:30:24 +09:00
image = MwVaCreateWidget(MwImageClass, "image", window, 0, 0, 0, 0,
2025-11-22 17:57:17 +09:00
MwNpixmap, empty,
NULL);
2025-11-18 20:34:20 +09:00
2025-11-27 02:30:24 +09:00
resize(window, NULL, 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);
}