#include #include #include #include #include #include #include struct IntuitionBase*IntuitionBase; struct App {char*title,*path;}; static struct App apps[]={ {"Amber Chrono","SYS:Utilities/AmberChrono/Chrono"},{"Boing 3D","SYS:Utilities/Boing3D/Boing3D"},{"Matrix |","SYS:Utilities/Matrix/Matrix"},{"RetroIRC","SYS:Utilities/RetroIRC/RetroIRC"},{"RetroTerm","SYS:Utilities/RetroTerm/RetroTerm"},{"Boing!","SYS:Utilities/Boing/Boing"},{"System Monitor","SYS:Utilities/AmberMonitor/Monitor"},{"Tech News","SYS:Utilities/NewsTicker/News"},{"MOD Player","SYS:Utilities/AmberMod/ModPlayer"}}; #define APPS (sizeof(apps)/sizeof(apps[0])) struct Entry {int app,x,y,w,h;};static struct Entry entries[APPS];static struct Window*found[APPS]; static int identify(struct Window*w){int i;if(!w->Title)return -1;for(i=0;iTitle,apps[i].title,strlen(apps[i].title)))return i;return -1;} int main(int argc,char**argv){struct Screen*sc;struct Window*w;ULONG lock;FILE*f;int n=0,i,j,id,pass,restoring=argc>1&&!strcmp(argv[1],"RESTORE");IntuitionBase=(struct IntuitionBase*)OpenLibrary("intuition.library",39);if(!IntuitionBase)return 20;sc=LockPubScreen(0);if(!sc){CloseLibrary((struct Library*)IntuitionBase);return 20;} if(!restoring){lock=LockIBase(0);for(w=sc->FirstWindow;w&&nNextWindow){id=identify(w);if(id<0)continue;for(i=0;iLeftEdge;entries[n].y=w->TopEdge;entries[n].w=w->Width;entries[n++].h=w->Height;}UnlockIBase(lock); if(!n)goto end;f=fopen("SYS:Prefs/AmigaSession.layout","w");if(!f)goto end;for(i=0;i=0;i--)fprintf(f,"Run >NIL: %s\n",apps[entries[i].app].path);fprintf(f,"Run >NIL: C:AmigaSession RESTORE\n");fclose(f);} }else{f=fopen("SYS:Prefs/AmigaSession.layout","r");if(!f)goto end;while(n=0&&entries[n].appFirstWindow;w;w=w->NextWindow)if(identify(w)==entries[i].app)break;UnlockIBase(lock);if(!w)continue;ChangeWindowBox(w,entries[i].x,entries[i].y,entries[i].w,entries[i].h);found[i]=w;}for(i=0;i=0;i--){lock=LockIBase(0);for(w=sc->FirstWindow;w;w=w->NextWindow)if(identify(w)==entries[i].app)break;UnlockIBase(lock);if(w){ChangeWindowBox(w,entries[i].x,entries[i].y,entries[i].w,entries[i].h);WindowToFront(w);}} } end:UnlockPubScreen(0,sc);CloseLibrary((struct Library*)IntuitionBase);return 0;}