GitLab has been upgraded to 13.11.3 If you encounter any issues mail code@riscosopen.org

Commit 4921e5df authored by Richard Buckley's avatar Richard Buckley
Browse files

This commit was generated by cvs2git to track changes on a CVS vendor branch.

parents a12ff145 f1257c91
......@@ -56,12 +56,15 @@ int iconbar_id = 0; /* object ids */
int menu_iconbar_id = 0;
int menu_option_id = 0;
int menu_view_id = 0;
int menu_version_id = 0;
int window_options_id = 0;
int window_build_id = 0;
int proginfo_id = 0;
char *build_tree = NULL;
char *default_env = NULL;
build_list_t *build_list = NULL;
int used_default_options = FALSE;
int version_type = 0;
/*
* clean up before exit
......@@ -193,7 +196,6 @@ read_defaults(void)
if ((fh=fopen(DEFAULTS_FILE,"r"))==NULL)
return 0;
debug db_printf("read_defaults\n");
while (!feof(fh)) {
fgets(buffer,sizeof(buffer),fh);
if (!feof(fh)) {
......@@ -208,12 +210,19 @@ read_defaults(void)
} else if (cstrcmp(argv[0],"opt")==0) {
for (i=1; i<argc; i++) {
for (j=0; j<(sizeof(options)/sizeof(option_t)); j++) {
options[j].def = 0;
if (strcmp(options[j].name,argv[i])==0) {
options[j].def = 1;
break;
}
}
}
} else if (cstrcmp(argv[0],"ver")==0) {
for (version_type=0; version_type<(sizeof(versioning)/sizeof(version_t)); version_type++) {
if (strcmp(versioning[version_type].msg,argv[1])==0) {
break;
}
}
}
}
}
......@@ -324,6 +333,7 @@ write_defaults(void)
ERR_CHECK_RETURN(err,stringset_get_selected(0,window_options_id,
OPTIONS_GADGET_ENV,buffer,sizeof(buffer),&i));
fprintf(fh,"env %s\n",buffer);
fprintf(fh,"ver %s\n",versioning[version_type].msg);
fclose(fh);
return 0;
......@@ -357,6 +367,8 @@ attach_other_handlers(int event_code,ToolboxEvent *event,
menu_view_id = id_block->self_id;
} else if (strcmp(template_name, WINDOW_BUILDS_NAME) ==0) {
window_build_id = id_block->self_id;
} else if (strcmp(template_name, MENU_VERSION_NAME) ==0) {
menu_version_id = id_block->self_id;
}
return 0;
}
......@@ -365,7 +377,7 @@ attach_other_handlers(int event_code,ToolboxEvent *event,
* Enter the correct version string into window
*/
int
initialise_proginfo(int event_code,ToolboxEvent *event,
proginfo_show(int event_code,ToolboxEvent *event,
IdBlock *id_block, void *handle)
{
proginfo_set_version(0,id_block->self_id,APP_VERSION);
......@@ -391,13 +403,22 @@ window_show(int event_code,ToolboxEvent *event,
ERR_CHECK_RETURN(err,
env_populate(window_options_id,OPTIONS_GADGET_ENV,default_env));
}
/* sort out default rom build options */
for (i=0; i<(sizeof(options)/sizeof(option_t)); i++) {
if (options[i].def) {
ERR_CHECK_RETURN(err,optionbutton_set_state(0,window_options_id,
if (!used_default_options) {
/* sort out default rom build options */
for (i=0; i<(sizeof(options)/sizeof(option_t)); i++) {
if (options[i].def) {
ERR_CHECK_RETURN(err,optionbutton_set_state(0,window_options_id,
options[i].id,1));
} else {
ERR_CHECK_RETURN(err,optionbutton_set_state(0,window_options_id,
options[i].id,0));
}
}
ERR_CHECK_RETURN(err,displayfield_set_value(0,window_options_id,
OPTIONS_GADGET_VERSION,msg_lookup(versioning[version_type].msg)));
used_default_options = TRUE;
}
} else if (id_block->self_id == window_build_id) {
/* populate list of build trees */
......@@ -405,6 +426,29 @@ window_show(int event_code,ToolboxEvent *event,
}
return 0;
}
/*
* deal with the menu about to be displayed
*/
int
menu_show(int event_code,ToolboxEvent *event,
IdBlock *id_block, void *handle)
{
_kernel_oserror *err=NULL;
int i;
if (id_block->self_id == menu_version_id) {
for (i=0; i<(sizeof(versioning)/sizeof(version_t)); i++) {
if (version_type == i) {
ERR_CHECK_RETURN(err,menu_set_tick(0,menu_version_id,
versioning[i].id,1));
} else {
ERR_CHECK_RETURN(err,menu_set_tick(0,menu_version_id,
versioning[i].id,0));
}
}
}
return 0;
}
/*
* populate string set prior to it being shown
......@@ -475,7 +519,7 @@ int action_click(int event_code,ToolboxEvent *event,
if (id_block->self_id == window_options_id)
{
char cmd[1024];
char cmd[BUFFER_SIZE];
int state;
switch (id_block->self_component)
......@@ -486,6 +530,8 @@ int action_click(int event_code,ToolboxEvent *event,
}
strcpy(cmd,BUILD_FILE);
strcat(cmd," ");
strcat(cmd,versioning[version_type].action);
for (i=0; i<(sizeof(options)/sizeof(option_t)); i++) {
ERR_CHECK_RETURN(err,optionbutton_get_state(0,window_options_id,
options[i].id,&state));
......@@ -494,6 +540,7 @@ int action_click(int event_code,ToolboxEvent *event,
strcat(cmd,options[i].name);
}
}
debug db_printf("cmd = '%s'\n",cmd);
reg.r[0] = (int)cmd;
ERR_CHECK_RETURN(err,_kernel_swi(Wimp_StartTask,&reg,&reg));
......@@ -551,6 +598,21 @@ iconbar_click(int event_code,ToolboxEvent *event,
return 0;
}
/*
* deal with key presses
*/
int
key_pressed(int event_code, WimpPollBlock *event,
IdBlock *id_block, void *handle)
{
_kernel_oserror *err = NULL;
WimpKeyPressedEvent *key_block = (WimpKeyPressedEvent *)event;
ERR_CHECK_RETURN(err,wimp_process_key(key_block->key_code));
return 0;
}
/*
* deal with clicks on the menus
*/
......@@ -593,6 +655,21 @@ menu_selection(int event_code,ToolboxEvent *event,
ERR_CHECK_RETURN(err,_kernel_swi(OS_CLI,&reg,&reg));
break;
}
} else if (id_block->self_id == menu_version_id) {
/* untick previous one */
ERR_CHECK_RETURN(err,menu_set_tick(0,menu_version_id,
versioning[version_type].id,0));
for (version_type=0; version_type<(sizeof(versioning)/sizeof(version_t));
version_type++) {
if (id_block->self_component == versioning[version_type].id) {
break;
}
}
ERR_CHECK_RETURN(err,menu_set_tick(0,menu_version_id,
versioning[version_type].id,1));
ERR_CHECK_RETURN(err,displayfield_set_value(0,window_options_id,
OPTIONS_GADGET_VERSION,msg_lookup(versioning[version_type].msg)));
}
return (0);
......@@ -635,15 +712,21 @@ int main()
ERR_GOTO(err,event_register_message_handler(Wimp_MDataLoad,
message_data_open,NULL));
/* Event handler */
ERR_GOTO(err,event_register_wimp_handler(-1,Wimp_EKeyPressed,
key_pressed,NULL));
/* Menu event handlers */
ERR_GOTO(err,event_register_toolbox_handler(-1,MENU_EVENT_QUIT,
event_quit,NULL));
ERR_GOTO(err,event_register_toolbox_handler(-1,Menu_Selection,
menu_selection,NULL));
ERR_GOTO(err,event_register_toolbox_handler(-1,Menu_AboutToBeShown,
menu_show,NULL));
/* Window event handlers */
ERR_GOTO(err,event_register_toolbox_handler(-1,ProgInfo_AboutToBeShown,
initialise_proginfo,NULL));
proginfo_show,NULL));
ERR_GOTO(err,event_register_toolbox_handler(-1,Window_AboutToBeShown,
window_show,NULL));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment