// Add an entry to the OpenWith file void add_open_with(char *line) { APTR file; struct Node *node; // Lock list lock_listlock(&GUI->open_with_list,1); // Too many nodes? if (Att_NodeCount((Att_List *)&GUI->open_with_list)>=environment->env->settings.max_openwith) { // List is empty? if (IsListEmpty((struct List *)&GUI->open_with_list.list)) return; // Get first node node=GUI->open_with_list.list.lh_Head; // Remove first node and free it RemHead((struct List *)&GUI->open_with_list); FreeMemH(node); } // Allocate a new node if (node=AllocMemH(global_memory_pool,sizeof(struct Node)+strlen(line)+1)) { // Initialise node and copy string node->ln_Name=(char *)(node+1); strcpy(node->ln_Name,line); // Add to Open With list AddTail((struct List *)&GUI->open_with_list,node); } // Open file for output if (file=OpenBuf("DOpus5:System/OpenWith",MODE_NEWFILE,4000)) { // Write lines for (node=GUI->open_with_list.list.lh_Head;node->ln_Succ;node=node->ln_Succ) { // Write line WriteBuf(file,node->ln_Name,strlen(node->ln_Name)); WriteBuf(file,"\n",1); } // Close file CloseBuf(file); } // Unlock list unlock_listlock(&GUI->open_with_list); }
// Save theme file long save_theme(struct Screen *screen,DOpusCallbackInfo *info,char *filename,BOOL build) { APTR file; APTR progress=0; char build_path[300]; struct MsgPort *reply_port; struct GetPointerPkt pkt; Att_List *list; long res=0; short a; // Building theme? if (build) { BPTR lock; short len; long count; // Copy filename to get path strcpy(build_path,filename); if ((len=strlen(build_path))>6 && stricmp(build_path+len-6,".theme")==0) build_path[len-6]=0; else strcat(build_path,".dir"); // Create theme directory if ((lock=CreateDir(build_path)) || IoErr()==ERROR_OBJECT_EXISTS) UnLock(lock); else return 0; // Get file count count=3; pkt.gpp_Type=MODPTR_SCRIPTS; pkt.gpp_Ptr=0; if ((list=(APTR)DC_CALL1(info, dc_GetPointer, DC_REGA0, &pkt))) //if ((list=DC_GetPointer(info,&pkt))) //if ((list=info->dc_GetPointer(&pkt))) { count+=Att_NodeCount(list); DC_CALL1(info, dc_FreePointer, DC_REGA0, &pkt); //DC_FreePointer(info,&pkt); //info->dc_FreePointer(&pkt); } // Open progress indicator progress=OpenProgressWindowTags( PW_Screen,(IPTR)screen, PW_Title,(IPTR)"Directory Opus Themes", PW_Info,(IPTR)GetString(locale,MSG_BUILDING_THEME), PW_Flags,PWF_INFO|PWF_GRAPH, PW_FileCount,count, PW_FileNum,0, TAG_END); } else build_path[0]=0; // Open output file if (!(file=OpenBuf(filename,MODE_NEWFILE,4096))) { CloseProgressWindow(progress); return 0; } // Create a reply port reply_port=CreateMsgPort(); // Write file introduction write_theme_intro(file,filename); // Background pictures WriteBuf(file, "/* Set background pictures */\n", -1); WriteBuf(file, "if index( apply_flags , \"B\") ~= 0 then do\n", -1); WriteBuf(file, "\tdopus set background on\n", -1); if (!save_theme_background(file,info,"desktop",reply_port,build_path,progress) || !save_theme_background(file,info,"lister",reply_port,build_path,progress) || !save_theme_background(file,info,"req",reply_port,build_path,progress)) { res=IoErr(); CloseBuf(file); CloseProgressWindow(progress); return res; } WriteBuf(file, "end\n\n",-1); // Sounds WriteBuf(file, "/* Set sound events */\n", -1); WriteBuf(file, "if index( apply_flags , \"S\") ~= 0 then do\n", -1); // Get script list (for sounds) pkt.gpp_Type=MODPTR_SCRIPTS; pkt.gpp_Ptr=0; if ((list=(APTR)DC_CALL1(info, dc_GetPointer, DC_REGA0, &pkt))) //if ((list=DC_GetPointer(info,&pkt))) //if ((list=info->dc_GetPointer(&pkt))) { Att_Node *node; // Go through scripts, find sounds for (node=(Att_Node *)list->list.lh_Head;node->node.ln_Succ;node=(Att_Node *)node->node.ln_Succ) { // No sound? if (node->data&(1<<1)) { if (progress) SetProgressWindowTags(progress,PW_FileInc,1,TAG_END); continue; } // Save the sound if (!save_theme_sound(file,info,node->node.ln_Name,reply_port,build_path,progress)) break; } // Failed? if (node->node.ln_Succ) res=IoErr(); // Free list DC_CALL1(info, dc_FreePointer, DC_REGA0, &pkt); //DC_FreePointer(info,&pkt); //info->dc_FreePointer(&pkt); // Failed? if (res) { CloseBuf(file); CloseProgressWindow(progress); return res; } } WriteBuf(file, "end\n\n",-1); // Fonts WriteBuf(file, "/* Set fonts */\n", -1); WriteBuf(file, "if index( apply_flags , \"F\") ~= 0 then do\n", -1); if (!save_theme_font(file,info,"screen",reply_port) || !save_theme_font(file,info,"listers",reply_port) || !save_theme_font(file,info,"iconsd",reply_port) || !save_theme_font(file,info,"iconsw",reply_port)) { res=IoErr(); CloseBuf(file); CloseProgressWindow(progress); return res; } WriteBuf(file, "end\n\n",-1); // Colour settings WriteBuf(file, "/* Set colour settings*/\n",-1); WriteBuf(file, "if index( apply_flags , \"P\") ~= 0 then do\n", -1); for (a=0;pen_settings[a];a++) { if (!save_theme_pens(file,info,pen_settings[a],reply_port)) break; } if (pen_settings[a] || !(save_theme_palette(file,info,reply_port))) { // Failure res=IoErr(); CloseBuf(file); CloseProgressWindow(progress); return res; } WriteBuf(file, "end\n\n",-1); // Write file outroduction write_theme_outro(file); // Close file CloseBuf(file); CloseProgressWindow(progress); return res; }