closing brace is only needed on smp build.
[AROS.git] / test / Zune / settings.c
blob0cb109b9c9d192d8766b7b49ad2c306dcb211d07
1 /*
2 Copyright © 2009, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <libraries/mui.h>
7 #include <proto/muimaster.h>
8 #include <proto/intuition.h>
9 #include <proto/alib.h>
10 #include <proto/exec.h>
11 #include <utility/hooks.h>
13 static void UseFunc(struct Hook *hook, Object *app, void *arg)
15 DoMethod(app, MUIM_Application_Save, MUIV_Application_Save_ENV);
16 DoMethod(app, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
19 static void SaveFunc(struct Hook *hook, Object *app, void *arg)
21 DoMethod(app, MUIM_Application_Save, MUIV_Application_Save_ENV);
22 DoMethod(app, MUIM_Application_Save, MUIV_Application_Save_ENVARC);
23 DoMethod(app, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
26 int main(int argc,char *argv[])
28 Object *app, *window, *bt_save, *bt_use, *bt_cancel, *checkbox;
29 ULONG sigs;
30 struct Hook saveHook, useHook;
32 const char *sex[] =
34 "male",
35 "female",
36 NULL
39 const char *hair_color[] =
41 "Blond",
42 "Redhead",
43 "Brunet",
44 NULL
47 useHook.h_Entry = HookEntry;
48 useHook.h_SubEntry = (HOOKFUNC) UseFunc;
49 saveHook.h_Entry = HookEntry;
50 saveHook.h_SubEntry = (HOOKFUNC) SaveFunc;
52 app = ApplicationObject,
53 MUIA_Application_Base, "SETTINGS",
54 SubWindow, window = WindowObject,
55 MUIA_Window_Title, "MUIM_Application_Load / MUIM_Application_Save test",
56 WindowContents, VGroup,
57 Child, ColGroup(2),
58 Child, Label2("Username:"),
59 Child, StringObject, StringFrame, MUIA_ObjectID, 1, MUIA_CycleChain, 1, End,
60 Child, Label1("Password:"),
61 Child, StringObject, StringFrame, MUIA_ObjectID, 4, MUIA_String_Secret, TRUE, MUIA_CycleChain, 1, End,
62 Child, Label1("Sex:"),
63 Child, CycleObject, MUIA_Cycle_Entries, sex, MUIA_ObjectID, 6, MUIA_CycleChain, 1, End,
64 Child, Label("Age:"),
65 Child, SliderObject, MUIA_ObjectID, 5, MUIA_Numeric_Min, 0, MUIA_Numeric_Max, 99, MUIA_CycleChain, 1, End,
66 Child, Label("Hair color:"),
67 Child, RadioObject, MUIA_ObjectID, 7, MUIA_Radio_Entries, hair_color, MUIA_CycleChain, 1, End,
68 Child, Label("AROS user:"),
69 Child, checkbox = MUI_MakeObject(MUIO_Checkmark, FALSE),
70 End,
71 Child, HGroup,
72 Child, bt_save = SimpleButton("Save"),
73 Child, bt_use = SimpleButton("Use"),
74 Child, bt_cancel = SimpleButton("Cancel"),
75 End,
76 End,
77 End,
78 End;
80 if (!app)
81 return 1;
83 set(checkbox, MUIA_ObjectID, 8);
85 DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest,TRUE,
86 app, (IPTR) 2,
87 MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
89 DoMethod(bt_cancel, MUIM_Notify, MUIA_Pressed, FALSE,
90 app, (IPTR) 2,
91 MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
93 DoMethod(bt_save,MUIM_Notify,MUIA_Pressed,FALSE,
94 app, (IPTR) 2,
95 MUIM_CallHook, &saveHook, NULL);
97 DoMethod(bt_use, MUIM_Notify, MUIA_Pressed, FALSE,
98 app, (IPTR) 2,
99 MUIM_CallHook, &useHook, NULL);
101 DoMethod(app, MUIM_Application_Load, MUIV_Application_Load_ENV);
103 set(window, MUIA_Window_Open, TRUE);
105 /* Main loop */
106 while((LONG)DoMethod(app, MUIM_Application_NewInput, (IPTR)&sigs)
107 != MUIV_Application_ReturnID_Quit)
109 if (sigs)
111 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
112 if (sigs & SIGBREAKF_CTRL_C)
113 break;
117 set(window, MUIA_Window_Open, FALSE);
119 MUI_DisposeObject(app);
121 return 0;