// Edit a filetype definition void filetypeed_edit_definition(filetype_ed_data *data) { fileclass_ed_data *startup; BOOL success=0; // Allocate startup data if (!(startup=AllocVec(sizeof(fileclass_ed_data),MEMF_CLEAR)) || !(startup->type=CopyFiletype(data->type,0))) { FreeVec(startup); return; } // Supply IPC ports startup->owner_ipc=data->ipc; startup->main_owner=data->func_startup.main_owner; // Supply some library pointers /*startup->dopus_base=DOpusBase; startup->dos_base=(struct Library *)DOSBase; startup->int_base=(struct Library *)IntuitionBase; startup->gfx_base=(struct Library *)GfxBase; startup->asl_base=AslBase;*/ // Fill out new window startup->new_win.parent=data->window; startup->new_win.dims=data->class_win; startup->new_win.title=data->type->type.name; startup->new_win.locale=Locale; startup->new_win.flags=WINDOW_VISITOR|WINDOW_REQ_FILL|WINDOW_AUTO_KEYS; // Supply object pointers startup->obj_def=data->class_obj; startup->lookup=data->class_lookup; startup->strings=data->class_strings; // Initialise reader list NewList((struct List *)&startup->readers); // Launch editor if ((IPC_Launch( &data->proc_list, &data->class_editor, "dopus_class_editor", (ULONG)IPC_NATIVE(FileclassEditor), STACK_DEFAULT, (ULONG)startup, (struct Library *)DOSBase)) && data->class_editor) success=1; // Free data if not successful if (!success) { FreeFiletype(startup->type); FreeVec(startup); } }
// Edit a filetype action void filetypeed_edit_action( filetype_ed_data *data, short action, char *name) { Cfg_Function *function; FunctionStartup *startup; BOOL success=0; // Allocate startup data if (!(startup=AllocVec(sizeof(FunctionStartup),MEMF_CLEAR))) return; // Find the function we want to edit if (!(function=FindFunctionType(&data->type->function_list,action))) { // Allocate a new function function=NewFunction(0,action); } // Otherwise, copy the function else function=CopyFunction(function,0,0); // Valid function? if (function) { // Copy startup data *startup=data->func_startup; startup->window=data->window; startup->function=function; startup->owner_ipc=data->ipc; startup->object=data->type; startup->object_flags=action; // Build title lsprintf(startup->title,"%s : %s",data->type->type.name,name); // Launch editor if ((IPC_Launch( &data->proc_list, &data->editor[action], "dopus_function_editor", (ULONG)IPC_NATIVE(FunctionEditor), STACK_DEFAULT, (ULONG)startup, (struct Library *)DOSBase)) && data->editor[action]) success=1; } // Free data if not successful if (!success) { FreeFunction(function); FreeVec(startup); } }
// Open a group void backdrop_open_group(BackdropInfo *info,BackdropObject *object,BOOL activate) { GroupData *group; IPCData *ipc=0; // Valid object? if (!object || !object->icon || object->icon->do_Type!=WBDRAWER) return; // See if it's already open lock_listlock(&GUI->group_list,0); if (group=backdrop_find_group(object)) { // Send activate message if (activate) IPC_Command(group->ipc,IPC_ACTIVATE,0,0,0,0); } unlock_listlock(&GUI->group_list); // If it was open, return if (group) return; // Allocate group packet if (!(group=AllocVec(sizeof(GroupData),MEMF_CLEAR))) return; // Fill in group packet group->screen=info->window->WScreen; if (object->icon->do_DrawerData) group->dimensions=*((struct IBox *)&object->icon->do_DrawerData->dd_NewWindow.LeftEdge); else { group->dimensions.Left=20; group->dimensions.Top=20; group->dimensions.Width=200; group->dimensions.Height=150; } strcpy(group->name,object->name); group->object=object; // Initialise popup menu if (group->popup=PopUpNewHandle(0,0,&locale)) { // Add items PopUpNewItem(group->popup,MSG_ICON_SNAPSHOT_MENU,MENU_ICON_SNAPSHOT_WINDOW,0); PopUpNewItem(group->popup,MSG_ICON_CLEANUP,MENU_ICON_CLEANUP,0); } // Launch process IPC_Launch( &GUI->group_list, &ipc, "dopus_group", (ULONG)backdrop_group_handler, STACK_DEFAULT, (ULONG)group,(struct Library *)DOSBase); // Failed? if (!ipc) { // Free PopUpFreeHandle(group->popup); FreeVec(group); } }
Cfg_Filetype *LIBFUNC L_EditFiletype( REG(a0, Cfg_Filetype *type), REG(a1, struct Window *window), REG(a2, IPCData *ipc), REG(a3, IPCData *dopus_ipc), REG(d0, ULONG flags)) { filetype_ed_data *data; IPCData *editor; IPCMessage *imsg; Cfg_Filetype *ret_type=0; // Valid filetype? if (!type) return 0; // Allocate data for the editor, copy filetype if (!(data=AllocVec(sizeof(filetype_ed_data),MEMF_CLEAR)) || !(data->type=CopyFiletype(type,0))) { FreeVec(data); return 0; } // Fill out data data->owner_ipc=ipc; data->action_lookup=filetype_action_lookup; // Supply libraries /*data->func_startup.dopus_base=DOpusBase; data->func_startup.dos_base=(struct Library *)DOSBase; data->func_startup.int_base=(struct Library *)IntuitionBase; data->func_startup.util_base=(struct Library *)UtilityBase; data->func_startup.cx_base=CxBase; data->func_startup.wb_base=WorkbenchBase; data->func_startup.gfx_base=(struct Library *)GfxBase; data->func_startup.asl_base=AslBase; data->func_startup.layers_base=LayersBase;*/ // Supply locale data->func_startup.locale=locale; // Supply gui data pointers data->new_win.parent=window; data->new_win.dims=&_filetype_editor_window; data->new_win.locale=locale; data->obj_def=_filetype_editor_objects; // Supply data pointers for function editor data->func_startup.win_def=&_function_editor_window; data->func_startup.obj_def=_function_editor_objects; data->func_startup.func_labels=_function_type_labels; data->func_startup.flag_list=_funced_flaglist; data->func_startup.func_list=IPC_Command(dopus_ipc,MAINCMD_GET_LIST,0,0,0,REPLY_NO_PORT); data->func_startup.flags=FUNCEDF_NO_KEY; data->func_startup.main_owner=ipc; // Supply data pointers for the fileclass editor data->class_win=&_fileclass_editor_window; data->class_obj=_fileclass_editor_objects; data->class_lookup=fileclass_match_lookup; data->class_strings=matchtype_labels; // Open class editor automatically? if (flags&EFTF_EDIT_CLASS) data->edit_flag=1; // Launch editor if (!(IPC_Launch( 0, &editor, "dopus_filetype_editor", (ULONG)IPC_NATIVE(FiletypeEditor), STACK_DEFAULT, (ULONG)data, (struct Library *)DOSBase)) || !editor) { // Failed; free data FreeFiletype(data->type); FreeVec(data); return 0; } // Event loop FOREVER { BOOL quit=0; // IPC messages while ((imsg=(IPCMessage *)GetMsg(ipc->command_port))) { // Filetype returned? if (imsg->command==FILETYPEEDIT_RETURN) { // Copy the filetype ret_type=CopyFiletype((Cfg_Filetype *)imsg->flags,0); } // Said goodbye? else if (imsg->command==IPC_GOODBYE && imsg->data==editor) quit=1; // Abort? else if (imsg->command==IPC_QUIT) { // Send abort message IPC_Quit(editor,imsg->flags,TRUE); } // Activate? else if (imsg->command==IPC_ACTIVATE) { // Send message IPC_Command(editor,IPC_ACTIVATE,imsg->flags,imsg->data,0,0); } // Identify? else if (imsg->command==IPC_IDENTIFY) { // Pass to DOpus IPC_Command(dopus_ipc,IPC_IDENTIFY,imsg->flags,imsg->data,0,REPLY_NO_PORT); } // Reply to message IPC_Reply(imsg); } // Check quit flag if (quit) break; // Wait for message WaitPort(ipc->command_port); } // Return new filetype (if any) return ret_type; }
// Show help on something void help_show_help(char *thing,char *file) { IPCData *ipc; char *copy,*ptr,helpbuf[256]; CommandList *cmd; // Valid thing? if (!thing || !*thing) return; // Can't do help if we don't have the amigaguide.library if (!AmigaGuideBase) { // Flash error and return DisplayBeep(GUI->screen_pointer); return; } // Is the node name a command? ptr=thing; if (!file && (cmd=function_find_internal(&ptr,0))) { // Is this an external module that has help available? if (cmd->flags&FUNCF_EXTERNAL_FUNCTION && cmd->help_name) { // Build full path to help file strcpy(helpbuf,"dopus5:help/"); AddPart(helpbuf,FilePart(cmd->help_name),256); // Use this file for help file=helpbuf; } } // Lock process list lock_listlock(&GUI->process_list,FALSE); // Is help process running? if (!(ipc=IPC_FindProc(&GUI->process_list,"dopus_help",0,0))) { // Unlock process list unlock_listlock(&GUI->process_list); // Launch help process if (!(IPC_Launch( &GUI->process_list, &ipc, "dopus_help", (ULONG)&help_proc, STACK_DEFAULT, 0, (struct Library *)DOSBase))) { // Couldn't launch it return; } // Lock process list lock_listlock(&GUI->process_list,FALSE); } // No file given? if (!file || !*file) file="dopus5:Help/dopus5.guide"; // Copy thing if (ipc && (copy=AllocVec(strlen(thing)+1+strlen(file)+1,0))) { // Copy thing and file string strcpy(copy,thing); strcpy(copy+strlen(copy)+1,file); // Send help command IPC_Command(ipc,HELPCMD_LINK,0,0,copy,0); } // Unlock process list unlock_listlock(&GUI->process_list); }
// Edit a filetype void filetype_edit( config_filetypes_data *data, FiletypeNode *node, short edit_flag) { filetype_ed_data *eddata; // Valid node? if (!node) return; // Check editor is not already up for this node if (node->editor) { // Send activate message IPC_Command(node->editor,IPC_ACTIVATE,0,0,0,0); return; } // Allocate data for the editor if (!(eddata=AllocVec(sizeof(filetype_ed_data),MEMF_CLEAR))) return; // Try to copy filetype if (!(eddata->type=CopyFiletype(node->type,0))) { FreeVec(eddata); return; } // Fill out data eddata->owner_ipc=data->ipc; eddata->node=node; eddata->action_lookup=filetype_action_lookup; // Supply libraries /*eddata->func_startup.dopus_base=DOpusBase; eddata->func_startup.dos_base=(struct Library *)DOSBase; eddata->func_startup.int_base=(struct Library *)IntuitionBase; eddata->func_startup.util_base=(struct Library *)UtilityBase; eddata->func_startup.cx_base=CxBase; eddata->func_startup.wb_base=WorkbenchBase; eddata->func_startup.gfx_base=(struct Library *)GfxBase; eddata->func_startup.asl_base=AslBase; eddata->func_startup.layers_base=LayersBase;*/ // Supply locale eddata->func_startup.locale=locale; // Supply gui data pointers eddata->new_win.parent=data->window; eddata->new_win.dims=&_filetype_editor_window; eddata->new_win.locale=locale; eddata->obj_def=_filetype_editor_objects; // Supply data pointers for function editor eddata->func_startup.win_def=&_function_editor_window; eddata->func_startup.obj_def=_function_editor_objects; eddata->func_startup.func_labels=_function_type_labels; eddata->func_startup.flag_list=_funced_flaglist; eddata->func_startup.func_list=data->command_list; eddata->func_startup.flags=FUNCEDF_NO_KEY; eddata->func_startup.main_owner=data->owner_ipc; // Supply data pointers for the fileclass editor eddata->class_win=&_fileclass_editor_window; eddata->class_obj=_fileclass_editor_objects; eddata->class_lookup=fileclass_match_lookup; eddata->class_strings=matchtype_labels; eddata->edit_flag=edit_flag; // Launch editor if (!(IPC_Launch( &data->proc_list, &node->editor, "dopus_filetype_editor", (ULONG)IPC_NATIVE(FiletypeEditor), STACK_DEFAULT, (ULONG)eddata, (struct Library *)DOSBase)) || !node->editor) { // Failed; free data FreeFiletype(eddata->type); FreeVec(eddata); } }