2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
6 /* gui_zune.c -- here are all functions for the ZUNE gui */
15 #include "variables.h"
17 /* External variables */
18 extern BPTR inputfile
;
19 extern char buffer
[MAXARGSIZE
];
20 extern char *filename
;
21 extern InstallerPrefs preferences
;
22 extern int error
, grace_exit
;
23 extern int doing_abort
;
25 #include <exec/types.h>
30 #include <proto/intuition.h>
31 #include <proto/muimaster.h>
32 #include <libraries/mui.h>
34 #include <libraries/coolimages.h>
36 #define HBar(x) MUI_MakeObject(MUIO_HBar,x)
37 #define CoolImageIDButton(label,imageid) SimpleButton(label)
42 Object
*reqwnd
, *helpwnd
, *helptext
;
43 Object
*reqroot
, *root
;
44 Object
*btproceed
, *btabort
, *btskip
, *bthelp
;
45 Object
*intermediate
= NULL
;
61 /* ######################################################################## */
63 void AddContents(Object
*obj
)
65 DoMethod(root
, MUIM_Group_InitChange
);
66 if (intermediate
!= NULL
)
68 DoMethod(root
, OM_REMMEMBER
, (IPTR
)intermediate
);
69 MUI_DisposeObject(intermediate
);
72 DoMethod(root
, OM_ADDMEMBER
, (IPTR
)obj
);
73 DoMethod(root
, MUIM_Group_ExitChange
);
75 void DelContents(Object
*obj
)
77 DoMethod(root
, MUIM_Group_InitChange
);
78 DoMethod(root
, OM_REMMEMBER
, (IPTR
)obj
);
79 DoMethod(root
, MUIM_Group_ExitChange
);
80 MUI_DisposeObject(obj
);
83 #define WaitCTRL(sigs) \
86 sigs = Wait(sigs | SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_D); \
87 if (sigs & SIGBREAKF_CTRL_C) break; \
88 if (sigs & SIGBREAKF_CTRL_D) break; \
91 #define disable_abort(val) set(btabort, MUIA_Disabled, val)
92 #define disable_skip(val) set(btskip, MUIA_Disabled, val)
93 #define disable_help(val) set(bthelp, MUIA_Disabled, val)
95 #define NeedPROMPT(pl) \
96 if ( GetPL(pl, _PROMPT).intval == 0 ) \
98 error = SCRIPTERROR; \
99 traperr("Missing prompt!\n", NULL); \
102 #define NeedHELP(pl) \
103 if ( GetPL(pl, _HELP).intval == 0 ) \
105 error = SCRIPTERROR; \
106 traperr("Missing help!\n", NULL); \
109 #define TRANSSCRIPT() \
110 if ( preferences.transcriptstream != BNULL ) \
114 int m = GetPL(pl, _PROMPT).intval; \
115 for ( i = 0 ; i < m ; i ++ ) \
117 len += strlen(GetPL(pl, _PROMPT).arg[i]) + 2; \
119 out = malloc((len+2)*sizeof(char)); \
122 for ( i = 0 ; i < m ; i ++ ) \
125 strcat(out,GetPL(pl, _PROMPT).arg[i]); \
128 Write(preferences.transcriptstream, out, len); \
133 * Ask user if he really wants to abort
137 BOOL running
= TRUE
, quit
= FALSE
;
140 Object
*btok
, *btcancel
;
144 GroupFrameT(_(MSG_MESSAGE
)),
145 MUIA_Text_Contents
, (IPTR
)ASKQUIT_STRING
,
149 MUIA_Group_SameSize
, TRUE
,
150 Child
, btok
= CoolImageIDButton(_(MSG_OK
), COOL_USEIMAGE_ID
),
151 Child
, btcancel
= CoolImageIDButton(_(MSG_CANCEL
), COOL_CANCELIMAGE_ID
),
154 set(btok
,MUIA_CycleChain
,1);
155 set(btcancel
,MUIA_CycleChain
,1);
156 DoMethod(btok
, MUIM_Notify
, MUIA_Pressed
, FALSE
,(IPTR
)app
, 2, MUIM_Application_ReturnID
, Push_Ok
);
157 DoMethod(btcancel
, MUIM_Notify
, MUIA_Pressed
, FALSE
,(IPTR
)app
, 2, MUIM_Application_ReturnID
, Push_Cancel
);
158 DoMethod(reqroot
, OM_ADDMEMBER
, (IPTR
)wc
);
160 set(reqwnd
, MUIA_Window_Open
, TRUE
);
163 switch (DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
177 set(reqwnd
, MUIA_Window_Open
, FALSE
);
179 DoMethod(reqroot
, OM_REMMEMBER
, (IPTR
)wc
);
180 MUI_DisposeObject(wc
);
186 /* Execute trap(1) */
187 traperr( "User aborted!\n", NULL
);
192 /* ######################################################################## */
195 const char GuiWinTitle
[] ="AROS - Installer V43.3";
198 #define WINDOWWIDTH 400
199 #define WINDOWHEIGHT 300
201 void helpwin(char *title
, char *text
)
206 set(helptext
, MUIA_Text_Contents
, text
);
207 set(helpwnd
, MUIA_Window_Title
, title
);
208 set(helpwnd
, MUIA_Window_Open
, TRUE
);
211 switch (DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
213 case MUIV_Application_ReturnID_Quit
:
221 set(helpwnd
, MUIA_Window_Open
, FALSE
);
225 void helpwinpl(char *title
, struct ParameterList
*pl
, int what
)
229 text
= collatestrings(GetPL(pl
, what
).intval
, GetPL(pl
, what
).arg
);
232 helpwin(title
, text
);
245 scr
= LockPubScreen(NULL
);
247 app
= ApplicationObject
,
248 MUIA_Application_Title
, "AROS - Installer",
249 MUIA_Application_DoubleStart
, TRUE
,
251 SubWindow
, wnd
= WindowObject
,
252 MUIA_Window_Title
, GuiWinTitle
,
253 MUIA_Window_Width
, WINDOWWIDTH
,
254 MUIA_Window_Height
, WINDOWHEIGHT
,
255 MUIA_Window_CloseGadget
, FALSE
,
256 MUIA_Window_NoMenus
, TRUE
,
257 MUIA_Window_ID
, MAKE_ID('A','I','N','S'),
258 WindowContents
, VGroup
,
259 Child
, root
= VGroup
, End
,
262 MUIA_Group_SameSize
, TRUE
,
263 Child
, btproceed
= CoolImageIDButton("Proceed", COOL_USEIMAGE_ID
),
264 Child
, btabort
= CoolImageIDButton("Abort", COOL_CANCELIMAGE_ID
),
265 Child
, btskip
= CoolImageIDButton("Skip", COOL_WARNIMAGE_ID
),
266 Child
, bthelp
= CoolImageIDButton("Help", COOL_INFOIMAGE_ID
),
270 SubWindow
, helpwnd
= WindowObject
,
271 MUIA_Window_Width
, WINDOWWIDTH
,
272 MUIA_Window_Height
, WINDOWHEIGHT
,
273 MUIA_Window_CloseGadget
, TRUE
,
274 MUIA_Window_SizeGadget
, FALSE
,
275 MUIA_Window_NoMenus
, TRUE
,
276 WindowContents
, VGroup
,
277 Child
, helptext
= TextObject
,
279 MUIA_Background
, MUII_GroupBack
,
280 MUIA_Text_Contents
, (IPTR
)NULL
,
285 SubWindow
, reqwnd
= WindowObject
,
286 MUIA_Window_Width
, WINDOWWIDTH
,
287 MUIA_Window_Height
, WINDOWHEIGHT
,
288 MUIA_Window_CloseGadget
, FALSE
,
289 MUIA_Window_SizeGadget
, FALSE
,
290 MUIA_Window_NoMenus
, TRUE
,
291 WindowContents
, VGroup
,
292 Child
, reqroot
= VGroup
, End
,
298 /* failed to initialize GUI */
300 printf("Failed to intialize Zune GUI\n");
304 set(btproceed
,MUIA_CycleChain
,1);
305 set(btabort
,MUIA_CycleChain
,1);
306 set(btskip
,MUIA_CycleChain
,1);
307 set(bthelp
,MUIA_CycleChain
,1);
308 DoMethod(helpwnd
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, (IPTR
)app
, 2,
309 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
311 DoMethod(btproceed
, MUIM_Notify
, MUIA_Pressed
, FALSE
,(IPTR
)app
, 2,
312 MUIM_Application_ReturnID
, Push_Proceed
);
313 DoMethod(btabort
, MUIM_Notify
, MUIA_Pressed
, FALSE
,(IPTR
)app
, 2,
314 MUIM_Application_ReturnID
, Push_Abort
);
315 DoMethod(btskip
, MUIM_Notify
, MUIA_Pressed
, FALSE
,(IPTR
)app
, 2,
316 MUIM_Application_ReturnID
, Push_Skip
);
317 DoMethod(bthelp
, MUIM_Notify
, MUIA_Pressed
, FALSE
,(IPTR
)app
, 2,
318 MUIM_Application_ReturnID
, Push_Help
);
319 set(wnd
, MUIA_Window_Open
, TRUE
);
320 UnlockPubScreen(NULL
, scr
);
328 set(wnd
, MUIA_Window_Open
, FALSE
);
329 MUI_DisposeObject(app
);
334 * Show user that we are going to "(abort)" install
335 * Don't confuse NOVICE...
337 void show_abort(char *msg
)
343 if ( get_var_int("@user-level") > _NOVICE
)
351 GroupFrameT("Aborting Installation:"),
352 MUIA_Text_Contents
, (IPTR
)(msg
),
362 switch (DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
376 disable_abort(FALSE
);
385 * Show user how much we have completed yet
387 void show_complete(long int percent
)
391 text
= malloc(strlen(GuiWinTitle
) + 13);
396 sprintf(text
, "%s (Done %3ld%%)", GuiWinTitle
, percent
);
397 set(wnd
, MUIA_Window_Title
, text
);
403 * Show user that we "(exit)" the installation
405 void show_exit(char *msg
)
412 msg2
= malloc((strlen(msg
)+strlen(DONE_TEXT
))*sizeof(char));
415 strcat(msg2
,DONE_TEXT
);
422 GroupFrameT("Aborting Installation:"),
423 MUIA_Text_Contents
, (IPTR
)(msg2
),
433 switch (DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
447 disable_abort(FALSE
);
454 * Show the line which caused the parse-error
456 void show_parseerror(char * msg
, int errline
)
462 * Tell user that some big task is to be done
465 void show_working(char *msg
)
467 if (intermediate
!= NULL
)
469 DelContents(intermediate
);
472 intermediate
= VGroup
,
474 GroupFrameT(_(MSG_MESSAGE
)),
475 MUIA_Text_Contents
, (IPTR
)(msg
),
481 DoMethod(root
, MUIM_Group_InitChange
);
482 DoMethod(root
, OM_ADDMEMBER
, (IPTR
)intermediate
);
483 DoMethod(root
, MUIM_Group_ExitChange
);
489 * Display a "(message)" to the user
490 * Don't confuse NOVICE unless "(all)" users want to get this info
492 void show_message(char * msg
, struct ParameterList
* pl
)
498 if ( GetPL(pl
, _ALL
).used
== 1 || get_var_int("@user-level") > _NOVICE
)
501 if ( GetPL(pl
, _HELP
).used
!= 1 )
508 GroupFrameT(_(MSG_MESSAGE
)),
509 MUIA_Text_Contents
, (IPTR
)(msg
),
519 switch (DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
528 helpwinpl(HELP_ON_MESSAGE
, pl
, _HELP
);
546 * Ask user for his user-level
548 void request_userlevel(char *msg
)
555 LONG usrlevel
, logval
;
561 /* Ask for User Level */
562 usrlevel
= preferences
.defusrlevel
;
567 welcome
= strdup(msg
);
571 welcome
= malloc(sizeof(char *)*(strlen(WELCOME_TEMPLATE
)+strlen(get_var_arg("@app-name"))));
573 sprintf(welcome
, WELCOME_TEMPLATE
, get_var_arg("@app-name"));
575 mxlabels
= malloc(4*sizeof(STRPTR
));
576 mxlabels
[0] = strdup(NOVICE_NAME
);
577 mxlabels
[1] = strdup(ADVANCED_NAME
);
578 mxlabels
[2] = strdup(EXPERT_NAME
);
583 Child
, VGroup
, GroupFrame
,
586 MUIA_Background
, MUII_GroupBack
,
587 MUIA_Text_Contents
, (IPTR
)(welcome
),
589 Child
, levelmx
= RadioObject
,
590 GroupFrameT(USERLEVEL_REQUEST
),
591 MUIA_Radio_Entries
, (IPTR
)(mxlabels
),
593 Child
, btabout
= CoolImageIDButton("About Installer" ,COOL_ASKIMAGE_ID
),
599 set(levelmx
, MUIA_Radio_Active
, usrlevel
);
600 DoMethod(btabout
, MUIM_Notify
, MUIA_Pressed
, FALSE
,(IPTR
)app
, 2, MUIM_Application_ReturnID
, Push_About
);
605 switch (DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
614 helpwin(HELP_ON_USERLEVEL
, USERLEVEL_HELP
);
620 /* TODO: help/about for Installer */
621 helptext
= malloc(512 * sizeof(char));
622 sprintf(helptext
, ABOUT_INSTALLER
, INSTALLER_VERSION
, INSTALLER_REVISION
);
623 helpwin(ABOUT_ON_INSTALLER
, helptext
);
632 GetAttr(MUIA_Radio_Active
, levelmx
, (IPTR
*)&usrlevel
);
633 set_variable("@user-level", NULL
, usrlevel
);
642 /* Ask for Logfile creation */
645 mxlabels
[0] = strdup(LOG_FILE_TEXT
);
646 mxlabels
[1] = strdup(LOG_PRINT_TEXT
);
647 mxlabels
[2] = strdup(LOG_NOLOG_TEXT
);
650 Child
, levelmx
= RadioObject
,
651 GroupFrameT(LOG_QUESTION
),
652 MUIA_Radio_Entries
, (IPTR
)(mxlabels
),
663 switch (DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
675 /* TODO: help for logfile-requester */
676 helptext
= malloc(512 * sizeof(char));
677 sprintf(helptext
, LOG_HELP
, preferences
.transcriptfile
);
678 helpwin(HELP_ON_LOGFILES
, helptext
);
687 GetAttr(MUIA_Radio_Active
, levelmx
, (IPTR
*)&logval
);
690 case 0: /* Log to file */
691 /* TODO: Handle Logging output selection */
693 case 1: /* Log to printer */
694 free(preferences
.transcriptfile
);
695 preferences
.transcriptfile
= strdup("PRT:");
698 free(preferences
.transcriptfile
);
699 preferences
.transcriptfile
= NULL
;
709 if (!preferences
.nopretend
)
711 mxlabels
[0] = strdup(NOPRETEND_TEXT
);
712 mxlabels
[1] = strdup(PRETEND_TEXT
);
716 Child
, levelmx
= RadioObject
,
717 GroupFrameT(PRETEND_QUESTION
),
718 MUIA_Radio_Entries
, (IPTR
)(mxlabels
),
729 switch (DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
738 helpwin(HELP_ON_PRETEND
, PRETEND_HELP
);
745 GetAttr(MUIA_Radio_Active
, levelmx
, (IPTR
*)&logval
);
748 case 0: /* Really Install */
749 preferences
.pretend
= FALSE
;
751 case 1: /* Only pretend to install */
752 preferences
.pretend
= TRUE
;
770 * Ask user for a boolean
772 long int request_bool(struct ParameterList
*pl
)
781 m
= GetPL(pl
, _PROMPT
).intval
;
783 retval
= ( GetPL(pl
, _DEFAULT
).intval
!= 0 );
785 mxlabels
= malloc(3*sizeof(STRPTR
));
787 if ( GetPL(pl
, _CHOICES
).used
== 1 )
789 if (GetPL(pl
, _CHOICES
).intval
>= 2)
791 mxlabels
[0] = strdup(GetPL(pl
, _CHOICES
).arg
[0]);
792 mxlabels
[1] = strdup(GetPL(pl
, _CHOICES
).arg
[1]);
794 else if (GetPL(pl
, _CHOICES
).intval
== 1)
796 mxlabels
[0] = strdup(GetPL(pl
, _CHOICES
).arg
[0]);
797 mxlabels
[1] = strdup(_(MSG_NO
));
801 mxlabels
[0] = strdup(_(MSG_YES
));
802 mxlabels
[1] = strdup(_(MSG_NO
));
807 mxlabels
[0] = strdup(_(MSG_YES
));
808 mxlabels
[1] = strdup(_(MSG_NO
));
814 if ( get_var_int("@user-level") > _NOVICE
)
818 Object
*levelmx
, *wc
;
822 out
= collatestrings(m
, GetPL(pl
, _PROMPT
).arg
);
825 Child
, VGroup
, GroupFrame
,
826 MUIA_Background
, MUII_GroupBack
,
828 MUIA_Text_Contents
, (IPTR
)(out
),
830 Child
, levelmx
= RadioObject
,
831 MUIA_Radio_Entries
, (IPTR
)(mxlabels
),
842 switch (DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
851 if (GetPL(pl
, _HELP
).intval
)
853 helpwinpl(HELP_ON_ASKNUMBER
, pl
, _HELP
);
857 helpwin(HELP_ON_ASKNUMBER
, get_var_arg("@asknumber-help"));
865 GetAttr(MUIA_Radio_Active
, levelmx
, &retval
);
872 if ( preferences
.transcriptstream
!= BNULL
)
874 Write(preferences
.transcriptstream
, "Ask Question: Result was \"", 26);
875 Write(preferences
.transcriptstream
, mxlabels
[retval
], strlen(mxlabels
[retval
]));
876 Write(preferences
.transcriptstream
, "\".\n\n", 4);
887 * Ask user for a number
889 long int request_number(struct ParameterList
*pl
)
892 long int i
, min
, max
;
893 char minmax
[MAXARGSIZE
];
895 retval
= GetPL( pl
, _DEFAULT
).intval
;
896 if ( GetPL( pl
, _RANGE
).used
== 1 )
898 min
= GetPL( pl
, _RANGE
).intval
;
899 max
= GetPL( pl
, _RANGE
).intval2
;
900 /* Wrong order ? Change order */
907 sprintf(minmax
, "Range = [%ld, %ld]", min
, max
);
914 min
= ( retval
< 0 ) ? retval
: 0;
919 if ( get_var_int( "@user-level" ) > _NOVICE
)
927 out
= collatestrings(GetPL(pl
, _PROMPT
).intval
, GetPL(pl
, _PROMPT
).arg
);
930 Child
, VGroup
, GroupFrame
,
931 MUIA_Background
, MUII_GroupBack
,
933 MUIA_Text_Contents
, (IPTR
)(out
),
935 Child
, st
= StringObject
,
937 MUIA_String_Accept
, (IPTR
)"-0123456789",
938 MUIA_String_Integer
, retval
,
939 MUIA_String_AdvanceOnCR
,TRUE
,
940 MUIA_CycleChain
, TRUE
,
943 MUIA_Text_Contents
, (IPTR
)(minmax
),
954 switch (DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
960 GetAttr(MUIA_String_Integer
, st
, &retval
);
961 if ( retval
<= max
&& retval
>= min
)
967 if (GetPL(pl
, _HELP
).intval
)
969 helpwinpl(HELP_ON_ASKSTRING
, pl
, _HELP
);
973 helpwin(HELP_ON_ASKNUMBER
, get_var_arg("@asknumber-help"));
981 GetAttr(MUIA_String_Integer
, st
, &retval
);
988 if ( preferences
.transcriptstream
!= BNULL
)
990 char tmpbuf
[MAXARGSIZE
];
991 Write(preferences
.transcriptstream
, "Ask Number: Result was \"", 24);
992 sprintf(tmpbuf
, "%ld", retval
);
993 Write(preferences
.transcriptstream
, tmpbuf
, strlen(tmpbuf
));
994 Write(preferences
.transcriptstream
, "\".\n\n", 4);
1002 * Ask user for a string
1004 char *request_string(struct ParameterList
*pl
)
1006 char *retval
, *string
= NULL
;
1009 if ( GetPL(pl
, _DEFAULT
).used
== 1 )
1011 string
= strdup(GetPL(pl
, _DEFAULT
).arg
[0]);
1015 string
= strdup(EMPTY_STRING
);
1018 if ( get_var_int( "@user-level" ) > _NOVICE
)
1021 BOOL running
= TRUE
;
1026 out
= collatestrings(GetPL(pl
, _PROMPT
).intval
, GetPL(pl
, _PROMPT
).arg
);
1029 Child
, VGroup
, GroupFrame
,
1030 MUIA_Background
, MUII_GroupBack
,
1032 MUIA_Text_Contents
, (IPTR
)(out
),
1034 Child
, st
= StringObject
,
1036 MUIA_String_Contents
, (IPTR
)string
,
1037 MUIA_String_MaxLen
, 128,
1038 MUIA_String_AdvanceOnCR
,TRUE
,
1039 MUIA_CycleChain
, TRUE
,
1051 switch (DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
1060 if (GetPL(pl
, _HELP
).intval
)
1062 helpwinpl(HELP_ON_ASKSTRING
, pl
, _HELP
);
1066 helpwin(HELP_ON_ASKNUMBER
, get_var_arg("@asknumber-help"));
1075 get(st
, MUIA_String_Contents
, &str
);
1076 string
= strdup(str
);
1081 disable_skip(FALSE
);
1083 retval
= addquotes(string
);
1085 if ( preferences
.transcriptstream
!= BNULL
)
1087 Write(preferences
.transcriptstream
, "Ask String: Result was ", 23);
1088 Write(preferences
.transcriptstream
, retval
, strlen(retval
));
1089 Write(preferences
.transcriptstream
, ".\n\n", 3);
1096 * Ask user to choose one of N items
1098 long int request_choice(struct ParameterList
*pl
)
1101 char **mxlabels
= NULL
;
1106 retval
= GetPL(pl
, _DEFAULT
).intval
;
1108 if ( GetPL(pl
, _CHOICES
).used
== 1 )
1110 max
= GetPL(pl
, _CHOICES
).intval
;
1114 error
= SCRIPTERROR
;
1115 traperr("More than 32 choices given!\n", NULL
);
1118 mxlabels
= malloc((max
+1)*sizeof(STRPTR
));
1121 for ( i
= 0 ; i
< max
; i
++ )
1123 mxlabels
[i
] = strdup(GetPL(pl
, _CHOICES
).arg
[i
]);
1129 error
= SCRIPTERROR
;
1130 traperr("No choices given!\n", NULL
);
1135 if ( get_var_int("@user-level") > _NOVICE
)
1138 BOOL running
= TRUE
;
1139 Object
*levelmx
, *wc
;
1143 out
= collatestrings(GetPL(pl
, _PROMPT
).intval
, GetPL(pl
, _PROMPT
).arg
);
1146 Child
, VGroup
, GroupFrame
,
1147 MUIA_Background
, MUII_GroupBack
,
1149 MUIA_Text_Contents
, (IPTR
)(out
),
1151 Child
, levelmx
= RadioObject
,
1152 MUIA_Radio_Entries
, (IPTR
)(mxlabels
),
1163 switch (DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
1172 if (GetPL(pl
, _HELP
).intval
)
1174 helpwinpl(HELP_ON_ASKCHOICE
, pl
, _HELP
);
1178 helpwin(HELP_ON_ASKCHOICE
, get_var_arg("@asknumber-help"));
1186 GetAttr(MUIA_Radio_Active
, levelmx
, &retval
);
1191 disable_skip(FALSE
);
1193 if ( preferences
.transcriptstream
!= BNULL
)
1195 Write(preferences
.transcriptstream
, "Ask Choice: Result was \"", 24);
1196 Write(preferences
.transcriptstream
, mxlabels
[retval
], strlen(mxlabels
[retval
]));
1197 Write(preferences
.transcriptstream
, "\".\n\n", 4);
1199 for ( i
= 0 ; i
< max
; i
++ )
1210 * Ask user for a directory
1212 char *request_dir(struct ParameterList
*pl
)
1214 char *retval
, *string
;
1216 if ( GetPL(pl
, _DEFAULT
).used
== 0 )
1218 error
= SCRIPTERROR
;
1219 traperr("No default specified!", NULL
);
1221 string
= GetPL(pl
, _DEFAULT
).arg
[0];
1223 /* TODO: write whole function request_dir() */
1225 retval
= addquotes(string
);
1232 * Ask user to insert a specific disk
1234 char *request_disk(struct ParameterList
*pl
)
1236 char *retval
, *string
;
1238 if ( GetPL(pl
, _DEST
).used
== 0 )
1240 error
= SCRIPTERROR
;
1241 traperr("No dest specified!", NULL
);
1243 string
= GetPL(pl
, _DEST
).arg
[0];
1245 /* TODO: write whole function request_disk() */
1247 retval
= addquotes(string
);
1254 * Ask user for a file
1256 char *request_file(struct ParameterList
*pl
)
1258 char *retval
, *string
;
1260 if ( GetPL(pl
, _DEFAULT
).used
== 0 )
1262 error
= SCRIPTERROR
;
1263 traperr("No default specified!", NULL
);
1265 string
= GetPL(pl
, _DEFAULT
).arg
[0];
1267 /* TODO: write whole function request_file() */
1269 retval
= addquotes(string
);
1276 * Ask user for a selection of multiple items (choose m of n items)
1278 long int request_options(struct ParameterList
*pl
)
1281 char **mxlabels
= NULL
;
1290 retval
= GetPL(pl
, _DEFAULT
).intval
;
1292 if ( GetPL(pl
, _CHOICES
).used
== 1 )
1294 max
= GetPL(pl
, _CHOICES
).intval
;
1298 error
= SCRIPTERROR
;
1299 traperr("More than 32 choices given!\n", NULL
);
1302 mxlabels
= malloc((max
+1)*sizeof(STRPTR
));
1305 for ( i
= 0 ; i
< max
; i
++ )
1307 mxlabels
[i
] = strdup(GetPL(pl
, _CHOICES
).arg
[i
]);
1308 marks
[i
] = MUI_MakeObject(MUIO_Checkmark
, (IPTR
)mxlabels
[i
]);
1309 labels
[i
] = LLabel(mxlabels
[i
]);
1311 set(marks
[i
], MUIA_CycleChain
, TRUE
);
1312 if ( (retval
& 1<<i
) != 0 )
1313 set(marks
[i
], MUIA_Selected
, TRUE
);
1319 error
= SCRIPTERROR
;
1320 traperr("No choices given!\n", NULL
);
1325 if ( get_var_int("@user-level") > _NOVICE
)
1328 BOOL running
= TRUE
;
1329 Object
*levelmx
, *wc
;
1333 out
= collatestrings(GetPL(pl
, _PROMPT
).intval
, GetPL(pl
, _PROMPT
).arg
);
1336 Child
, VGroup
, GroupFrame
,
1337 MUIA_Background
, MUII_GroupBack
,
1339 MUIA_Text_Contents
, (IPTR
)(out
),
1341 Child
, levelmx
= ColGroup(2),
1343 MUIA_Background
, MUII_GroupBack
,
1350 for ( i
= 0 ; i
< max
; i
++ )
1352 DoMethod(levelmx
, OM_ADDMEMBER
, (IPTR
)marks
[i
]);
1353 DoMethod(levelmx
, OM_ADDMEMBER
, (IPTR
)labels
[i
]);
1359 switch (DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
1368 if (GetPL(pl
, _HELP
).intval
)
1370 helpwinpl(HELP_ON_ASKCHOICE
, pl
, _HELP
);
1374 helpwin(HELP_ON_ASKCHOICE
, get_var_arg("@asknumber-help"));
1383 for ( i
= 0 ; i
< max
; i
++ )
1385 GetAttr(MUIA_Selected
, marks
[i
], &val
);
1395 disable_skip(FALSE
);
1397 if ( preferences
.transcriptstream
!= BNULL
)
1399 Write(preferences
.transcriptstream
, "Ask Options: Result was \"", 24);
1401 for ( i
= 0 ; i
< max
; i
++ )
1403 if ( (retval
& (1<<i
)) != 0 )
1407 Write(preferences
.transcriptstream
, "\", \"", 4);
1409 Write(preferences
.transcriptstream
, mxlabels
[i
], strlen(mxlabels
[i
]));
1413 Write(preferences
.transcriptstream
, "\".\n\n", 4);
1415 for ( i
= 0 ; i
< max
; i
++ )
1426 * Ask user to confirm
1428 int request_confirm(struct ParameterList
* pl
)
1431 BOOL running
= TRUE
;
1439 if ( get_var_int("@user-level") >= GetPL(pl
, _CONFIRM
).intval
)
1441 out
= collatestrings(GetPL(pl
, _PROMPT
).intval
, GetPL(pl
, _PROMPT
).arg
);
1446 MUIA_Background
, MUII_GroupBack
,
1447 MUIA_Text_Contents
, (IPTR
)(out
),
1457 switch (DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
1470 helpwinpl(HELP_ON_CONFIRM
, pl
, _HELP
);
1488 * Give a short summary on what was done
1493 printf("Application has been installed in %s.\n", get_var_arg("@default-dest"));
1498 void display_text(char * msg
)
1500 BOOL running
= TRUE
;
1507 GroupFrameT(_(MSG_MESSAGE
)),
1508 MUIA_Text_Contents
, (IPTR
)msg
,
1512 Child
, btok
= CoolImageIDButton(_(MSG_OK
), COOL_USEIMAGE_ID
),
1515 set(btok
,MUIA_CycleChain
,1);
1516 DoMethod(btok
, MUIM_Notify
, MUIA_Pressed
, FALSE
,(IPTR
)app
, 2, MUIM_Application_ReturnID
, Push_Ok
);
1517 DoMethod(reqroot
, OM_ADDMEMBER
, (IPTR
)wc
);
1519 set(reqwnd
, MUIA_Window_Open
, TRUE
);
1522 switch (DoMethod(app
,MUIM_Application_NewInput
,(IPTR
)&sigs
))
1532 set(reqwnd
, MUIA_Window_Open
, FALSE
);
1534 DoMethod(reqroot
, OM_REMMEMBER
, (IPTR
)wc
);
1535 MUI_DisposeObject(wc
);