define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / workbench / prefs / time / main.c
blob05be592053a13112bdfc4194dc06ed6fabbaaaff
1 /*
2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /*********************************************************************************************/
8 #include "global.h"
9 #include "version.h"
11 #include <libraries/coolimages.h>
12 #include <aros/debug.h>
14 #include <zune/clock.h>
15 #include <zune/calendar.h>
17 #include <stdlib.h> /* for exit() */
18 #include <stdio.h>
19 #include <string.h>
21 /*********************************************************************************************/
23 #define ARG_TEMPLATE "FROM,EDIT/S,USE/S,SAVE/S,PUBSCREEN/K"
25 #define ARG_FROM 0
26 #define ARG_EDIT 1
27 #define ARG_USE 2
28 #define ARG_SAVE 3
29 #define ARG_PUBSCREEN 4
31 #define NUM_ARGS 5
33 #define DO_SPECIAL_BUTTON_LAYOUT 1 /* all button get same width, but as small as possible,
34 and spread along whole parent group */
36 #define SPACING_BUTTONGROUP 4
38 #define RETURNID_USE 1
39 #define RETURNID_SAVE 2
41 /*********************************************************************************************/
43 static struct libinfo
45 APTR var;
46 STRPTR name;
47 WORD version;
48 BOOL required;
50 libtable[] =
52 {&IntuitionBase , "intuition.library" , 39, TRUE },
53 {&GfxBase , "graphics.library" , 40, TRUE }, /* 40, because of WriteChunkyPixels */
54 {&UtilityBase , "utility.library" , 39, TRUE },
55 {&MUIMasterBase , "muimaster.library" , 0 , TRUE },
56 {NULL }
59 /*********************************************************************************************/
61 static struct Hook yearhook, clockhook, activehook, restorehook;
62 #if DO_SPECIAL_BUTTON_LAYOUT
63 static struct Hook buttonlayouthook;
64 #endif
65 static struct RDArgs *myargs;
66 static Object *activetimestrobj;
67 static IPTR args[NUM_ARGS];
69 static STRPTR monthlabels[] =
71 "January",
72 "February",
73 "March",
74 "April",
75 "May",
76 "June",
77 "July",
78 "August",
79 "September",
80 "October",
81 "November",
82 "December",
83 NULL
86 /*********************************************************************************************/
88 static void CloseLibs(void);
89 static void CloseTimerDev(void);
90 static void FreeArguments(void);
91 static void FreeVisual(void);
92 static void KillGUI(void);
94 /*********************************************************************************************/
96 WORD ShowMessage(STRPTR title, STRPTR text, STRPTR gadtext)
98 struct EasyStruct es;
100 es.es_StructSize = sizeof(es);
101 es.es_Flags = 0;
102 es.es_Title = title;
103 es.es_TextFormat = text;
104 es.es_GadgetFormat = gadtext;
106 return EasyRequestArgs(NULL, &es, NULL, NULL);
109 /*********************************************************************************************/
111 void Cleanup(STRPTR msg)
113 if (msg)
115 if (IntuitionBase && !((struct Process *)FindTask(NULL))->pr_CLI)
117 ShowMessage("Time", msg, MSG(MSG_OK));
119 else
121 printf("Time: %s\n", msg);
125 KillGUI();
126 FreeVisual();
127 FreeArguments();
128 CloseTimerDev();
129 CloseLibs();
130 CleanupLocale();
132 exit(prog_exitcode);
136 /*********************************************************************************************/
138 static void OpenLibs(void)
140 struct libinfo *li;
142 for(li = libtable; li->var; li++)
144 if (!((*(struct Library **)li->var) = OpenLibrary(li->name, li->version)))
146 if (li->required)
148 sprintf(s, MSG(MSG_CANT_OPEN_LIB), li->name, li->version);
149 Cleanup(s);
156 /*********************************************************************************************/
158 static void CloseLibs(void)
160 struct libinfo *li;
162 for(li = libtable; li->var; li++)
164 if (*(struct Library **)li->var) CloseLibrary((*(struct Library **)li->var));
168 /*********************************************************************************************/
170 static void OpenTimerDev(void)
172 if ((TimerMP = CreateMsgPort()))
174 if ((TimerIO = (struct timerequest *)CreateIORequest(TimerMP, sizeof(struct timerequest))))
176 if (!OpenDevice("timer.device", UNIT_VBLANK, (struct IORequest *)TimerIO, 0))
178 TimerBase = (struct Device *)TimerIO->tr_node.io_Device;
183 if (!TimerBase)
185 sprintf(s, MSG(MSG_CANT_OPEN_LIB), "timer.device", 0);
186 Cleanup(s);
190 /*********************************************************************************************/
192 static void CloseTimerDev(void)
194 if (TimerIO)
196 CloseDevice((struct IORequest *)TimerIO);
197 DeleteIORequest((struct IORequest *)TimerIO);
200 if (TimerMP)
202 DeleteMsgPort(TimerMP);
206 /*********************************************************************************************/
208 static void OpenBattClockRes(void)
210 BattClockBase = OpenResource("battclock.resource");
212 if (!BattClockBase)
214 sprintf(s, MSG(MSG_CANT_OPEN_LIB), "battclock.resource", 0);
215 Cleanup(s);
219 /*********************************************************************************************/
221 static void GetArguments(void)
223 if (!(myargs = ReadArgs(ARG_TEMPLATE, args, NULL)))
225 Fault(IoErr(), 0, s, 256);
226 Cleanup(s);
229 // if (!args[ARG_FROM]) args[ARG_FROM] = (IPTR)CONFIGNAME_ENV;
232 /*********************************************************************************************/
234 static void FreeArguments(void)
236 if (myargs) FreeArgs(myargs);
239 /*********************************************************************************************/
241 static void GetVisual(void)
245 /*********************************************************************************************/
247 static void FreeVisual(void)
251 /*********************************************************************************************/
253 #if DO_SPECIAL_BUTTON_LAYOUT
255 /*********************************************************************************************/
257 static ULONG ButtonLayoutFunc(struct Hook *hook, Object *obj, struct MUI_LayoutMsg *msg)
259 IPTR retval = MUILM_UNKNOWN;
261 switch(msg->lm_Type)
263 case MUILM_MINMAX:
265 Object *cstate = (Object *)msg->lm_Children->mlh_Head;
266 Object *child;
268 WORD maxminwidth = 0;
269 WORD maxminheight = 0;
270 WORD numchilds = 0;
272 while((child = NextObject(&cstate)))
274 if (_minwidth(child) > maxminwidth) maxminwidth = _minwidth(child);
275 if (_minheight(child) > maxminheight) maxminheight = _minheight(child);
276 numchilds++;
279 msg->lm_MinMax.MinWidth =
280 msg->lm_MinMax.DefWidth = numchilds * maxminwidth + SPACING_BUTTONGROUP * (numchilds - 1);
281 msg->lm_MinMax.MaxWidth = MUI_MAXMAX;
283 msg->lm_MinMax.MinHeight =
284 msg->lm_MinMax.DefHeight =
285 msg->lm_MinMax.MaxHeight = maxminheight;
287 retval = 0;
288 break;
290 case MUILM_LAYOUT:
292 Object *cstate = (Object *)msg->lm_Children->mlh_Head;
293 Object *child;
295 WORD maxminwidth = 0;
296 WORD maxminheight = 0;
297 WORD numchilds = 0;
298 WORD x = 0, i = 0;
300 while((child = NextObject(&cstate)))
302 if (_minwidth(child) > maxminwidth) maxminwidth = _minwidth(child);
303 if (_minheight(child) > maxminheight) maxminheight = _minheight(child);
304 numchilds++;
307 cstate = (Object *)msg->lm_Children->mlh_Head;
308 while((child = NextObject(&cstate)))
310 if (i == numchilds -1)
312 x = msg->lm_Layout.Width - maxminwidth;
314 else
316 x = maxminwidth + (msg->lm_Layout.Width - numchilds * maxminwidth) / (numchilds - 1);
317 x *= i;
319 MUI_Layout(child, x, 0, maxminwidth, maxminheight, 0);
321 i++;
325 retval = TRUE;
326 break;
328 } /* switch(msg->lm_Type) */
330 return retval;
333 /*********************************************************************************************/
335 #endif /* DO_SPECIAL_BUTTON_LAYOUT */
337 /*********************************************************************************************/
339 static void YearFunc(struct Hook *hook, Object *obj, IPTR *param)
341 IPTR year;
343 get(obj, MUIA_String_Integer, &year);
345 if ((LONG)*param == -1)
346 year--;
347 else if ((LONG)*param == 1)
348 year++;
350 if (year < 1978)
352 year = 1978;
353 nnset(obj, MUIA_String_Integer, year);
355 else if (year > 2099)
357 year = 2099;
358 nnset(obj, MUIA_String_Integer, year);
360 else if (*param)
362 nnset(obj, MUIA_String_Integer, year);
365 nnset(calobj, MUIA_Calendar_Year, year);
369 /*********************************************************************************************/
371 static void ActiveFunc(struct Hook *hook, Object *obj, IPTR *param)
373 Object *active;
374 WORD hand = -1;
376 active = *(Object **)param;
378 if (active == hourobj)
380 hand = MUIV_Clock_EditHand_Hour;
382 else if (active == minobj)
384 hand = MUIV_Clock_EditHand_Minute;
386 else if (active == secobj)
388 hand = MUIV_Clock_EditHand_Second;
391 if (hand != -1)
393 activetimestrobj = active;
394 set(clockobj, MUIA_Clock_EditHand, hand);
399 /*********************************************************************************************/
401 static void ClockFunc(struct Hook *hook, Object *obj, IPTR *param)
403 struct ClockData *cd;
404 UBYTE s[3];
406 get(obj, MUIA_Clock_Time, &cd);
408 if (*param == 0)
410 sprintf(s, "%02d", cd->hour);
411 nnset(hourobj, MUIA_String_Contents, s);
413 sprintf(s, "%02d", cd->min);
414 nnset(minobj, MUIA_String_Contents, s);
416 sprintf(s, "%02d", cd->sec);
417 nnset(secobj, MUIA_String_Contents, s);
419 else
421 struct ClockData cd2;
422 LONG diff = (LONG)*param;
423 LONG max = 0;
424 UWORD *cd2_member = NULL;
426 if (diff == 100) diff = 0; /* 100 means string gadget acknowledge */
428 if (activetimestrobj == hourobj)
430 max = 23;
431 cd2_member = &cd2.hour;
433 else if (activetimestrobj == minobj)
435 max = 59;
436 cd2_member = &cd2.min;
438 else if (activetimestrobj == secobj)
440 max = 59;
441 cd2_member = &cd2.sec;
444 if (max)
446 IPTR number = 0;
448 set(obj, MUIA_Clock_Frozen, TRUE);
449 get(obj, MUIA_Clock_Time, &cd);
451 cd2 = *cd;
453 get(activetimestrobj, MUIA_String_Integer, &number);
455 number += diff;
457 if ((LONG)number < 0)
459 number = max;
461 else if ((LONG)number > max)
463 number = 0;
465 *cd2_member = number;
467 sprintf(s, "%02ld", number);
469 nnset(activetimestrobj, MUIA_String_Contents, s);
471 set(obj, MUIA_Clock_Time, (IPTR)&cd2);
477 /*********************************************************************************************/
479 static void RestoreFunc(struct Hook *hook, Object *obj, APTR msg)
481 RestorePrefs();
483 set(calobj, MUIA_Calendar_Date, (IPTR)&clockdata);
484 set(monthobj, MUIA_Cycle_Active, clockdata.month - 1);
485 set(yearobj, MUIA_String_Integer, clockdata.year);
486 set(clockobj, MUIA_Clock_Frozen, FALSE);
490 /*********************************************************************************************/
492 static void MakeGUI(void)
494 extern struct NewMenu nm;
496 Object *menu, *yearaddobj, *yearsubobj, *timeaddobj, *timesubobj;
497 Object *saveobj, *useobj, *cancelobj;
499 #if DO_SPECIAL_BUTTON_LAYOUT
500 buttonlayouthook.h_Entry = HookEntry;
501 buttonlayouthook.h_SubEntry = (HOOKFUNC)ButtonLayoutFunc;
502 #endif
503 yearhook.h_Entry = HookEntry;
504 yearhook.h_SubEntry = (HOOKFUNC)YearFunc;
506 clockhook.h_Entry = HookEntry;
507 clockhook.h_SubEntry = (HOOKFUNC)ClockFunc;
509 activehook.h_Entry = HookEntry;
510 activehook.h_SubEntry = (HOOKFUNC)ActiveFunc;
512 restorehook.h_Entry = HookEntry;
513 restorehook.h_SubEntry = (HOOKFUNC)RestoreFunc;
515 if (LocaleBase)
517 struct Locale *locale = OpenLocale(NULL);
519 if (locale)
521 WORD i;
523 for(i = 0; i < 12; i++)
525 monthlabels[i] = GetLocaleStr(locale, MON_1 + i);
528 CloseLocale(locale);
533 menu = MUI_MakeObject(MUIO_MenustripNM, &nm, 0);
535 app = ApplicationObject,
536 MUIA_Application_Title, (IPTR)"Time",
537 MUIA_Application_Version, (IPTR)VERSIONSTR,
538 MUIA_Application_Copyright, (IPTR)"Copyright © 1995-2002, The AROS Development Team",
539 MUIA_Application_Author, (IPTR)"The AROS Development Team",
540 MUIA_Application_Description, (IPTR)MSG(MSG_WINTITLE),
541 MUIA_Application_Base, (IPTR)"Time",
542 menu ? MUIA_Application_Menustrip : TAG_IGNORE, menu,
543 SubWindow, wnd = WindowObject,
544 MUIA_Window_Title, (IPTR)MSG(MSG_WINTITLE),
545 MUIA_Window_ID, MAKE_ID('T','W','I','N'),
546 WindowContents, VGroup,
547 Child, HGroup, /* Group containing calendar box and clock box */
548 MUIA_Group_SameWidth, TRUE,
549 Child, VGroup, /* Calendar box */
550 GroupFrame,
551 MUIA_Background, MUII_GroupBack,
552 Child, HGroup, /* Month/year row */
553 Child, monthobj = MUI_MakeObject(MUIO_Cycle, NULL, monthlabels),
554 Child, HVSpace,
555 Child, yearsubobj = TextObject, /* year [-] gadget */
556 ButtonFrame,
557 MUIA_Background, MUII_ButtonBack,
558 MUIA_CycleChain, TRUE,
559 MUIA_Font, MUIV_Font_Button,
560 MUIA_InputMode, MUIV_InputMode_RelVerify,
561 MUIA_Text_Contents, "\033c-",
562 MUIA_FixWidthTxt, (IPTR)"+",
563 End,
564 Child, yearobj = StringObject, /* year gadget */
565 StringFrame,
566 MUIA_CycleChain, TRUE,
567 MUIA_String_Accept, (IPTR)"0123456789",
568 MUIA_FixWidthTxt, (IPTR)"55555",
569 End,
570 Child, yearaddobj = TextObject, /* year [-] gadget */
571 ButtonFrame,
572 MUIA_Background, MUII_ButtonBack,
573 MUIA_CycleChain, TRUE,
574 MUIA_Font, MUIV_Font_Button,
575 MUIA_InputMode, MUIV_InputMode_RelVerify,
576 MUIA_Text_Contents, "\033c+",
577 MUIA_FixWidthTxt, (IPTR)"-",
578 End,
579 End,
580 Child, calobj = CalendarObject,
581 MUIA_CycleChain, TRUE,
582 End,
583 End,
584 Child, VGroup, /* Clock box */
585 GroupFrame,
586 MUIA_Background, MUII_GroupBack,
587 Child, clockobj = ClockObject,
588 End,
589 Child, HGroup,
590 Child, HVSpace,
591 Child, PageGroup,
592 Child, HVSpace,
593 Child, HGroup,
594 MUIA_Group_Spacing, 0,
595 Child, TextObject, /* phantom time [-] gadget */
596 ButtonFrame,
597 MUIA_Background, MUII_ButtonBack,
598 MUIA_Font, MUIV_Font_Button,
599 MUIA_InputMode, MUIV_InputMode_RelVerify,
600 MUIA_Text_Contents, "\033c-",
601 MUIA_FixWidthTxt, (IPTR)"+",
602 End,
603 Child, TextObject, /* phantom time [+] gadget */
604 ButtonFrame,
605 MUIA_Background, MUII_ButtonBack,
606 MUIA_Font, MUIV_Font_Button,
607 MUIA_InputMode, MUIV_InputMode_RelVerify,
608 MUIA_Text_Contents, "\033c+",
609 MUIA_FixWidthTxt, (IPTR)"-",
610 End,
611 End,
612 End,
613 Child, hourobj = StringObject, /* hour gadget */
614 StringFrame,
615 MUIA_CycleChain, TRUE,
616 MUIA_String_Accept, (IPTR)"0123456789",
617 MUIA_FixWidthTxt, (IPTR)"555",
618 End,
619 Child, CLabel2(":"),
620 Child, minobj = StringObject, /* min gadget */
621 StringFrame,
622 MUIA_CycleChain, TRUE,
623 MUIA_String_Accept, (IPTR)"0123456789",
624 MUIA_FixWidthTxt, (IPTR)"555",
625 End,
626 Child, CLabel2(":"),
627 Child, secobj = StringObject, /* sec gadget */
628 StringFrame,
629 MUIA_CycleChain, TRUE,
630 MUIA_String_Accept, (IPTR)"0123456789",
631 MUIA_FixWidthTxt, (IPTR)"555",
632 End,
633 Child, HGroup,
634 MUIA_Group_Spacing, 0,
635 Child, timesubobj = TextObject, /* time [-] gadget */
636 ButtonFrame,
637 MUIA_Background, MUII_ButtonBack,
638 MUIA_CycleChain, TRUE,
639 MUIA_Font, MUIV_Font_Button,
640 MUIA_InputMode, MUIV_InputMode_RelVerify,
641 MUIA_Text_Contents, "\033c-",
642 MUIA_FixWidthTxt, (IPTR)"+",
643 End,
644 Child, timeaddobj = TextObject, /* time [+] gadget */
645 ButtonFrame,
646 MUIA_Background, MUII_ButtonBack,
647 MUIA_CycleChain, TRUE,
648 MUIA_Font, MUIV_Font_Button,
649 MUIA_InputMode, MUIV_InputMode_RelVerify,
650 MUIA_Text_Contents, "\033c+",
651 MUIA_FixWidthTxt, (IPTR)"-",
652 End,
653 End,
654 Child, HVSpace,
655 End,
656 End,
657 End,
658 Child, HGroup, /* save/use/cancel button row */
659 #if DO_SPECIAL_BUTTON_LAYOUT
660 MUIA_Group_LayoutHook, (IPTR)&buttonlayouthook,
661 #else
662 MUIA_FixHeight, 1,
663 MUIA_Group_SameWidth, TRUE,
664 #endif
665 Child, saveobj = CoolImageIDButton(MSG(MSG_GAD_SAVE), COOL_SAVEIMAGE_ID),
666 Child, useobj = CoolImageIDButton(MSG(MSG_GAD_USE), COOL_DOTIMAGE_ID),
667 Child, cancelobj = CoolImageIDButton(MSG(MSG_GAD_CANCEL), COOL_CANCELIMAGE_ID),
668 End,
669 End,
670 End,
671 End;
673 if (!app) Cleanup(MSG(MSG_CANT_CREATE_APP));
675 DoMethod(wnd, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR) app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
677 DoMethod(cancelobj, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR) app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
678 DoMethod(saveobj, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR) app, 2, MUIM_Application_ReturnID, RETURNID_SAVE);
679 DoMethod(useobj, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR) app, 2, MUIM_Application_ReturnID, RETURNID_USE);
681 DoMethod(wnd, MUIM_Notify, MUIA_Window_MenuAction, MSG_MEN_PROJECT_QUIT, (IPTR) app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
682 DoMethod(wnd, MUIM_Notify, MUIA_Window_MenuAction, MSG_MEN_EDIT_RESTORE, (IPTR) app, 2, MUIM_CallHook, (IPTR)&restorehook);
684 DoMethod(wnd, MUIM_Notify, MUIA_Window_ActiveObject, MUIV_EveryTime, (IPTR) app, 3, MUIM_CallHook, (IPTR)&activehook, MUIV_TriggerValue);
685 DoMethod(monthobj, MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, (IPTR) calobj, 3, MUIM_NoNotifySet, MUIA_Calendar_Month0, MUIV_TriggerValue);
686 DoMethod(yearobj, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, (IPTR) yearobj, 3, MUIM_CallHook, (IPTR)&yearhook, 0);
687 DoMethod(yearaddobj, MUIM_Notify, MUIA_Timer, MUIV_EveryTime, (IPTR) yearobj, 3, MUIM_CallHook, (IPTR)&yearhook, 1);
688 DoMethod(yearsubobj, MUIM_Notify, MUIA_Timer, MUIV_EveryTime, (IPTR) yearobj, 3, MUIM_CallHook, (IPTR)&yearhook, -1);
689 DoMethod(timeaddobj, MUIM_Notify, MUIA_Timer, MUIV_EveryTime, (IPTR) clockobj, 3, MUIM_CallHook, (IPTR)&clockhook, 1);
690 DoMethod(timesubobj, MUIM_Notify, MUIA_Timer, MUIV_EveryTime, (IPTR) clockobj, 3, MUIM_CallHook, (IPTR)&clockhook, -1);
691 DoMethod(clockobj, MUIM_Notify, MUIA_Clock_Ticked, TRUE, (IPTR) clockobj, 3, MUIM_CallHook, (IPTR)&clockhook, 0);
692 DoMethod(hourobj, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, (IPTR) clockobj, 3, MUIM_CallHook, (IPTR)&clockhook, 100);
693 DoMethod(minobj, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, (IPTR) clockobj, 3, MUIM_CallHook, (IPTR)&clockhook, 100);
694 DoMethod(secobj, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime, (IPTR) clockobj, 3, MUIM_CallHook, (IPTR)&clockhook, 100);
696 set(calobj, MUIA_Calendar_Date, &clockdata);
697 set(monthobj, MUIA_Cycle_Active, clockdata.month - 1);
698 set(yearobj, MUIA_String_Integer, clockdata.year);
700 CallHook(&clockhook, clockobj, 0);
703 /*********************************************************************************************/
705 static void KillGUI(void)
707 DisposeObject(app);
710 /*********************************************************************************************/
712 static void HandleAll(void)
714 ULONG sigs = 0;
715 LONG returnid;
717 set (wnd, MUIA_Window_Open, TRUE);
719 for(;;)
721 returnid = (LONG) DoMethod(app, MUIM_Application_NewInput, (IPTR) &sigs);
723 if ((returnid == MUIV_Application_ReturnID_Quit) ||
724 (returnid == RETURNID_SAVE) || (returnid == RETURNID_USE)) break;
726 if (sigs)
728 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
729 if (sigs & SIGBREAKF_CTRL_C) break;
733 switch(returnid)
735 case RETURNID_SAVE:
736 case RETURNID_USE:
738 struct ClockData cal_date, clock_time, *dateptr;
739 IPTR frozen = 0;
741 get(calobj, MUIA_Calendar_Date, &dateptr);
742 cal_date = *dateptr;
744 get(clockobj, MUIA_Clock_Frozen, &frozen);
745 if (frozen)
747 get(clockobj, MUIA_Clock_Time, &dateptr);
748 clock_time = *dateptr;
750 else
752 struct timeval tv;
754 GetSysTime(&tv);
755 Amiga2Date(tv.tv_secs, &clock_time);
758 clockdata.sec = clock_time.sec;
759 clockdata.min = clock_time.min;
760 clockdata.hour = clock_time.hour;
761 clockdata.mday = cal_date.mday;
762 clockdata.month = cal_date.month;
763 clockdata.year = cal_date.year;
764 clockdata.wday = cal_date.wday;
766 if (returnid == RETURNID_SAVE)
767 SavePrefs();
768 else
769 UsePrefs();
771 break;
776 /*********************************************************************************************/
778 int main(void)
780 InitLocale("System/Prefs/Time.catalog", 1);
781 InitMenus();
782 OpenLibs();
783 OpenTimerDev();
784 OpenBattClockRes();
785 GetArguments();
786 InitPrefs((args[ARG_USE] ? TRUE : FALSE), (args[ARG_SAVE] ? TRUE : FALSE));
787 GetVisual();
788 MakeGUI();
789 HandleAll();
790 Cleanup(NULL);
792 return 0;
795 /*********************************************************************************************/