format
This commit is contained in:
parent
1b9bac2611
commit
1c4e999ebe
7 changed files with 65 additions and 32 deletions
|
|
@ -4,3 +4,4 @@ project(
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(mbiff)
|
add_subdirectory(mbiff)
|
||||||
|
add_subdirectory(mauplay)
|
||||||
|
|
|
||||||
10
mauplay/CMakeLists.txt
Normal file
10
mauplay/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
include(MDEBase)
|
||||||
|
setup_project(mauplay ${CMAKE_INSTALL_BINDIR})
|
||||||
|
|
||||||
|
target_link_libraries(
|
||||||
|
mauplay
|
||||||
|
PRIVATE
|
||||||
|
MDEAudio
|
||||||
|
)
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
3
mauplay/main.c
Normal file
3
mauplay/main.c
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#include "mauplay.h"
|
||||||
|
|
||||||
|
int main() {}
|
||||||
19
mauplay/mauplay.h
Normal file
19
mauplay/mauplay.h
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef __MAUPLAY_H__
|
||||||
|
#define __MAUPLAY_H__
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
/* Milsko */
|
||||||
|
#include <MDE/Foundation.h>
|
||||||
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
|
/* External */
|
||||||
|
|
||||||
|
/* Standard */
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
22
mbiff/mail.c
22
mbiff/mail.c
|
|
@ -1,33 +1,33 @@
|
||||||
#include "mbiff.h"
|
#include "mbiff.h"
|
||||||
|
|
||||||
static time_t last = 0;
|
static time_t last = 0;
|
||||||
static char* mailpath;
|
static char* mailpath;
|
||||||
|
|
||||||
void init_mail(void){
|
void init_mail(void) {
|
||||||
struct stat s;
|
struct stat s;
|
||||||
struct passwd* pwd = getpwuid(getuid());
|
struct passwd* pwd = getpwuid(getuid());
|
||||||
|
|
||||||
if(getenv("MAIL") != NULL){
|
if(getenv("MAIL") != NULL) {
|
||||||
mailpath = malloc(strlen(getenv("MAIL")) + strlen(pwd->pw_name) + 1);
|
mailpath = malloc(strlen(getenv("MAIL")) + strlen(pwd->pw_name) + 1);
|
||||||
sprintf(mailpath, getenv("MAIL"), pwd->pw_name);
|
sprintf(mailpath, getenv("MAIL"), pwd->pw_name);
|
||||||
}else{
|
} else {
|
||||||
mailpath = malloc(strlen(_PATH_MAILDIR) + 1 + strlen(pwd->pw_name) + 1);
|
mailpath = malloc(strlen(_PATH_MAILDIR) + 1 + strlen(pwd->pw_name) + 1);
|
||||||
sprintf(mailpath, _PATH_MAILDIR "/%s", pwd->pw_name);
|
sprintf(mailpath, _PATH_MAILDIR "/%s", pwd->pw_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stat(mailpath, &s) == 0){
|
if(stat(mailpath, &s) == 0) {
|
||||||
last = s.st_mtime;
|
last = s.st_mtime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_mail(void){
|
void check_mail(void) {
|
||||||
struct stat s;
|
struct stat s;
|
||||||
s.st_mtime = 0;
|
s.st_mtime = 0;
|
||||||
if(stat(mailpath, &s) == 0 || last != 0){
|
if(stat(mailpath, &s) == 0 || last != 0) {
|
||||||
if((s.st_mtime == 0 && last != 0) || s.st_mtime > last){
|
if((s.st_mtime == 0 && last != 0) || s.st_mtime > last) {
|
||||||
MwVaApply(image,
|
MwVaApply(image,
|
||||||
MwNpixmap, full,
|
MwNpixmap, full,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
last = s.st_mtime;
|
last = s.st_mtime;
|
||||||
|
|
|
||||||
40
mbiff/main.c
40
mbiff/main.c
|
|
@ -3,47 +3,47 @@
|
||||||
#include "mailempty.xpm"
|
#include "mailempty.xpm"
|
||||||
#include "mailfull.xpm"
|
#include "mailfull.xpm"
|
||||||
|
|
||||||
MwWidget window, image, mail;
|
MwWidget window, image, mail;
|
||||||
MwLLPixmap empty, full;
|
MwLLPixmap empty, full;
|
||||||
static int waiting = 0;
|
static int waiting = 0;
|
||||||
|
|
||||||
static void resize(MwWidget handle, void* user, void* client){
|
static void resize(MwWidget handle, void* user, void* client) {
|
||||||
int w = MwGetInteger(handle, MwNwidth);
|
int w = MwGetInteger(handle, MwNwidth);
|
||||||
int h = MwGetInteger(handle, MwNheight);
|
int h = MwGetInteger(handle, MwNheight);
|
||||||
int iw = w < h ? w : h;
|
int iw = w < h ? w : h;
|
||||||
|
|
||||||
(void)user;
|
(void)user;
|
||||||
(void)client;
|
(void)client;
|
||||||
|
|
||||||
MwVaApply(image,
|
MwVaApply(image,
|
||||||
MwNx, (w - iw) / 2,
|
MwNx, (w - iw) / 2,
|
||||||
MwNy, (h - iw) / 2,
|
MwNy, (h - iw) / 2,
|
||||||
MwNwidth, iw,
|
MwNwidth, iw,
|
||||||
MwNheight, iw,
|
MwNheight, iw,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tick(MwWidget handle, void* user, void* client){
|
static void tick(MwWidget handle, void* user, void* client) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
(void)user;
|
(void)user;
|
||||||
(void)client;
|
(void)client;
|
||||||
|
|
||||||
waiting += MwWaitMS;
|
waiting += MwWaitMS;
|
||||||
if(waiting >= 1000){
|
if(waiting >= 1000) {
|
||||||
check_mail();
|
check_mail();
|
||||||
|
|
||||||
waiting = 0;
|
waiting = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mouseUp(MwWidget handle, void* user, void* client){
|
static void mouseUp(MwWidget handle, void* user, void* client) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
(void)user;
|
(void)user;
|
||||||
(void)client;
|
(void)client;
|
||||||
|
|
||||||
MwVaApply(image,
|
MwVaApply(image,
|
||||||
MwNpixmap, empty,
|
MwNpixmap, empty,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
@ -52,12 +52,12 @@ int main() {
|
||||||
MwLibraryInit();
|
MwLibraryInit();
|
||||||
|
|
||||||
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 128, 128,
|
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 128, 128,
|
||||||
MwNtitle, "mbiff",
|
MwNtitle, "mbiff",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
empty = MwLoadImage(window, DATADIR "/mde/icons/128x128/mailempty.png");
|
empty = MwLoadImage(window, DATADIR "/mde/icons/128x128/mailempty.png");
|
||||||
full = MwLoadImage(window, DATADIR "/mde/icons/128x128/mailfull.png");
|
full = MwLoadImage(window, DATADIR "/mde/icons/128x128/mailfull.png");
|
||||||
mail = MwLoadImage(window, DATADIR "/mde/icons/128x128/mail.png");
|
mail = MwLoadImage(window, DATADIR "/mde/icons/128x128/mail.png");
|
||||||
if(empty == NULL) empty = MwLoadXPM(window, mailempty);
|
if(empty == NULL) empty = MwLoadXPM(window, mailempty);
|
||||||
if(full == NULL) full = MwLoadXPM(window, mailfull);
|
if(full == NULL) full = MwLoadXPM(window, mailfull);
|
||||||
if(mail == NULL) mail = MwLoadXPM(window, mailempty);
|
if(mail == NULL) mail = MwLoadXPM(window, mailempty);
|
||||||
|
|
@ -65,8 +65,8 @@ int main() {
|
||||||
MwVaApply(window, MwNiconPixmap, mail, NULL);
|
MwVaApply(window, MwNiconPixmap, mail, NULL);
|
||||||
|
|
||||||
image = MwVaCreateWidget(MwImageClass, "image", window, 0, 0, 128, 128,
|
image = MwVaCreateWidget(MwImageClass, "image", window, 0, 0, 128, 128,
|
||||||
MwNpixmap, empty,
|
MwNpixmap, empty,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
MwAddUserHandler(image, MwNmouseUpHandler, mouseUp, NULL);
|
MwAddUserHandler(image, MwNmouseUpHandler, mouseUp, NULL);
|
||||||
MwAddUserHandler(window, MwNtickHandler, tick, NULL);
|
MwAddUserHandler(window, MwNtickHandler, tick, NULL);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* main.c */
|
/* main.c */
|
||||||
extern MwWidget window, image;
|
extern MwWidget window, image;
|
||||||
extern MwLLPixmap empty, full;
|
extern MwLLPixmap empty, full;
|
||||||
|
|
||||||
/* mail.c */
|
/* mail.c */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue