home *** CD-ROM | disk | FTP | other *** search
- /* dcc dh1:IndexCD/Bin/Config_mui.c -l DLIB:muis.lib -3.0 */
-
- #include <stdio.h>
- #include <string.h>
- #include "demo.h"
-
- #define ID_DISPLAY 1
- #define ID_RIPRISTINA 2
- #define ID_SALVA 3
- #define ID_ESCI 4
-
- static Object * App; /* Application object */
- static Object * WI_Browser; /* Window object */
- static Object * BT_RIPRISTINA; /* RIPRISTINA Button object */
- static Object * BT_SALVA; /* SALVA Button object */
- static Object * BT_ESCI; /* ESCI Button object */
-
- static Object * pop1;
- static Object * pop2;
- static Object * pop3;
- static Object * pop4;
- static Object * pop5;
- static Object * pop6;
- static Object * pop7;
- static Object * pop8;
- static Object * pop9;
-
-
- char destdir [90]; // Configuration data
- char clha [90];
- char clzx [90];
- char ctext [90];
- char cpic [90];
- char cmod [90];
- char cdms [90];
- char destdms [90];
- char font [90];
-
- char buff[255];
- char path[255];
-
- char *Config = "S:Aminet-Config";
- char *ptr;
-
- int main(int argc,char *argv[])
- {
- static char buffer[2048];
- BOOL running = TRUE;
- ULONG signal;
-
- init();
-
- LoadConfiguration();
-
- App = ApplicationObject,
- MUIA_Application_Title , "Prefs IndexCD",
- MUIA_Application_Version , "$VER: IndexCD 2.3 (22-02-97)",
- MUIA_Application_Copyright , "©1996, Claudio Buraglio",
- MUIA_Application_Author , "Claudio Buraglio",
- MUIA_Application_Description, "Configuration of IndexCD",
- MUIA_Application_Base , "CONFIG-IndexCD",
-
- SubWindow, WI_Browser = WindowObject,
- MUIA_Window_Title, "Configuration IndexCD - ©1997 Claudio Buraglio.",
- MUIA_Window_ID, MAKE_ID('M','A','I','N'),
-
- WindowContents, VGroup,
-
- Child, ColGroup(2),
-
- Child, KeyLabel2("Destination:",0),
- Child, pop1 = PopaslObject,
- MUIA_Popstring_String, KeyString(destdir,256,0),
- MUIA_Popstring_Button, PopButton(MUII_PopDrawer),
- ASLFR_TitleText , "Select the destination directory...",
- ASLFR_DrawersOnly, TRUE,
- End,
- // StringFile
- Child, KeyLabel2("Command LHA:",0),
- Child, pop2 = PopaslObject,
- MUIA_Popstring_String, KeyString(clha,256,0),
- MUIA_Popstring_Button, PopButton(MUII_PopFile),
- ASLFR_TitleText, "Select LHA...",
- End,
- Child, KeyLabel2("Command LZX:",0),
- Child, pop3 = PopaslObject,
- MUIA_Popstring_String, KeyString(clzx,256,0),
- MUIA_Popstring_Button, PopButton(MUII_PopFile),
- ASLFR_TitleText, "Select LZX...",
- End,
- Child, KeyLabel2("Text Viewer:",0),
- Child, pop4 = PopaslObject,
- MUIA_Popstring_String, KeyString(ctext,256,0),
- MUIA_Popstring_Button, PopButton(MUII_PopFile),
- ASLFR_TitleText, "Select a text viewer...",
- End,
- Child, KeyLabel2("Picture Viewer:",0),
- Child, pop5 = PopaslObject,
- MUIA_Popstring_String, KeyString(cpic,256,0),
- MUIA_Popstring_Button, PopButton(MUII_PopFile),
- ASLFR_TitleText , "Select a picture viewer...",
- End,
- Child, KeyLabel2("Mod Player:",0),
- Child, pop6 = PopaslObject,
- MUIA_Popstring_String, KeyString(cmod,256,0),
- MUIA_Popstring_Button, PopButton(MUII_PopFile),
- ASLFR_TitleText , "Select a modules player...",
- End,
- Child, KeyLabel2("Command DMS:",0),
- Child, pop7 = PopaslObject,
- MUIA_Popstring_String, KeyString(cdms,256,0),
- MUIA_Popstring_Button, PopButton(MUII_PopFile),
- ASLFR_TitleText , "Select DMS...",
- End,
- Child, KeyLabel2("Destination Drawer of DMS:",0),
- Child, pop8 = PopaslObject,
- MUIA_Popstring_String, KeyString(destdms,256,0),
- MUIA_Popstring_Button, PopButton(MUII_PopDrawer),
- ASLFR_TitleText, "Seleziona the destination drawer for dms...",
- ASLFR_DrawersOnly, TRUE,
- End,
- Child, KeyLabel2("Font:",0),
- Child, pop9 = PopaslObject,
- MUIA_Popstring_String, KeyString(font,80,0),
- MUIA_Popstring_Button, PopButton(MUII_PopUp),
- MUIA_Popasl_Type , ASL_FontRequest,
- ASLFO_TitleText , "Select font...",
- End,
- End,
- // Bottoni
- Child, HGroup, MUIA_Group_SameSize, TRUE,
- Child, BT_RIPRISTINA = SimpleButton("_Last saved" ),
- Child, BT_SALVA = SimpleButton("_Save configuration"),
- Child, BT_ESCI = SimpleButton("_Exit" ),
- End,
-
- End,
- End,
- End;
-
- if (!App) fail(App,"Can't open application.");
-
- DoMethod(WI_Browser,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,App,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
- DoMethod(BT_SALVA ,MUIM_Notify,MUIA_Pressed,FALSE,App,2,MUIM_Application_ReturnID,ID_SALVA);
- DoMethod(BT_ESCI ,MUIM_Notify,MUIA_Pressed,FALSE,App,2,MUIM_Application_ReturnID,ID_ESCI );
- DoMethod(BT_RIPRISTINA ,MUIM_Notify,MUIA_Pressed,FALSE,App,2,MUIM_Application_ReturnID,ID_RIPRISTINA );
-
- DoMethod(WI_Browser,MUIM_Window_SetCycleChain,BT_RIPRISTINA,BT_SALVA,BT_ESCI,NULL);
-
- set(WI_Browser,MUIA_Window_Open,TRUE);
-
- while (running)
- {
- switch (DoMethod(App,MUIM_Application_Input,&signal))
- {
- case MUIV_Application_ReturnID_Quit:
- running = FALSE;
- break;
-
- case ID_SALVA:
- {
- FILE *fp;
- if ( fp = fopen(Config, "w"))
- {
- LONG x;
- get(pop1, MUIA_String_Contents, &x);
- sprintf(buff, "destdir=%s\n", x);
- ptr = strrchr(buff, '/');
- if (ptr == 0) { ptr = strrchr(buff, ':'); }
- *++ptr = 0xa; *++ptr = 0x0;
- fputs(buff, fp);
-
- get(pop2, MUIA_String_Contents, &x);
- fprintf(fp, " lha=%s\n", x);
- get(pop3, MUIA_String_Contents, &x);
- fprintf(fp, " lzx=%s\n", x);
- get(pop4, MUIA_String_Contents, &x);
- fprintf(fp, " text=%s\n", x);
- get(pop5, MUIA_String_Contents, &x);
- fprintf(fp, " pic=%s\n", x);
- get(pop6, MUIA_String_Contents, &x);
- fprintf(fp, " mod=%s\n", x);
- get(pop7, MUIA_String_Contents, &x);
- fprintf(fp, " dms=%s\n", x);
-
- get(pop8, MUIA_String_Contents, &x);
- sprintf(buff, "destdms=%s\n", x);
- ptr = strrchr(buff, ':');
- if (ptr == 0) { strcpy(buff,"DF0:\n"); } else
- { *++ptr = 0xa; *++ptr = 0x0; }
- fputs(buff, fp);
-
- get(pop9, MUIA_String_Contents, &x);
- fprintf(fp, " font=%s\n", x);
-
- fclose(fp);
- }
- running = FALSE;
- break;
- }
-
- case ID_ESCI:
- {
- running = FALSE;
- break;
- }
-
- case ID_RIPRISTINA:
- {
- LoadConfiguration();
- setstring(pop1, destdir);
- setstring(pop2, clha);
- setstring(pop3, clzx);
- setstring(pop4, ctext);
- setstring(pop5, cpic);
- setstring(pop6, cmod);
- setstring(pop7, cdms);
- setstring(pop8, destdms);
- setstring(pop9, font);
- break;
- }
- }
- if (running && signal)
- Wait(signal);
- }
- fail(App,NULL);
- }
-
- LoadConfiguration()
- {
- FILE *fp;
- char *coda;
-
- strcpy(destdir, "RAM:");
- strcpy( clha, "CD0:Tools/LhA");
- strcpy( ctext, "CD0:Tools/PowerGuide");
- strcpy( cpic, "CD0:Tools/VT");
- strcpy( cmod, "CD0:Tools/DeliTracker2");
-
- strcpy( clzx, "C:LZX");
- strcpy( cdms, "CD0:Tools/DMS");
- strcpy(destdms, "DF0:");
- strcpy( font, "topaz/11");
-
- if (fp = fopen(Config, "r"))
- {
- while (fgets(buff, sizeof(buff)-1, fp))
- {
- if ((ptr = strstr(buff, "destdir=")) != NULL)
- {
- ptr = strchr(buff, '=');
- ptr++;
- coda = stpcpy(destdir, ptr);
- *--coda = 0;
- }
- if ((ptr = strstr(buff, "lha=")) != NULL)
- {
- ptr = strchr(buff, '=');
- ptr++;
- coda = stpcpy(clha, ptr);
- *--coda = 0;
- }
- if ((ptr = strstr(buff, "lzx=")) != NULL)
- {
- ptr = strchr(buff, '=');
- ptr++;
- coda = stpcpy(clzx, ptr);
- *--coda = 0;
- }
- if ((ptr = strstr(buff, "text=")) != NULL)
- {
- ptr = strchr(buff, '=');
- ptr++;
- coda = stpcpy(ctext, ptr);
- *--coda = 0;
- }
- if ((ptr = strstr(buff, "pic=")) != NULL)
- {
- ptr = strchr(buff, '=');
- ptr++;
- coda = stpcpy(cpic, ptr);
- *--coda = 0;
- }
- if ((ptr = strstr(buff, "mod=")) != NULL)
- {
- ptr = strchr(buff, '=');
- ptr++;
- coda = stpcpy(cmod, ptr);
- *--coda = 0;
- }
- if ((ptr = strstr(buff, " dms=")) != NULL)
- {
- ptr = strchr(buff, '=');
- ptr++;
- coda = stpcpy(cdms, ptr);
- *--coda = 0;
- }
- if ((ptr = strstr(buff, "destdms=")) != NULL)
- {
- ptr = strchr(buff, '=');
- ptr++;
- coda = stpcpy(destdms, ptr);
- *--coda = 0;
- }
- if ((ptr = strstr(buff, "font=")) != NULL)
- {
- ptr = strchr(buff, '=');
- ptr++;
- coda = stpcpy(font, ptr);
- *--coda = 0;
- }
- }
- fclose(fp);
- }
- }
-
-