From d6629e2cdb3d29ac633726ab4c38ba3f7271bb3a Mon Sep 17 00:00:00 2001 From: neil Date: Sun, 8 Mar 2015 19:42:29 +0000 Subject: [PATCH] Added a tab for the boot entry's module list. Modules can be added, deleted, enabled and disabled. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@50168 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/prefs/boot/booteditor.c | 652 ++++++++++++++++++++++++++-------- workbench/prefs/boot/booteditor.h | 10 +- workbench/prefs/boot/catalogs/boot.cd | 27 ++ workbench/prefs/boot/main.c | 4 +- 4 files changed, 537 insertions(+), 156 deletions(-) diff --git a/workbench/prefs/boot/booteditor.c b/workbench/prefs/boot/booteditor.c index 2bcfe02469..86285e9c82 100644 --- a/workbench/prefs/boot/booteditor.c +++ b/workbench/prefs/boot/booteditor.c @@ -1,5 +1,5 @@ /* - Copyright © 2013-2014, The AROS Development Team. All rights reserved. + Copyright © 2013-2015, The AROS Development Team. All rights reserved. $Id$ */ @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include @@ -19,6 +21,7 @@ #include #include +#include #include "locale.h" #include "booteditor.h" @@ -37,6 +40,7 @@ static CONST_STRPTR ata_buses_list[5] = {NULL}; static CONST_STRPTR debug_output_list[4] = {NULL}; static CONST_STRPTR gfx_type_list[5] = {NULL}; static CONST_STRPTR vesa_depth_list[4] = {NULL}; +static CONST_STRPTR entry_tabs[3] = {NULL}; struct BootEditor_DATA { @@ -61,17 +65,43 @@ struct BootEditor_DATA *floppy_enable, *debug_output, *debug_mungwall, - *debug_usb; + *debug_usb, + *module_list, + *add_button, + *remove_button, + *module_pop_string, + *module_path, + *module_active; }; +struct module_entry +{ + STRPTR path; + BOOL active; +}; + +static struct Hook module_display_hook; + static BOOL ReadBootArgs(CONST_STRPTR line, struct BootEditor_DATA *data); static BOOL WriteBootArgs(BPTR file, struct BootEditor_DATA *data); +static BOOL ReadModule(CONST_STRPTR line, struct BootEditor_DATA *data); +static BOOL WriteModule(Object *obj, BPTR file, struct module_entry *entry); +AROS_UFP3S(LONG, ModuleDisplayHook, + AROS_UFPA(struct Hook *, hook, A0), + AROS_UFPA(char **, array, A2), + AROS_UFPA(struct module_entry *, entry, A1)); static Object *BootEditor__OM_NEW(Class *CLASS, Object *self, struct opSet *message) { struct BootEditor_DATA temp_data, *data = &temp_data; + module_display_hook.h_Entry = HookEntry; + module_display_hook.h_SubEntry = (HOOKFUNC)ModuleDisplayHook; + + entry_tabs[0] = _(MSG_OPTIONS); + entry_tabs[1] = _(MSG_MODULES); + gfx_type_list[0] = _(MSG_GFX_TYPE_AUTO); gfx_type_list[1] = _(MSG_GFX_TYPE_NATIVE); gfx_type_list[2] = _(MSG_GFX_TYPE_VESA); @@ -95,193 +125,247 @@ static Object *BootEditor__OM_NEW(Class *CLASS, Object *self, MUIA_PrefsEditor_Path, (IPTR)grub_config_path, MUIA_PrefsEditor_CanTest, FALSE, MUIA_PrefsEditor_CanUse, FALSE, - Child, (IPTR)ColGroup(2), - Child, (IPTR)VGroup, - GroupFrameT(_(MSG_GFX)), - Child, (IPTR)ColGroup(2), - Child, (IPTR)Label2(__(MSG_GFX_TYPE)), - Child, (IPTR)(data->gfx_type = (Object *)CycleObject, - MUIA_Cycle_Entries, (IPTR)gfx_type_list, - End), - Child, (IPTR)(data->gfx_composition = - MUI_MakeObject(MUIO_Checkmark, NULL)), - Child, (IPTR)HGroup, - Child, (IPTR)Label2(__(MSG_GFX_COMPOSITION)), - Child, (IPTR)HVSpace, - End, - Child, (IPTR)HVSpace, - Child, (IPTR)HVSpace, - End, - Child, (IPTR)(data->vesa_group = VGroup, - GroupFrameT(_(MSG_GFX_VESAMODE)), - Child, (IPTR)HGroup, - Child, (IPTR)(data->vesa_best_res = + + Child, (IPTR)RegisterGroup(entry_tabs), + + /* Options tab */ + + Child, (IPTR)ColGroup(2), + Child, (IPTR)VGroup, + GroupFrameT(_(MSG_GFX)), + Child, (IPTR)ColGroup(2), + Child, (IPTR)Label2(__(MSG_GFX_TYPE)), + Child, (IPTR)(data->gfx_type = (Object *)CycleObject, + MUIA_Cycle_Entries, (IPTR)gfx_type_list, + End), + Child, (IPTR)(data->gfx_composition = MUI_MakeObject(MUIO_Checkmark, NULL)), - Child, (IPTR)Label2(__(MSG_GFX_BESTRES)), + Child, (IPTR)HGroup, + Child, (IPTR)Label2(__(MSG_GFX_COMPOSITION)), + Child, (IPTR)HVSpace, + End, + Child, (IPTR)HVSpace, Child, (IPTR)HVSpace, End, - Child, (IPTR)ColGroup(2), - Child, (IPTR)Label2(__(MSG_GFX_WIDTH)), + Child, (IPTR)(data->vesa_group = VGroup, + GroupFrameT(_(MSG_GFX_VESAMODE)), Child, (IPTR)HGroup, - Child, (IPTR)(data->vesa_width = - (Object *)StringObject, - StringFrame, - MUIA_CycleChain, 1, - MUIA_String_Accept, (IPTR)accept_nums, - MUIA_FixWidthTxt, (IPTR)"00000", - End), + Child, (IPTR)(data->vesa_best_res = + MUI_MakeObject(MUIO_Checkmark, NULL)), + Child, (IPTR)Label2(__(MSG_GFX_BESTRES)), Child, (IPTR)HVSpace, End, - Child, (IPTR)Label2(__(MSG_GFX_HEIGHT)), - Child, (IPTR)HGroup, - Child, (IPTR)(data->vesa_height = - (Object *)StringObject, - StringFrame, - MUIA_CycleChain, 1, - MUIA_String_Accept, (IPTR)accept_nums, - MUIA_FixWidthTxt, (IPTR)"00000", + Child, (IPTR)ColGroup(2), + Child, (IPTR)Label2(__(MSG_GFX_WIDTH)), + Child, (IPTR)HGroup, + Child, (IPTR)(data->vesa_width = + (Object *)StringObject, + StringFrame, + MUIA_CycleChain, 1, + MUIA_String_Accept, (IPTR)accept_nums, + MUIA_FixWidthTxt, (IPTR)"00000", + End), + Child, (IPTR)HVSpace, + End, + Child, (IPTR)Label2(__(MSG_GFX_HEIGHT)), + Child, (IPTR)HGroup, + Child, (IPTR)(data->vesa_height = + (Object *)StringObject, + StringFrame, + MUIA_CycleChain, 1, + MUIA_String_Accept, (IPTR)accept_nums, + MUIA_FixWidthTxt, (IPTR)"00000", + End), + Child, (IPTR)HVSpace, + End, + Child, (IPTR)Label2(__(MSG_GFX_DEPTH)), + Child, (IPTR)(data->vesa_depth = + (Object *)CycleObject, + MUIA_Cycle_Entries, (IPTR)vesa_depth_list, End), - Child, (IPTR)HVSpace, + Child, (IPTR)Label2(__(MSG_GFX_REFRESH)), + Child, (IPTR)HGroup, + Child, (IPTR)(data->vesa_refresh = + (Object *)StringObject, + StringFrame, + MUIA_CycleChain, 1, + MUIA_String_Accept, (IPTR)accept_nums, + MUIA_FixWidthTxt, (IPTR)"0000", + End), + Child, (IPTR)Label2(__(MSG_GFX_HERTZ)), + Child, (IPTR)HVSpace, + End, End, - Child, (IPTR)Label2(__(MSG_GFX_DEPTH)), - Child, (IPTR)(data->vesa_depth = (Object *)CycleObject, - MUIA_Cycle_Entries, (IPTR)vesa_depth_list, - End), - Child, (IPTR)Label2(__(MSG_GFX_REFRESH)), Child, (IPTR)HGroup, - Child, (IPTR)(data->vesa_refresh = - (Object *)StringObject, - StringFrame, - MUIA_CycleChain, 1, - MUIA_String_Accept, (IPTR)accept_nums, - MUIA_FixWidthTxt, (IPTR)"0000", - End), - Child, (IPTR)Label2(__(MSG_GFX_HERTZ)), + Child, (IPTR)(data->vesa_default_refresh = + MUI_MakeObject(MUIO_Checkmark, NULL)), + Child, (IPTR)Label2(__(MSG_GFX_DEFAULTREFRESH)), Child, (IPTR)HVSpace, End, - End, - Child, (IPTR)HGroup, - Child, (IPTR)(data->vesa_default_refresh = - MUI_MakeObject(MUIO_Checkmark, NULL)), - Child, (IPTR)Label2(__(MSG_GFX_DEFAULTREFRESH)), - Child, (IPTR)HVSpace, - End, - End), - End, - Child, (IPTR)VGroup, + End), + End, Child, (IPTR)VGroup, - GroupFrameT(_(MSG_ATA)), - Child, (IPTR)HGroup, - Child, (IPTR)Label2(__(MSG_ATA_BUSES)), - Child, (IPTR)(data->ata_buses = (Object *)CycleObject, - MUIA_Cycle_Entries, (IPTR)ata_buses_list, - End), - End, - Child, (IPTR)ColGroup(2), - Child, (IPTR)(data->ata_dma = - MUI_MakeObject(MUIO_Checkmark, NULL)), + Child, (IPTR)VGroup, + GroupFrameT(_(MSG_ATA)), Child, (IPTR)HGroup, - Child, (IPTR)Label2(__(MSG_ATA_DMA)), - Child, (IPTR)HVSpace, + Child, (IPTR)Label2(__(MSG_ATA_BUSES)), + Child, (IPTR)(data->ata_buses = + (Object *)CycleObject, + MUIA_Cycle_Entries, (IPTR)ata_buses_list, + End), End, - Child, (IPTR)(data->ata_multi = - MUI_MakeObject(MUIO_Checkmark, NULL)), - Child, (IPTR)HGroup, - Child, (IPTR)Label2(__(MSG_ATA_MULTI)), + Child, (IPTR)ColGroup(2), + Child, (IPTR)(data->ata_dma = + MUI_MakeObject(MUIO_Checkmark, NULL)), + Child, (IPTR)HGroup, + Child, (IPTR)Label2(__(MSG_ATA_DMA)), + Child, (IPTR)HVSpace, + End, + Child, (IPTR)(data->ata_multi = + MUI_MakeObject(MUIO_Checkmark, NULL)), + Child, (IPTR)HGroup, + Child, (IPTR)Label2(__(MSG_ATA_MULTI)), + Child, (IPTR)HVSpace, + End, + Child, (IPTR)(data->ata_32bit = + MUI_MakeObject(MUIO_Checkmark, NULL)), + Child, (IPTR)HGroup, + Child, (IPTR)Label2(__(MSG_ATA_32BIT)), + Child, (IPTR)HVSpace, + End, + Child, (IPTR)(data->ata_poll = + MUI_MakeObject(MUIO_Checkmark, NULL)), + Child, (IPTR)HGroup, + Child, (IPTR)Label2(__(MSG_ATA_POLL)), + Child, (IPTR)HVSpace, + End, Child, (IPTR)HVSpace, - End, - Child, (IPTR)(data->ata_32bit = - MUI_MakeObject(MUIO_Checkmark, NULL)), - Child, (IPTR)HGroup, - Child, (IPTR)Label2(__(MSG_ATA_32BIT)), Child, (IPTR)HVSpace, End, - Child, (IPTR)(data->ata_poll = - MUI_MakeObject(MUIO_Checkmark, NULL)), - Child, (IPTR)HGroup, - Child, (IPTR)Label2(__(MSG_ATA_POLL)), - Child, (IPTR)HVSpace, + End, + Child, (IPTR)VGroup, + GroupFrameT(_(MSG_DEVICE)), + Child, (IPTR)ColGroup(2), + Child, (IPTR)Label2(__(MSG_DEVICE_NAME)), + Child, (IPTR)HGroup, + Child, (IPTR)(data->device_name = + (Object *)StringObject, + StringFrame, + MUIA_CycleChain, 1, + MUIA_String_Reject, (IPTR)":; ", + MUIA_FixWidthTxt, (IPTR)"000000000", + End), + Child, (IPTR)HVSpace, + End, + Child, (IPTR)Label2(__(MSG_DEVICE_DELAY)), + Child, (IPTR)HGroup, + Child, (IPTR)(data->device_delay = + (Object *)StringObject, + StringFrame, + MUIA_CycleChain, 1, + MUIA_String_Accept, (IPTR)accept_nums, + MUIA_FixWidthTxt, (IPTR)"000", + End), + Child, (IPTR)Label2(__(MSG_DEVICE_SECONDS)), + Child, (IPTR)HVSpace, + End, End, + End, + End, + Child, (IPTR)ColGroup(2), + GroupFrameT(_(MSG_MISC)), + Child, (IPTR)(data->usb_enable = + MUI_MakeObject(MUIO_Checkmark, NULL)), + Child, (IPTR)HGroup, + Child, (IPTR)Label2(__(MSG_USB_ENABLE)), + Child, (IPTR)HVSpace, + End, + Child, (IPTR)(data->acpi_enable = + MUI_MakeObject(MUIO_Checkmark, NULL)), + Child, (IPTR)HGroup, + Child, (IPTR)Label2(__(MSG_ACPI_ENABLE)), Child, (IPTR)HVSpace, + End, + Child, (IPTR)(data->floppy_enable = + MUI_MakeObject(MUIO_Checkmark, NULL)), + Child, (IPTR)HGroup, + Child, (IPTR)Label2(__(MSG_FLOPPY_ENABLE)), Child, (IPTR)HVSpace, End, + Child, (IPTR)HVSpace, + Child, (IPTR)HVSpace, End, Child, (IPTR)VGroup, - GroupFrameT(_(MSG_DEVICE)), + GroupFrameT(_(MSG_DEBUG)), + Child, (IPTR)HGroup, + Child, (IPTR)Label2(__(MSG_DEBUG_OUTPUT)), + Child, (IPTR)(data->debug_output = + (Object *)CycleObject, + MUIA_Cycle_Entries, (IPTR)debug_output_list, + End), + End, Child, (IPTR)ColGroup(2), - Child, (IPTR)Label2(__(MSG_DEVICE_NAME)), + Child, (IPTR)(data->debug_mungwall = + MUI_MakeObject(MUIO_Checkmark, NULL)), Child, (IPTR)HGroup, - Child, (IPTR)(data->device_name = - (Object *)StringObject, - StringFrame, - MUIA_CycleChain, 1, - MUIA_String_Reject, (IPTR)":; ", - MUIA_FixWidthTxt, (IPTR)"000000000", - End), + Child, (IPTR)Label2(__(MSG_DEBUG_MUNGWALL)), Child, (IPTR)HVSpace, End, - Child, (IPTR)Label2(__(MSG_DEVICE_DELAY)), + Child, (IPTR)(data->debug_usb = + MUI_MakeObject(MUIO_Checkmark, NULL)), Child, (IPTR)HGroup, - Child, (IPTR)(data->device_delay = - (Object *)StringObject, - StringFrame, - MUIA_CycleChain, 1, - MUIA_String_Accept, (IPTR)accept_nums, - MUIA_FixWidthTxt, (IPTR)"000", - End), - Child, (IPTR)Label2(__(MSG_DEVICE_SECONDS)), + Child, (IPTR)Label2(__(MSG_DEBUG_USB)), Child, (IPTR)HVSpace, End, End, - End, - End, - Child, (IPTR)ColGroup(2), - GroupFrameT(_(MSG_MISC)), - Child, (IPTR)(data->usb_enable = - MUI_MakeObject(MUIO_Checkmark, NULL)), - Child, (IPTR)HGroup, - Child, (IPTR)Label2(__(MSG_USB_ENABLE)), Child, (IPTR)HVSpace, End, - Child, (IPTR)(data->acpi_enable = - MUI_MakeObject(MUIO_Checkmark, NULL)), - Child, (IPTR)HGroup, - Child, (IPTR)Label2(__(MSG_ACPI_ENABLE)), - Child, (IPTR)HVSpace, - End, - Child, (IPTR)(data->floppy_enable = - MUI_MakeObject(MUIO_Checkmark, NULL)), - Child, (IPTR)HGroup, - Child, (IPTR)Label2(__(MSG_FLOPPY_ENABLE)), - Child, (IPTR)HVSpace, - End, - Child, (IPTR)HVSpace, - Child, (IPTR)HVSpace, End, + + /* Modules tab */ + Child, (IPTR)VGroup, - GroupFrameT(_(MSG_DEBUG)), - Child, (IPTR)HGroup, - Child, (IPTR)Label2(__(MSG_DEBUG_OUTPUT)), - Child, (IPTR)(data->debug_output = (Object *)CycleObject, - MUIA_Cycle_Entries, (IPTR)debug_output_list, + Child, (IPTR)ListviewObject, + MUIA_Listview_List, (IPTR)(data->module_list = + (Object *)ListObject, + InputListFrame, + MUIA_List_AutoVisible, TRUE, + MUIA_List_Title, TRUE, + MUIA_List_Format, (IPTR)"P=\033c BAR,", + MUIA_List_DisplayHook, (IPTR)&module_display_hook, End), + MUIA_CycleChain, 1, End, - Child, (IPTR)ColGroup(2), - Child, (IPTR)(data->debug_mungwall = - MUI_MakeObject(MUIO_Checkmark, NULL)), + Child, (IPTR)VGroup, Child, (IPTR)HGroup, - Child, (IPTR)Label2(__(MSG_DEBUG_MUNGWALL)), - Child, (IPTR)HVSpace, + Child, (IPTR)(data->add_button = + SimpleButton(_(MSG_ADD))), + Child, (IPTR)(data->remove_button = + SimpleButton(_(MSG_REMOVE))), End, - Child, (IPTR)(data->debug_usb = - MUI_MakeObject(MUIO_Checkmark, NULL)), Child, (IPTR)HGroup, - Child, (IPTR)Label2(__(MSG_DEBUG_USB)), - Child, (IPTR)HVSpace, + GroupFrame, + Child, (IPTR)Label2(__(MSG_PATH)), + Child, (IPTR)(data->module_pop_string = PopaslObject, + MUIA_Popasl_Type, ASL_FileRequest, + MUIA_Popstring_String, + (IPTR)(data->module_path = + (Object *)StringObject, + StringFrame, + MUIA_Background, MUII_TextBack, + MUIA_CycleChain, 1, + MUIA_Disabled, TRUE, + End), + MUIA_Popstring_Button, + (IPTR)PopButton(MUII_PopFile), + End), + Child, (IPTR)(data->module_active = + MUI_MakeObject(MUIO_Checkmark, NULL)), + Child, (IPTR)Label2(_(MSG_ACTIVE)), End, End, - Child, (IPTR)HVSpace, End, + End, TAG_DONE ); @@ -383,6 +467,17 @@ static Object *BootEditor__OM_NEW(Class *CLASS, Object *self, (IPTR)data->vesa_height, 3, MUIM_Set, MUIA_Disabled, MUIV_TriggerValue); + DoMethod(data->module_list, MUIM_Notify, MUIA_List_Active, + MUIV_EveryTime, (IPTR)self, 1, MUIM_BootEditor_ShowModule); + DoMethod(data->module_path, MUIM_Notify, MUIA_String_Contents, + MUIV_EveryTime, (IPTR)self, 1, MUIM_BootEditor_UpdateModule); + DoMethod(data->module_active, MUIM_Notify, MUIA_Selected, + MUIV_EveryTime, (IPTR)self, 1, MUIM_BootEditor_UpdateModule); + DoMethod(data->add_button, MUIM_Notify, MUIA_Pressed, + TRUE, (IPTR)self, 1, MUIM_BootEditor_AddModule); + DoMethod(data->remove_button, MUIM_Notify, MUIA_Pressed, TRUE, + (IPTR)self, 1, MUIM_BootEditor_RemoveModule); + /* Set default values */ SET(data->gfx_composition, MUIA_Selected, TRUE); @@ -398,6 +493,10 @@ static Object *BootEditor__OM_NEW(Class *CLASS, Object *self, SET(data->usb_enable, MUIA_Selected, TRUE); SET(data->acpi_enable, MUIA_Selected, TRUE); + + SET(data->remove_button, MUIA_Disabled, TRUE); + SET(data->module_active, MUIA_Disabled, TRUE); + SET(data->module_pop_string, MUIA_Disabled, TRUE); } return self; @@ -422,7 +521,7 @@ static IPTR BootEditor__MUIM_PrefsEditor_ImportFH(Class *CLASS, Object *self, struct BootEditor_DATA *data = INST_DATA(CLASS, self); BPTR file; TEXT line_buffer[MAX_LINE_LENGTH], *line; - BOOL success = TRUE, done = FALSE, found = FALSE; + BOOL success = TRUE, done = FALSE; /* Find first AROS boot entry, parse its arguments and put them in * the GUI */ @@ -433,7 +532,7 @@ static IPTR BootEditor__MUIM_PrefsEditor_ImportFH(Class *CLASS, Object *self, if (success) { - while (!done && !found) + while (!done) { line = FGets(file, line_buffer, MAX_LINE_LENGTH); if (line == NULL) @@ -441,10 +540,16 @@ static IPTR BootEditor__MUIM_PrefsEditor_ImportFH(Class *CLASS, Object *self, else if (strstr(line, "multiboot") != NULL && strstr(line, "bootstrap") != NULL) { - found = TRUE; if (!ReadBootArgs(line, data)) success = FALSE; } + else if (strstr(line, "module ") != NULL) + { + if (!ReadModule(line, data)) + success = FALSE; + } + if (strstr(line, "}") != NULL) + done = TRUE; } } @@ -467,6 +572,8 @@ static IPTR BootEditor__MUIM_PrefsEditor_Save(Class *CLASS, Object *self, BPTR old_file, new_file; TEXT line_buffer[MAX_LINE_LENGTH], *line; BOOL success = TRUE, done = FALSE, found = FALSE; + struct module_entry *module; + UWORD i; /* Find first AROS boot entry and replace its arguments with those * chosen in the GUI */ @@ -486,12 +593,38 @@ static IPTR BootEditor__MUIM_PrefsEditor_Save(Class *CLASS, Object *self, else if (!found && strstr(line, "multiboot") != NULL && strstr(line, "bootstrap") != NULL) { - found = TRUE; strstr(line, ".gz")[3] = '\0'; if (FPuts(new_file, line) != 0) success = FALSE; else if (!WriteBootArgs(new_file, data)) success = FALSE; + else + { + /* Skip past all module lines */ + + while (!found) + { + line = FGets(old_file, line_buffer, MAX_LINE_LENGTH); + if (line == NULL) + found = done = TRUE; + else if (strchr(line, '}') != NULL) + found = TRUE; + } + + /* Write new module lines */ + + for (i = 0; success && DoMethod(data->module_list, + MUIM_List_GetEntry, i, &module) != (IPTR)NULL; i++) + { + if (!WriteModule(self, new_file, module)) + success = FALSE; + } + + /* Keep line with closing curly bracket */ + + if (FPuts(new_file, line) != 0) + success = FALSE; + } } else if (FPuts(new_file, line) != 0) @@ -518,6 +651,97 @@ static IPTR BootEditor__MUIM_PrefsEditor_Save(Class *CLASS, Object *self, return success; } +IPTR BootEditor__MUIM_BootEditor_ShowModule(Class *cl, Object *self, + Msg message) +{ + struct BootEditor_DATA *data = INST_DATA(cl, self); + struct module_entry *module; + BOOL show; + + DoMethod(data->module_list, MUIM_List_GetEntry, + MUIV_List_GetEntry_Active, &module); + show = module != NULL; + SET(data->module_pop_string, MUIA_Disabled, !show); + SET(data->module_active, MUIA_Disabled, !show); + NNSET(data->module_path, MUIA_String_Contents, + (IPTR)(show ? module->path : NULL)); + NNSET(data->module_active, MUIA_Selected, show ? module->active : FALSE); + SET(data->remove_button, MUIA_Disabled, !show); + + return 0; +} + +IPTR BootEditor__MUIM_BootEditor_UpdateModule(Class *cl, Object *self, + Msg message) +{ + struct BootEditor_DATA *data = INST_DATA(cl, self); + struct module_entry *module; + + DoMethod(data->module_list, MUIM_List_GetEntry, + MUIV_List_GetEntry_Active, &module); + if (module != NULL) + { + FreeVec(module->path); + module->path = + StrDup((APTR)XGET(data->module_path, MUIA_String_Contents)); + module->active = XGET(data->module_active, MUIA_Selected); + DoMethod(data->module_list, MUIM_List_Redraw, + MUIV_List_Redraw_Active); + } + return 0; +} + +IPTR BootEditor__MUIM_BootEditor_AddModule(Class *cl, Object *self, + Msg message) +{ + struct BootEditor_DATA *data = INST_DATA(cl, self); + struct module_entry *module; + BOOL success = TRUE; + + module = AllocMem(sizeof(struct module_entry), MEMF_CLEAR); + if (module == NULL) + success = FALSE; + + if (success) + { + module->path = StrDup(""); + if (module->path == NULL) + success = FALSE; + module->active = TRUE; + } + + if (success) + { + if (DoMethod(data->module_list, MUIM_List_InsertSingle, module, + MUIV_List_Insert_Bottom) == -1) + success = FALSE; + SET(data->module_list, MUIA_List_Active, MUIV_List_Active_Bottom); + } + + return 0; +} + +IPTR BootEditor__MUIM_BootEditor_RemoveModule(Class *cl, Object *self, + Msg message) +{ + struct BootEditor_DATA *data = INST_DATA(cl, self); + struct module_entry *module; + + /* Remove entry from list and deallocate it */ + + DoMethod(data->module_list, MUIM_List_GetEntry, + MUIV_List_GetEntry_Active, &module); + if (module != NULL) + { + DoMethod(data->module_list, MUIM_List_Remove, + MUIV_List_Remove_Active); + FreeVec(module->path); + FreeMem(module, sizeof(struct module_entry)); + } + + return 0; +} + static BOOL ReadBootArgs(CONST_STRPTR line, struct BootEditor_DATA *data) { UWORD choice, width = 0, height = 0, depth = 0, refresh = 0, delay = 0; @@ -572,6 +796,7 @@ static BOOL ReadBootArgs(CONST_STRPTR line, struct BootEditor_DATA *data) SET(data->vesa_best_res, MUIA_Selected, best_res); /* Check for user-set refresh rate */ + if (*(options - 1) == '@') { while (*options >= '0' && *options <= '9') @@ -674,7 +899,7 @@ static BOOL WriteBootArgs(BPTR file, struct BootEditor_DATA *data) { UWORD count, choice, width, height, depth, delay; BOOL success = TRUE; - CONST_STRPTR name; + CONST_STRPTR name = NULL; /* VESA */ @@ -804,7 +1029,124 @@ static BOOL WriteBootArgs(BPTR file, struct BootEditor_DATA *data) return success; } -ZUNE_CUSTOMCLASS_6 +static BOOL ReadModule(CONST_STRPTR line, struct BootEditor_DATA *data) +{ + BOOL success = TRUE; + STRPTR path, comment; + struct module_entry *entry; + + /* Parse module line */ + + path = strchr(line, '/'); + comment = strchr(line, '#'); + if (path == NULL) + success = FALSE; + + /* Create module entry */ + + if (success) + { + entry = AllocMem(sizeof(struct module_entry), MEMF_CLEAR); + if (entry == NULL) + success = FALSE; + } + + if (success) + { + path[strlen(path) - 1] = '\0'; + entry->path = AllocVec(strlen(path) + 4, MEMF_ANY); + if (entry->path == NULL) + success = FALSE; + } + + if (success) + { + sprintf(entry->path, "SYS:%s", path + 1); + + /* Mark module inactive if there's a comment character before it */ + + entry->active = comment == NULL || comment > path; + } + + /* Add module to list */ + + if (success) + { + if (DoMethod(data->module_list, MUIM_List_InsertSingle, + (IPTR)entry, MUIV_List_Insert_Bottom) == -1) + success = FALSE; + } + + return success; +} + +static BOOL WriteModule(Object *obj, BPTR file, struct module_entry *entry) +{ + BOOL success = TRUE; + TEXT buffer[MAX_LINE_LENGTH], *path = buffer, *p; + BPTR lock, old_dir; + Object *app = NULL, *window = NULL; + + /* Convert path to canonical form */ + + old_dir = CurrentDir(BNULL); + lock = Lock(entry->path, SHARED_LOCK); + if (lock == BNULL) + { + GET(obj, MUIA_ApplicationObject, &app); + GET(obj, MUIA_Window_Window, &window); + + MUI_Request(app, window, 0, "Error", _(MSG_OK), _(MSG_BAD_MODULE), + entry->path); + success = FALSE; + } + + if (success) + { + if (!NameFromLock(lock, buffer, MAX_LINE_LENGTH)) + success = FALSE; + UnLock(lock); + } + + if (success) + { + if ((p = strchr(buffer, ':')) != NULL) + path = p + 1; + + FPrintf(file, " "); + if (!entry->active) + FPrintf(file, "#"); + FPrintf(file, "module /%s\n", path); + } + CurrentDir(old_dir); + + return success; +} + +AROS_UFH3S(LONG, ModuleDisplayHook, + AROS_UFHA(struct Hook *, hook, A0), + AROS_UFHA(char **, array, A2), + AROS_UFHA(struct module_entry *, entry, A1)) +{ + AROS_USERFUNC_INIT + + if (entry != NULL) + { + *array++ = entry->active ? "*" : ""; + *array = entry->path; + } + else + { + *array++ = (STRPTR)_(MSG_ACTIVE); + *array = (STRPTR)_(MSG_PATH); + } + + return 0; + + AROS_USERFUNC_EXIT +} + +ZUNE_CUSTOMCLASS_10 ( BootEditor, NULL, MUIC_PrefsEditor, NULL, OM_NEW, struct opSet *, @@ -812,5 +1154,9 @@ ZUNE_CUSTOMCLASS_6 MUIM_Cleanup, Msg, MUIM_PrefsEditor_ImportFH, struct MUIP_PrefsEditor_ImportFH *, MUIM_PrefsEditor_ExportFH, struct MUIP_PrefsEditor_ExportFH *, - MUIM_PrefsEditor_Save, Msg + MUIM_PrefsEditor_Save, Msg, + MUIM_BootEditor_ShowModule, Msg, + MUIM_BootEditor_UpdateModule, Msg, + MUIM_BootEditor_AddModule, Msg, + MUIM_BootEditor_RemoveModule, Msg ); diff --git a/workbench/prefs/boot/booteditor.h b/workbench/prefs/boot/booteditor.h index d92b33e837..6b61ec9c19 100644 --- a/workbench/prefs/boot/booteditor.h +++ b/workbench/prefs/boot/booteditor.h @@ -2,17 +2,25 @@ #define _BOOTEDITOR_H_ /* - Copyright © 2009-2013, The AROS Development Team. All rights reserved. + Copyright © 2009-2015, The AROS Development Team. All rights reserved. $Id$ */ #include #include +/*** Identifier base ********************************************************/ +#define MUIB_BootEditor (MUIB_PrefsEditor + 0x100) + /*** Variables **************************************************************/ extern struct MUI_CustomClass *BootEditor_CLASS; /*** Macros *****************************************************************/ #define BootEditorObject BOOPSIOBJMACRO_START(BootEditor_CLASS->mcc_Class) +#define MUIM_BootEditor_ShowModule (MUIB_BootEditor + 1) +#define MUIM_BootEditor_UpdateModule (MUIB_BootEditor + 2) +#define MUIM_BootEditor_AddModule (MUIB_BootEditor + 3) +#define MUIM_BootEditor_RemoveModule (MUIB_BootEditor + 4) + #endif /* _BOOTEDITOR_H_ */ diff --git a/workbench/prefs/boot/catalogs/boot.cd b/workbench/prefs/boot/catalogs/boot.cd index 7991e25f1a..c6e54e7356 100644 --- a/workbench/prefs/boot/catalogs/boot.cd +++ b/workbench/prefs/boot/catalogs/boot.cd @@ -139,3 +139,30 @@ seconds MSG_DEVICE_DEFAULTDELAY (//) Use Default Boot Delay ; +MSG_OPTIONS (//) +Options +; +MSG_MODULES (//) +Modules +; +MSG_ACTIVE (//) +Active +; +MSG_PATH (//) +Path +; +MSG_ADD (//) +Add +; +MSG_REMOVE (//) +Remove +; +MSG_OK (//) +OK +; +MSG_CANCEL (//) +Cancel +; +MSG_BAD_MODULE (//) +Bad module path "%s" +; diff --git a/workbench/prefs/boot/main.c b/workbench/prefs/boot/main.c index dbee17e886..3dde08d809 100644 --- a/workbench/prefs/boot/main.c +++ b/workbench/prefs/boot/main.c @@ -1,5 +1,5 @@ /* - Copyright © 2009-2014, The AROS Development Team. All rights reserved. + Copyright © 2009-2015, The AROS Development Team. All rights reserved. $Id$ */ @@ -16,7 +16,7 @@ #include "args.h" #include "booteditor.h" -#define VERSION "$VER: Boot 1.2 (21.2.2013)" +#define VERSION "$VER: Boot 1.3 (8.3.2014)" int main(int argc, char **argv) { -- 2.11.4.GIT