From 871ea22d7d2225b1b160c62be2fbca2d8ab5736e Mon Sep 17 00:00:00 2001 From: neil Date: Thu, 30 Apr 2009 18:09:57 +0000 Subject: [PATCH] Now saves time. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@31160 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/prefs/time/global.h | 6 +++++- workbench/prefs/time/main.c | 22 +++++++++++++++++++--- workbench/prefs/time/prefs.c | 8 +++++++- workbench/prefs/time/vars.h | 3 ++- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/workbench/prefs/time/global.h b/workbench/prefs/time/global.h index 1d7f531a7..f28903595 100644 --- a/workbench/prefs/time/global.h +++ b/workbench/prefs/time/global.h @@ -1,5 +1,5 @@ /* - Copyright © 1995-2003, The AROS Development Team. All rights reserved. + Copyright © 1995-2009, The AROS Development Team. All rights reserved. $Id$ */ @@ -123,6 +123,10 @@ #include #endif +#ifndef PROTO_BATTCLOCK_H +#include +#endif + #ifndef PROTO_MUIMASTER_H #include #endif diff --git a/workbench/prefs/time/main.c b/workbench/prefs/time/main.c index 3c5db822c..05be59205 100644 --- a/workbench/prefs/time/main.c +++ b/workbench/prefs/time/main.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2003, The AROS Development Team. All rights reserved. + Copyright © 1995-2009, The AROS Development Team. All rights reserved. $Id$ */ @@ -205,6 +205,19 @@ static void CloseTimerDev(void) /*********************************************************************************************/ +static void OpenBattClockRes(void) +{ + BattClockBase = OpenResource("battclock.resource"); + + if (!BattClockBase) + { + sprintf(s, MSG(MSG_CANT_OPEN_LIB), "battclock.resource", 0); + Cleanup(s); + } +} + +/*********************************************************************************************/ + static void GetArguments(void) { if (!(myargs = ReadArgs(ARG_TEMPLATE, args, NULL))) @@ -750,8 +763,10 @@ static void HandleAll(void) clockdata.year = cal_date.year; clockdata.wday = cal_date.wday; - UsePrefs(); - + if (returnid == RETURNID_SAVE) + SavePrefs(); + else + UsePrefs(); } break; @@ -766,6 +781,7 @@ int main(void) InitMenus(); OpenLibs(); OpenTimerDev(); + OpenBattClockRes(); GetArguments(); InitPrefs((args[ARG_USE] ? TRUE : FALSE), (args[ARG_SAVE] ? TRUE : FALSE)); GetVisual(); diff --git a/workbench/prefs/time/prefs.c b/workbench/prefs/time/prefs.c index ecfe60065..368758a6d 100644 --- a/workbench/prefs/time/prefs.c +++ b/workbench/prefs/time/prefs.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. + Copyright © 1995-2009, The AROS Development Team. All rights reserved. $Id$ Desc: @@ -51,6 +51,12 @@ BOOL UsePrefs(void) BOOL SavePrefs(void) { + ULONG secs; + + secs = Date2Amiga(&clockdata); + WriteBattClock(secs); + UsePrefs(); + return TRUE; } diff --git a/workbench/prefs/time/vars.h b/workbench/prefs/time/vars.h index 730debe83..e365e1897 100644 --- a/workbench/prefs/time/vars.h +++ b/workbench/prefs/time/vars.h @@ -1,5 +1,5 @@ /* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. + Copyright © 1995-2009, The AROS Development Team. All rights reserved. $Id$ Desc: @@ -23,6 +23,7 @@ VAR struct Library *LocaleBase; VAR struct Library *MUIMasterBase; VAR struct Device *TimerBase; +VAR APTR BattClockBase; VAR struct MUI_CustomClass *calendarmcc; VAR struct MUI_CustomClass *clockmcc; VAR struct MsgPort *TimerMP; -- 2.11.4.GIT