home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / util / wb / forceicon / source / ficonprefs.c < prev    next >
C/C++ Source or Header  |  1994-08-19  |  63KB  |  2,519 lines

  1. /*
  2. Auto:        smake FIconPrefs
  3. */
  4.  
  5.  
  6. /* $Revision Header built automatically *************** (do not edit) ************
  7. **
  8. ** © Copyright by GuntherSoft
  9. **
  10. ** File             : SnakeSYS:CPrgs/ForceIcon2/FIconPrefs.c
  11. ** Created on       : Wednesday, 16.03.94 16:19:51
  12. ** Created by       : Kai Iske
  13. ** Current revision : V1.0
  14. **
  15. **
  16. ** Purpose
  17. ** -------
  18. **   - Prefs Editor for ForceIcon
  19. **
  20. ** Revision V1.0
  21. ** --------------
  22. ** created on Wednesday, 16.03.94 16:19:51  by  Kai Iske.   LogMessage :
  23. **     --- Initial release ---
  24. **
  25. *********************************************************************************/
  26.  
  27.  
  28.  
  29.  
  30. /**********************************************************************/
  31. /*                     Define for DisplayError()                      */
  32. /**********************************************************************/
  33. #define    PREFSRUN
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40. /**********************************************************************/
  41. /*                      Routines for this module                      */
  42. /**********************************************************************/
  43. static BOOL            OpenAll(void);
  44. static void            CloseAll(void);
  45. static struct    FIconSema    *FindFIconSema(void);
  46. static void            RemoveFIconSema(struct FIconSema *FIconSema);
  47. static BOOL            InitApp(void);
  48. static void            RemoveApp(void);
  49. static ULONG    __saveds __asm    DispViewFunc(register __a0 struct Hook *MyHook, register __a2 char **array, register __a1 struct VolEntry *Data);
  50. static ULONG    __saveds __asm    DisableFunc(register __a0 struct Hook *MyHook, register __a2 APTR Obj, register __a1 APTR *Data);
  51. static ULONG    __saveds __asm    PageChangeFunc(register __a0 struct Hook *MyHook, register __a2 APTR Obj, register __a1 APTR *Data);
  52. static struct    VolEntry    *AddNewVolume(char *Name, ULONG Type, struct VolEntry *CopyPtr);
  53. static BOOL            CheckExists(char *Name);
  54. static BOOL            SavePrefs(BOOL EnvMode);
  55. static void            DskChange(struct VolEntry *ListEntry);
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. /**********************************************************************/
  63. /*                    Functions of files included                     */
  64. /**********************************************************************/
  65.     // LoadPrefs.h
  66.  
  67. static void            LoadPrefs(struct FIconSema *FIconSema);
  68.  
  69.     // VolList.h
  70.  
  71. static BOOL            GetDevVolList(struct List *VolList);
  72. static BOOL            GetDosEntries(struct List *VolList, ULONG Mode);
  73. static void            FreeDevVolList(struct List *VolList);
  74. static void            SortList(struct List *VolList, BOOL DisplayType);
  75. static void            SortPartialList(struct List *VolList, UWORD Left, UWORD Right);
  76. static APTR            GetListEntry(struct List *List, WORD EntryNum);
  77. static BOOL            MyStrCmp(char *FromName, char *ToName);
  78.  
  79.     // Error.h
  80.  
  81. static void    __stdargs    DisplayError(LONG ErrCode, ULONG Arg1, ...);
  82.  
  83.     // CheckToolTypes.h
  84.  
  85. static void            CheckToolTypes(struct WBStartup *WBenchMsg);
  86.  
  87.     // PoolVec.h
  88.  
  89. static APTR            AllocVecPool(struct FIconSema *FIconSema, ULONG Size);
  90. static void            FreeVecPool(struct FIconSema *FIconSema, APTR Addr);
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97. /**********************************************************************/
  98. /*                           Library bases                            */
  99. /**********************************************************************/
  100. struct    ExecBase        *SysBase;
  101. struct    IntuitionBase        *IntuitionBase    = NULL;
  102. struct    DosLibrary        *DOSBase    = NULL;
  103. struct    Library            *IconBase    = NULL;
  104. struct    Library            *UtilityBase    = NULL;
  105. struct    Library            *IFFParseBase    = NULL;
  106. struct    Library            *MUIMasterBase    = NULL;
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113. /**********************************************************************/
  114. /*                         "No-StartUp vars"                          */
  115. /**********************************************************************/
  116. #define    MUIVERS                    "$VER:ForceIcon_Prefs "REVISION" ("REVDATE")"
  117. char                _ProgramName[]    = "ForceIconPrefs";
  118. LONG                _OSERR        = 0;
  119.  
  120.  
  121.  
  122.  
  123. /**********************************************************************/
  124. /*                           Our variables                            */
  125. /**********************************************************************/
  126. static    struct    FIconSema    *FIconSema    = NULL;        // Pointer to our rendezvous semaphore
  127. static    struct    List        AvailableList;
  128. static    UWORD            FlushMemory    = FALSE;
  129.  
  130.  
  131.  
  132.  
  133. /**********************************************************************/
  134. /*                 Application and window definitions                 */
  135. /**********************************************************************/
  136. static    struct    DiskObject    *DObj        = NULL;
  137. static    APTR            AppObject    = NULL;
  138. static    APTR            MainWindow    = NULL;
  139. static    APTR            UsedList;
  140. static    APTR            EditEntry;
  141. static    APTR            CopyEntry;
  142. static    APTR            RemoveEntry;
  143. static    APTR            AvailList;
  144. static    APTR            AddEntry;
  145. static    APTR            AddEntryMan;
  146. static    APTR            RescanList;
  147. static    APTR            SaveObj;
  148. static    APTR            UseObj;
  149. static    APTR            AboutObj;
  150. static    APTR            HideObj;
  151. static    APTR            QuitObj;
  152.  
  153. static    APTR            EditWindow;
  154. static    APTR            VolumeName;
  155. static    APTR            VolumeType;
  156. static    APTR            IconPosGroup;
  157. static    APTR            IconPos[2];
  158. static    APTR            IconX;
  159. static    APTR            IconY;
  160. static    APTR            Position;
  161. static    APTR            UseIconGroup;
  162. static    APTR            UseIcon[2];
  163. static    APTR            IconName;
  164. static    APTR            UseWindowGroup;
  165. static    APTR            UseWindow[2];
  166. static    APTR            WinX;
  167. static    APTR            WinY;
  168. static    APTR            WinWidth;
  169. static    APTR            WinHeight;
  170. static    APTR            LookWin;
  171. static    APTR            UseFlagsGroup;
  172. static    APTR            UseFlags[2];
  173. static    APTR            FlagModes;
  174. static    APTR            EditOkObj;
  175. static    APTR            EditCancelObj;
  176.  
  177. static    APTR            ManWindow;
  178. static    APTR            ManVolName;
  179. static    APTR            ManVolType;
  180. static    APTR            ManOkObj;
  181. static    APTR            ManCancelObj;
  182.  
  183.  
  184.  
  185.  
  186.  
  187. /**********************************************************************/
  188. /*                     Strings for Cycle gadgets                      */
  189. /**********************************************************************/
  190. static const char *TypeEntries[] =
  191. {
  192.     "Volume",
  193.     "Device",
  194.     NULL
  195. };
  196.  
  197.  
  198. static const char *ModeEntriesVol[] =
  199. {
  200.     "Ignore",
  201.     "Use",
  202.     "Inherit",
  203.     NULL
  204. };
  205.  
  206.  
  207. static const char *ModeEntriesDev[] =
  208. {
  209.     "Ignore",
  210.     "Use",
  211.     NULL
  212. };
  213.  
  214.  
  215. static const char *PositionEntries[] =
  216. {
  217.     "Open position window",
  218.     "Close position window",
  219.     NULL
  220. };
  221.  
  222.  
  223.  
  224. static const char *LookWinEntries[] =
  225. {
  226.     "Open window",
  227.     "Close window",
  228.     NULL
  229. };
  230.  
  231.  
  232. static const char *FlagModesEntries[] =
  233. {
  234.     "only icons + view by icon",
  235.     "only icons + view by name",
  236.     "only icons + view by date",
  237.     "only icons + view by size",
  238.     "all files + view by icon",
  239.     "all files + view by name",
  240.     "all files + view by date",
  241.     "all files + view by size",
  242.     NULL
  243. };
  244.  
  245.  
  246. /**********************************************************************/
  247. /*                            Display Hook                            */
  248. /**********************************************************************/
  249. static struct Hook    DispViewHook =
  250. {
  251.     {NULL},
  252.     (APTR)DispViewFunc,
  253.     NULL,
  254.     NULL
  255. };
  256.  
  257.  
  258.  
  259. static struct Hook    DisableHook =
  260. {
  261.     {NULL},
  262.     (APTR)DisableFunc,
  263.     NULL,
  264.     NULL
  265. };
  266.  
  267.  
  268.  
  269. static struct Hook    PageChangeHook =
  270. {
  271.     {NULL},
  272.     (APTR)PageChangeFunc,
  273.     NULL,
  274.     NULL
  275. };
  276.  
  277.  
  278.  
  279. /**********************************************************************/
  280. /*                      This is our main program                      */
  281. /**********************************************************************/
  282. ULONG __saveds main(void)
  283. {
  284.     struct    Process        *MyProc;
  285.     struct    WBStartup    *WBenchMsg    = NULL;
  286.     struct    VolEntry    *EditEntryPtr    = NULL;
  287.     struct    Window        *PosWindow    = NULL,
  288.                 *DrawerWindow    = NULL;
  289.     ULONG            MySig,
  290.                 ReturnID;
  291.     BOOL            GoOn        = TRUE;
  292.  
  293.  
  294.  
  295.  
  296.         // Get SysBase
  297.  
  298.     SysBase    = *((struct ExecBase **)0x4L);
  299.  
  300.  
  301.         // Get address of our process
  302.  
  303.     MyProc = (struct Process *)FindTask(NULL);
  304.  
  305.  
  306.  
  307.         // Determine where we were started from
  308.  
  309.     if(!MyProc->pr_CLI)
  310.     {
  311.         WaitPort(&MyProc->pr_MsgPort);
  312.         WBenchMsg = (struct WBStartup *)GetMsg(&MyProc->pr_MsgPort);
  313.     }
  314.  
  315.  
  316.  
  317.         // Don`t run under OS < 37
  318.  
  319.     if(((struct Library *)SysBase)->lib_Version >= 37)
  320.     {
  321.             // Open libraries
  322.  
  323.         if(OpenAll())
  324.         {
  325.             if((FIconSema = FindFIconSema()))
  326.             {
  327.                     // Check for ToolTypes/commandline options
  328.  
  329.                 CheckToolTypes(WBenchMsg);
  330.  
  331.                 if(InitApp())
  332.                 {
  333.                     while(GoOn)
  334.                     {
  335.                         switch(ReturnID = DoMethod(AppObject, MUIM_Application_Input, &MySig))
  336.                         {
  337.                                 // Handle MAINWINDOW
  338.  
  339.  
  340.                                 // Save ?!?!
  341.  
  342.                             case ID_SAVE :
  343.                             {
  344.                                 SavePrefs(FALSE);
  345.                                 GoOn    = FALSE;
  346.                                 break;
  347.                             }
  348.  
  349.                                 // Use ?!?!
  350.  
  351.                             case ID_USE :
  352.                             {
  353.                                 SavePrefs(TRUE);
  354.                                 GoOn    = FALSE;
  355.                                 break;
  356.                             }
  357.  
  358.                                 // About ???
  359.  
  360.                             case ID_ABOUT :
  361.                             {
  362.                                 DisplayError(ERR_ABOUT, VERNUM, REVNUM, REVDATE, NULL);
  363.                                 break;
  364.                             }
  365.  
  366.                                 // Hide/Quit Prefs ?!?
  367.  
  368.                             case ID_HIDE :
  369.                             {
  370.                                 GoOn    = FALSE;
  371.                                 break;
  372.                             }
  373.  
  374.                                 // Hide/Quit Prefs and server ???
  375.  
  376.                             case ID_QUIT :
  377.                             {
  378.                                 struct    Task    *ServerTask;
  379.  
  380.                                 ObtainSemaphore(&FIconSema->FIconSema);
  381.                                 Forbid();
  382.                                 ServerTask    = FIconSema->ServerTask;
  383.                                 ReleaseSemaphore(&FIconSema->FIconSema);
  384.  
  385.                                     // Tell server to go away
  386.  
  387.                                 if(ServerTask)
  388.                                     Signal(ServerTask, SIGBREAKF_CTRL_C);
  389.                                 Permit();
  390.  
  391.                                 GoOn    = FALSE;
  392.                                 break;
  393.                             }
  394.  
  395.                             case ID_USEDLIST :
  396.                             case ID_EDITENTRY :
  397.                             {
  398.                                 struct    VolEntry    *ThisEntry;
  399.  
  400.                                 DoMethod(UsedList, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &ThisEntry);
  401.  
  402.                                 if(ThisEntry)
  403.                                 {
  404.                                     set(VolumeName, MUIA_String_Contents, ThisEntry->VolName);
  405.                                     set(VolumeType, MUIA_Cycle_Active, (ThisEntry->Link.ln_Type == LDF_DEVICES));
  406.                                     set(IconPos[0], MUIA_Cycle_Active, ThisEntry->IconPos);
  407.                                     set(IconPos[1], MUIA_Cycle_Active, ThisEntry->IconPos);
  408.                                     set(IconX, MUIA_String_Integer, ThisEntry->Left);
  409.                                     set(IconX, MUIA_Disabled, (ThisEntry->IconPos != MODE_USE));
  410.                                     set(IconY, MUIA_String_Integer, ThisEntry->Top);
  411.                                     set(IconY, MUIA_Disabled, (ThisEntry->IconPos != MODE_USE));
  412.                                     set(Position, MUIA_Cycle_Active, 0);
  413.                                     set(Position, MUIA_Disabled, (ThisEntry->IconPos != MODE_USE));
  414.                                     set(UseIcon[0], MUIA_Cycle_Active, ThisEntry->UseAlt);
  415.                                     set(UseIcon[1], MUIA_Cycle_Active, ThisEntry->UseAlt);
  416.                                     set(IconName, MUIA_String_Contents, ThisEntry->IconName);
  417.                                     set(IconName, MUIA_Disabled, (ThisEntry->UseAlt != MODE_USE));
  418.                                     set(UseWindow[0], MUIA_Cycle_Active, ThisEntry->UseWin);
  419.                                     set(UseWindow[1], MUIA_Cycle_Active, ThisEntry->UseWin);
  420.                                     set(WinX, MUIA_String_Integer, ThisEntry->WinX);
  421.                                     set(WinX, MUIA_Disabled, (ThisEntry->UseWin != MODE_USE));
  422.                                     set(WinY, MUIA_String_Integer, ThisEntry->WinY);
  423.                                     set(WinY, MUIA_Disabled, (ThisEntry->UseWin != MODE_USE));
  424.                                     set(WinWidth, MUIA_String_Integer, ThisEntry->WinWidth);
  425.                                     set(WinWidth, MUIA_Disabled, (ThisEntry->UseWin != MODE_USE));
  426.                                     set(WinHeight, MUIA_String_Integer, ThisEntry->WinHeight);
  427.                                     set(WinHeight, MUIA_Disabled, (ThisEntry->UseWin != MODE_USE));
  428.                                     set(LookWin, MUIA_Cycle_Active, 0);
  429.                                     set(LookWin, MUIA_Disabled, (ThisEntry->UseWin != MODE_USE));
  430.                                     set(UseFlags[0], MUIA_Cycle_Active, ThisEntry->UseFlags);
  431.                                     set(UseFlags[1], MUIA_Cycle_Active, ThisEntry->UseFlags);
  432.                                     set(FlagModes, MUIA_Cycle_Active, ThisEntry->WinFlags);
  433.                                     set(FlagModes, MUIA_Disabled, (ThisEntry->UseFlags != MODE_USE));
  434.  
  435.                                     set(MainWindow, MUIA_Window_Sleep, TRUE);
  436.  
  437.                                     set(EditWindow, MUIA_Window_Open, TRUE);
  438.  
  439.                                     EditEntryPtr    = ThisEntry;
  440.                                 }
  441.                                 break;
  442.                             }
  443.  
  444.                                 // Copy an entry ???
  445.  
  446.                             case ID_COPYENTRY :
  447.                             {
  448.                                 struct    VolEntry    *ThisEntry;
  449.  
  450.  
  451.                                 DoMethod(UsedList, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &ThisEntry);
  452.  
  453.                                 if(ThisEntry)
  454.                                 {
  455.                                     set(ManVolName, MUIA_String_Contents, ThisEntry->VolName);
  456.                                     set(ManVolType, MUIA_Cycle_Active, (ThisEntry->Link.ln_Type == LDF_DEVICES));
  457.  
  458.                                     set(MainWindow, MUIA_Window_Sleep, TRUE);
  459.                                     set(ManWindow, MUIA_Window_Title, "Copy entry");
  460.                                     set(ManWindow, MUIA_Window_Open, TRUE);
  461.  
  462.                                     EditEntryPtr    = ThisEntry;
  463.                                 }
  464.                                 break;
  465.                             }
  466.  
  467.  
  468.                                 // Remove an entry ???
  469.  
  470.                             case ID_REMOVEENTRY :
  471.                             {
  472.                                 struct    VolEntry    *ThisEntry;
  473.  
  474.                                 DoMethod(UsedList, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &ThisEntry);
  475.  
  476.                                 if(ThisEntry)
  477.                                 {
  478.                                     ObtainSemaphore(&FIconSema->FIconSema);
  479.  
  480.                                         // Remove entry from listview
  481.  
  482.                                     DoMethod(UsedList, MUIM_List_Remove, MUIV_List_Remove_Active);
  483.  
  484.                                         // Remove entry from internal list
  485.  
  486.                                     Remove(ThisEntry);
  487.                                     FreeVecPool(FIconSema, ThisEntry);
  488.  
  489.                                     FIconSema->VolumeList.lh_Type--;
  490.  
  491.                                     ReleaseSemaphore(&FIconSema->FIconSema);
  492.                                 }
  493.                                 break;
  494.                             }
  495.  
  496.                                 // Add an entry ???
  497.  
  498.                             case ID_AVAILLIST :
  499.                             case ID_ADDENTRY :
  500.                             {
  501.                                 struct    VolEntry    *ThisEntry;
  502.  
  503.                                     // Really get entry ???
  504.  
  505.                                 DoMethod(AvailList, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &ThisEntry);
  506.  
  507.                                 if(ThisEntry)
  508.                                     AddNewVolume(ThisEntry->VolName, ThisEntry->Link.ln_Type, NULL);
  509.                                 break;
  510.                             }
  511.  
  512.  
  513.                                 // Manually add an entry ???
  514.  
  515.                             case ID_ADDENTRYMAN :
  516.                             {
  517.                                 set(ManVolName, MUIA_String_Contents, "");
  518.                                 set(ManVolType, MUIA_Cycle_Active, 0);
  519.  
  520.                                 set(MainWindow, MUIA_Window_Sleep, TRUE);
  521.                                 set(ManWindow, MUIA_Window_Title, "Add manually");
  522.                                 set(ManWindow, MUIA_Window_Open, TRUE);
  523.  
  524.                                 EditEntryPtr    = NULL;
  525.                                 break;
  526.                             }
  527.  
  528.  
  529.                                 // Rescan list ???
  530.  
  531.                             case ID_RESCANLIST :
  532.                             {
  533.                                 struct    VolEntry    *ThisEntry;
  534.  
  535.  
  536.                                     // Remove List from listview
  537.  
  538.                                 DoMethod(AvailList, MUIM_List_Clear, NULL);
  539.  
  540.                                     // FreeList
  541.  
  542.                                 FreeDevVolList(&AvailableList);
  543.                                 GetDevVolList(&AvailableList);
  544.  
  545.                                     // Add list of available entries
  546.  
  547.                                 ThisEntry    = (struct VolEntry *)AvailableList.lh_Head;
  548.                                 while(ThisEntry->Link.ln_Succ)
  549.                                 {
  550.                                     DoMethod(AvailList, MUIM_List_InsertSingle, (APTR)ThisEntry, MUIV_List_Insert_Bottom);
  551.  
  552.                                     ThisEntry    = (struct VolEntry *)ThisEntry->Link.ln_Succ;
  553.                                 }
  554.                                 break;
  555.                             }
  556.  
  557.  
  558.  
  559.                                 // Check Edit window
  560.  
  561.  
  562.                                 // New input from IconX/Y gadgets?
  563.  
  564.                             case ID_ICONX :
  565.                             case ID_ICONY :
  566.                             {
  567.                                 LONG    PosX,
  568.                                     PosY;
  569.  
  570.  
  571.                                     // Only do, when PosWindow is open, as values
  572.                                     // will be obtained on exit, anyway
  573.  
  574.                                 if(PosWindow)
  575.                                 {
  576.                                     get(IconX, MUIA_String_Integer, &PosX);
  577.                                     get(IconY, MUIA_String_Integer, &PosY);
  578.  
  579.                                     ChangeWindowBox(PosWindow, (PosX < 0 ? PosWindow->WScreen->Width + PosX : PosX), (PosY < 0 ? PosWindow->WScreen->Height + PosY : PosY), PosWindow->Width, PosWindow->Height);
  580.                                 }
  581.                                 break;
  582.                             }
  583.  
  584.                                 // New input from Drawer Windows?
  585.  
  586.                             case ID_WINX :
  587.                             case ID_WINY :
  588.                             case ID_WINWIDTH :
  589.                             case ID_WINHEIGHT :
  590.                             {
  591.                                 ULONG    Left,
  592.                                     Top,
  593.                                     Width,
  594.                                     Height;
  595.  
  596.                                 if(DrawerWindow)
  597.                                 {
  598.                                     get(WinX, MUIA_String_Integer, &Left);
  599.                                     get(WinY, MUIA_String_Integer, &Top);
  600.                                     get(WinWidth, MUIA_String_Integer, &Width);
  601.                                     get(WinHeight, MUIA_String_Integer, &Height);
  602.  
  603.                                     ChangeWindowBox(DrawerWindow, Left, Top, Width, Height);
  604.                                 }
  605.                                 break;
  606.                             }
  607.  
  608.  
  609.                                 // Open/Close position window ???
  610.  
  611.                             case ID_POSITION :
  612.                             {
  613.                                 ULONG    State;
  614.  
  615.                                 get(Position, MUIA_Cycle_Active, &State);
  616.  
  617.                                 if(State && !PosWindow && EditEntryPtr)
  618.                                 {
  619.                                     struct    Screen    *WBScreen;
  620.                                     LONG        Left,
  621.                                             Top;
  622.  
  623.                                     get(IconX, MUIA_String_Integer, &Left);
  624.                                     get(IconY, MUIA_String_Integer, &Top);
  625.  
  626.                                     if((WBScreen = LockPubScreen(NULL)))
  627.                                     {
  628.                                         PosWindow = OpenWindowTags(NULL,
  629.                                                 WA_Left,    (Left < 0 ? WBScreen->Width + Left : Left),
  630.                                                 WA_Top,        (Top < 0 ? WBScreen->Height + Top : Top),
  631.                                                 WA_Width,    (WBScreen->BarLayer->rp->Font->tf_XSize * 4) + 2 + WBScreen->WBorLeft + WBScreen->WBorRight,
  632.                                                 WA_Height,    WBScreen->WBorTop + WBScreen->Font->ta_YSize + 1,
  633.                                                 WA_IDCMP,    IDCMP_CHANGEWINDOW,
  634.                                                 WA_Flags,    WFLG_DRAGBAR|WFLG_RMBTRAP,
  635.                                                 WA_Title,    "Icon",
  636.                                                 WA_PubScreen,    WBScreen,
  637.                                         TAG_DONE);
  638.  
  639.                                         UnlockPubScreen(NULL, WBScreen);
  640.  
  641.                                         if(!PosWindow)
  642.                                         {
  643.                                             set(Position, MUIA_Cycle_Active, 0);
  644.                                             DisplayError(ERR_NOMEM, NULL);
  645.                                         }
  646.                                     }
  647.                                 }
  648.                                 else if(PosWindow)
  649.                                 {
  650.                                     CloseWindow(PosWindow);
  651.                                     PosWindow    = NULL;
  652.                                 }
  653.                                 break;
  654.                             }
  655.  
  656.                                 // Open/Close Drawer Window ???
  657.  
  658.                             case ID_DRAWER :
  659.                             {
  660.                                 ULONG    State;
  661.  
  662.                                 get(LookWin, MUIA_Cycle_Active, &State);
  663.  
  664.                                 if(State && !DrawerWindow && EditEntryPtr)
  665.                                 {
  666.                                     struct    Screen    *WBScreen;
  667.                                     ULONG        Left,
  668.                                             Top,
  669.                                             Width,
  670.                                             Height;
  671.  
  672.  
  673.                                     get(WinX, MUIA_String_Integer, &Left);
  674.                                     get(WinY, MUIA_String_Integer, &Top);
  675.                                     get(WinWidth, MUIA_String_Integer, &Width);
  676.                                     get(WinHeight, MUIA_String_Integer, &Height);
  677.  
  678.                                     if((WBScreen = LockPubScreen(NULL)))
  679.                                     {
  680.                                         DrawerWindow = OpenWindowTags(NULL,
  681.                                                 WA_Left,    Left,
  682.                                                 WA_Top,        Top,
  683.                                                 WA_Width,    (Width ? Width: 50),
  684.                                                 WA_Height,    (Height ? Height : 50),
  685.                                                 WA_MaxWidth,    -1,
  686.                                                 WA_MaxHeight,    -1,
  687.                                                 WA_IDCMP,    IDCMP_CHANGEWINDOW,
  688.                                                 WA_Flags,    WFLG_DEPTHGADGET|WFLG_DRAGBAR|WFLG_RMBTRAP|WFLG_SIZEBRIGHT|WFLG_SIZEBBOTTOM,
  689.                                                 WA_Title,    "Drawer window (demo)",
  690.                                                 WA_PubScreen,    WBScreen,
  691.                                                 WA_SizeGadget,    TRUE,
  692.                                         TAG_DONE);
  693.  
  694.                                         UnlockPubScreen(NULL, WBScreen);
  695.                                         
  696.                                         if(!DrawerWindow)
  697.                                         {
  698.                                             set(LookWin, MUIA_Cycle_Active, 0);
  699.                                             DisplayError(ERR_NOMEM, NULL);
  700.                                         }
  701.                                     }
  702.                                 }
  703.                                 else if(DrawerWindow)
  704.                                 {
  705.                                     CloseWindow(DrawerWindow);
  706.                                     DrawerWindow    = NULL;
  707.                                 }
  708.                                 break;
  709.                             }
  710.  
  711.                                 // Ok ???
  712.  
  713.                             case ID_EDITOK :
  714.                             {
  715.                                 ULONG    OldType,
  716.                                     NewName,
  717.                                     PopAslState;
  718.                                 BOOL    DoSort    = FALSE;
  719.  
  720.  
  721.                                     // Don`t close window, when FileRequester is open
  722.  
  723.                                 get(IconName, MUIA_Popasl_Active, &PopAslState);
  724.                                 if(!PopAslState)
  725.                                 {
  726.                                     set(EditWindow, MUIA_Window_Open, FALSE);
  727.                                     if(PosWindow)
  728.                                     {
  729.                                         CloseWindow(PosWindow);
  730.                                         PosWindow    = NULL;
  731.                                     }
  732.                                     if(DrawerWindow)
  733.                                     {
  734.                                         CloseWindow(DrawerWindow);
  735.                                         DrawerWindow    = NULL;
  736.                                     }
  737.                                     set(MainWindow, MUIA_Window_Sleep, FALSE);
  738.  
  739.                                         // Copy contents of gadgets to selected entry
  740.  
  741.                                     if(EditEntryPtr)
  742.                                     {
  743.                                         LONG    Dummy;
  744.  
  745.                                         ObtainSemaphore(&FIconSema->FIconSema);
  746.  
  747.                                             // Get new settings
  748.  
  749.                                         get(VolumeName, MUIA_String_Contents, &Dummy);
  750.                                         NewName = stricmp(EditEntryPtr->VolName, (char *)Dummy);
  751.                                         strcpy(EditEntryPtr->VolName, (char *)Dummy);
  752.  
  753.                                         get(VolumeType, MUIA_Cycle_Active, &Dummy);
  754.                                         OldType                = EditEntryPtr->Link.ln_Type;
  755.                                         EditEntryPtr->Link.ln_Type    = (Dummy ? LDF_DEVICES : LDF_VOLUMES);
  756.  
  757.                                         get(IconX, MUIA_String_Integer, &Dummy);
  758.                                         EditEntryPtr->Left        = Dummy;
  759.  
  760.                                         get(IconY, MUIA_String_Integer, &Dummy);
  761.                                         EditEntryPtr->Top        = Dummy;
  762.  
  763.                                         get(IconPos[(UWORD)(EditEntryPtr->Link.ln_Type == LDF_DEVICES)], MUIA_Cycle_Active, &Dummy);
  764.                                         EditEntryPtr->IconPos    = Dummy;
  765.  
  766.                                         get(IconName, MUIA_String_Contents, &Dummy);
  767.                                         strcpy(EditEntryPtr->IconName, (char *)Dummy);
  768.  
  769.                                         get(UseIcon[(UWORD)(EditEntryPtr->Link.ln_Type == LDF_DEVICES)], MUIA_Cycle_Active, &Dummy);
  770.                                         EditEntryPtr->UseAlt    = Dummy;
  771.  
  772.                                         get(UseWindow[(UWORD)(EditEntryPtr->Link.ln_Type == LDF_DEVICES)], MUIA_Cycle_Active, &Dummy);
  773.                                         EditEntryPtr->UseWin    = Dummy;
  774.  
  775.                                         get(WinX, MUIA_String_Integer, &Dummy);
  776.                                         EditEntryPtr->WinX    = Dummy;
  777.  
  778.                                         get(WinY, MUIA_String_Integer, &Dummy);
  779.                                         EditEntryPtr->WinY    = Dummy;
  780.  
  781.                                         get(WinWidth, MUIA_String_Integer, &Dummy);
  782.                                         EditEntryPtr->WinWidth    = Dummy;
  783.  
  784.                                         get(WinHeight, MUIA_String_Integer, &Dummy);
  785.                                         EditEntryPtr->WinHeight    = Dummy;
  786.  
  787.                                         get(UseFlags[(UWORD)(EditEntryPtr->Link.ln_Type == LDF_DEVICES)], MUIA_Cycle_Active, &Dummy);
  788.                                         EditEntryPtr->UseFlags    = Dummy;
  789.  
  790.                                         get(FlagModes, MUIA_Cycle_Active, &Dummy);
  791.                                         EditEntryPtr->WinFlags    = Dummy;
  792.  
  793.                                         if(!strstr(EditEntryPtr->IconName, ".info") && strlen(EditEntryPtr->IconName))
  794.                                             strcat(EditEntryPtr->IconName, ".info");
  795.  
  796.  
  797.  
  798.                                             // Type of entry changed ???
  799.  
  800.                                         if(OldType != EditEntryPtr->Link.ln_Type)
  801.                                         {
  802.                                             Remove(EditEntryPtr);
  803.  
  804.                                             if(EditEntryPtr->Link.ln_Type == LDF_DEVICES)
  805.                                                 AddTail(&FIconSema->VolumeList, (struct Node *)EditEntryPtr);
  806.                                             else
  807.                                                 AddHead(&FIconSema->VolumeList, (struct Node *)EditEntryPtr);
  808.  
  809.                                             DoSort    = TRUE;
  810.                                         }
  811.  
  812.                                             // Name changed ???
  813.  
  814.                                         if(!DoSort)
  815.                                             DoSort    = (BOOL)(NewName != 0);
  816.  
  817.                                             // Rearrange volume`s/device`s icon
  818.  
  819.                                         DskChange(EditEntryPtr);
  820.  
  821.                                             // Sort list
  822.  
  823.                                         if(DoSort)
  824.                                         {
  825.                                             SortList(&FIconSema->VolumeList, TRUE);
  826.  
  827.                                                 // Remove list
  828.  
  829.                                             DoMethod(UsedList, MUIM_List_Clear, NULL);
  830.  
  831.                                             EditEntryPtr    = (struct VolEntry *)FIconSema->VolumeList.lh_Head;
  832.                                             while(EditEntryPtr->Link.ln_Succ)
  833.                                             {
  834.                                                 DoMethod(UsedList, MUIM_List_InsertSingle, (APTR)EditEntryPtr, MUIV_List_Insert_Bottom);
  835.  
  836.                                                 EditEntryPtr    = (struct VolEntry *)EditEntryPtr->Link.ln_Succ;
  837.                                             }
  838.                                         }
  839.                                         ReleaseSemaphore(&FIconSema->FIconSema);
  840.                                     }
  841.                                     EditEntryPtr    = NULL;
  842.                                 }
  843.                                 break;
  844.                             }
  845.  
  846.                                 // Cancel ???
  847.  
  848.                             case ID_EDITCANCEL :
  849.                             {
  850.                                 ULONG    PopAslState;
  851.  
  852.                                     // Don`t close window, when FileRequester is open
  853.  
  854.                                 get(IconName, MUIA_Popasl_Active, &PopAslState);
  855.                                 if(!PopAslState)
  856.                                 {
  857.                                     set(EditWindow, MUIA_Window_Open, FALSE);
  858.                                     if(PosWindow)
  859.                                     {
  860.                                         CloseWindow(PosWindow);
  861.                                         PosWindow    = NULL;
  862.                                     }
  863.                                     if(DrawerWindow)
  864.                                     {
  865.                                         CloseWindow(DrawerWindow);
  866.                                         DrawerWindow    = NULL;
  867.                                     }
  868.                                     set(MainWindow, MUIA_Window_Sleep, FALSE);
  869.                                 }
  870.                                 EditEntryPtr    = NULL;
  871.                                 break;
  872.                             }
  873.  
  874.  
  875.  
  876.                                 // Check man window
  877.  
  878.                             case ID_MANOK :
  879.                             {
  880.                                 char            *VolName;
  881.                                 ULONG            Type;
  882.  
  883.                                 set(ManWindow, MUIA_Window_Open, FALSE);
  884.                                 set(MainWindow, MUIA_Window_Sleep, FALSE);
  885.  
  886.  
  887.                                 get(ManVolName, MUIA_String_Contents, &VolName);
  888.                                 get(ManVolType, MUIA_Cycle_Active, &Type);
  889.                                 Type    = (Type ? LDF_DEVICES : LDF_VOLUMES);
  890.  
  891.                                 AddNewVolume(VolName, Type, EditEntryPtr);
  892.                                 EditEntryPtr    = NULL;
  893.                                 break;
  894.                             }
  895.  
  896.                             case ID_MANCANCEL :
  897.                             {
  898.                                 set(ManWindow, MUIA_Window_Open, FALSE);
  899.                                 set(MainWindow, MUIA_Window_Sleep, FALSE);
  900.                                 EditEntryPtr    = NULL;
  901.                                 break;
  902.                             }
  903.                         }
  904.  
  905.  
  906.                         if(GoOn && MySig)
  907.                         {
  908.                             if(PosWindow)
  909.                                 MySig    |= (1 << PosWindow->UserPort->mp_SigBit);
  910.  
  911.                             if(DrawerWindow)
  912.                                 MySig    |= (1 << DrawerWindow->UserPort->mp_SigBit);
  913.  
  914.                             MySig    = Wait(MySig | SIGBREAKF_CTRL_F);
  915.  
  916.  
  917.                                 // Server snapped icon?
  918.  
  919.                             if(MySig & SIGBREAKF_CTRL_F)
  920.                             {
  921.                                 struct    VolEntry    *ThisEntry;
  922.  
  923.                                     // Entry being displayed?
  924.  
  925.                                 if(EditEntryPtr)
  926.                                 {
  927.                                     set(IconPos[0], MUIA_Cycle_Active, EditEntryPtr->IconPos);
  928.                                     set(IconPos[1], MUIA_Cycle_Active, EditEntryPtr->IconPos);
  929.                                     set(IconX, MUIA_String_Integer, EditEntryPtr->Left);
  930.                                     set(IconX, MUIA_Disabled, (EditEntryPtr->IconPos != MODE_USE));
  931.                                     set(IconY, MUIA_String_Integer, EditEntryPtr->Top);
  932.                                     set(IconY, MUIA_Disabled, (EditEntryPtr->IconPos != MODE_USE));
  933.                                     set(Position, MUIA_Cycle_Active, 0);
  934.                                     set(Position, MUIA_Disabled, (EditEntryPtr->IconPos != MODE_USE));
  935.  
  936.                                     if(PosWindow)
  937.                                         CloseWindow(PosWindow);
  938.                                     PosWindow    = NULL;
  939.                                 }
  940.  
  941.                                     // Remove entries from listview (Used)
  942.  
  943.                                 DoMethod(UsedList, MUIM_List_Clear, NULL);
  944.  
  945.                                     // Sort the list again
  946.  
  947.                                 SortList(&FIconSema->VolumeList, TRUE);
  948.  
  949.                                     // Readd list
  950.  
  951.                                 ThisEntry    = (struct VolEntry *)FIconSema->VolumeList.lh_Head;
  952.                                 while(ThisEntry->Link.ln_Succ)
  953.                                 {
  954.                                     DoMethod(UsedList, MUIM_List_InsertSingle, (APTR)ThisEntry, MUIV_List_Insert_Bottom);
  955.  
  956.                                     ThisEntry    = (struct VolEntry *)ThisEntry->Link.ln_Succ;
  957.                                 }
  958.                             }
  959.  
  960.                                 // Check for action on PosWindow
  961.  
  962.                             if(PosWindow && (MySig & (1 << PosWindow->UserPort->mp_SigBit)))
  963.                             {
  964.                                 struct    IntuiMessage    *MyMsg;
  965.                                 ULONG            MsgClass;
  966.                                 LONG            OldX,
  967.                                             OldY;
  968.  
  969.  
  970.                                 while((MyMsg = (struct IntuiMessage *)GetMsg(PosWindow->UserPort)))
  971.                                 {
  972.                                     MsgClass    = MyMsg->Class;
  973.  
  974.                                     ReplyMsg((struct Message *)MyMsg);
  975.  
  976.                                     if(MsgClass == IDCMP_CHANGEWINDOW)
  977.                                     {
  978.                                             // Get old position
  979.  
  980.                                         get(IconX, MUIA_String_Integer, &OldX);
  981.                                         get(IconY, MUIA_String_Integer, &OldY);
  982.  
  983.                                         set(IconX, MUIA_String_Integer, (OldX < 0 ? PosWindow->LeftEdge - PosWindow->WScreen->Width : PosWindow->LeftEdge));
  984.                                         set(IconY, MUIA_String_Integer, (OldY < 0 ? PosWindow->TopEdge - PosWindow->WScreen->Height : PosWindow->TopEdge));
  985.                                     }
  986.                                 }
  987.                             }
  988.  
  989.                                 // Check for action on DrawerWindow
  990.  
  991.                             if(DrawerWindow && (MySig & (1 << DrawerWindow->UserPort->mp_SigBit)))
  992.                             {
  993.                                 struct    IntuiMessage    *MyMsg;
  994.                                 ULONG    MsgClass;
  995.  
  996.                                 while((MyMsg = (struct IntuiMessage *)GetMsg(DrawerWindow->UserPort)))
  997.                                 {
  998.                                     MsgClass    = MyMsg->Class;
  999.  
  1000.                                     ReplyMsg((struct Message *)MyMsg);
  1001.  
  1002.                                     if(MsgClass == IDCMP_CHANGEWINDOW)
  1003.                                     {
  1004.                                         set(WinX, MUIA_String_Integer, DrawerWindow->LeftEdge);
  1005.                                         set(WinY, MUIA_String_Integer, DrawerWindow->TopEdge);
  1006.                                         set(WinWidth, MUIA_String_Integer, DrawerWindow->Width);
  1007.                                         set(WinHeight, MUIA_String_Integer, DrawerWindow->Height);
  1008.                                     }
  1009.                                 }
  1010.                             }
  1011.                         }
  1012.                     }
  1013.  
  1014.                     if(PosWindow)
  1015.                         CloseWindow(PosWindow);
  1016.  
  1017.                         // Free list of available volumes
  1018.  
  1019.                     FreeDevVolList(&AvailableList);
  1020.                 }
  1021.  
  1022.                 RemoveApp();
  1023.             }
  1024.  
  1025.             RemoveFIconSema(FIconSema);
  1026.         }
  1027.     }
  1028.  
  1029.  
  1030.         // Close libs
  1031.  
  1032.     CloseAll();
  1033.  
  1034.  
  1035.         // Flush memory when requested
  1036.  
  1037.     if(FlushMemory)
  1038.     {
  1039.         APTR    FlushPtr;
  1040.         int    i;
  1041.  
  1042.         for(i = 0; i < 10; i++)
  1043.         {
  1044.             if((FlushPtr = AllocMem(0x1DCD6500, MEMF_PUBLIC)))
  1045.                 FreeMem(FlushPtr, 0x1DCD6500);
  1046.         }
  1047.     }
  1048.  
  1049.         // Send back WBStartUp Message
  1050.  
  1051.     if(WBenchMsg)
  1052.     {
  1053.         Forbid();
  1054.         ReplyMsg((struct Message *)WBenchMsg);
  1055.     }
  1056.     return(0);
  1057. }
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064. /**********************************************************************/
  1065. /*                        Functionreplacements                        */
  1066. /**********************************************************************/
  1067. void chkabort(void){;}
  1068. void __stdargs _XCEXIT(LONG Val){;}
  1069.  
  1070.  
  1071.  
  1072.  
  1073. /**********************************************************************/
  1074. /*                           Open libraries                           */
  1075. /**********************************************************************/
  1076. static BOOL OpenAll(void)
  1077. {
  1078.     if(!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37)))
  1079.     {
  1080.         DisplayError(ERR_OPEN, (ULONG)"intuition.library", 37);
  1081.         return(FALSE);
  1082.     }
  1083.  
  1084.     if(!(MUIMasterBase = OpenLibrary("muimaster.library", 0)))
  1085.     {
  1086.         DisplayError(ERR_OPEN, (ULONG)"muimaster.library", 7);
  1087.         return(FALSE);
  1088.     }
  1089.  
  1090.     if(!(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 37)))
  1091.     {
  1092.         DisplayError(ERR_OPEN, (ULONG)"dos.library", 37);
  1093.         return(FALSE);
  1094.     }
  1095.  
  1096.     if(!(IconBase = OpenLibrary("icon.library", 37)))
  1097.     {
  1098.         DisplayError(ERR_OPEN, (ULONG)"icon.library", 37);
  1099.         return(FALSE);
  1100.     }
  1101.  
  1102.     if(!(UtilityBase = OpenLibrary("utility.library", 37)))
  1103.     {
  1104.         DisplayError(ERR_OPEN, (ULONG)"utility.library", 37);
  1105.         return(FALSE);
  1106.     }
  1107.  
  1108.     if(!(IFFParseBase = OpenLibrary("iffparse.library", 37)))
  1109.     {
  1110.         DisplayError(ERR_OPEN, (ULONG)"iffparse.library", 37);
  1111.         return(FALSE);
  1112.     }
  1113.  
  1114.     if(!(AslBase = OpenLibrary("asl.library", 36)))
  1115.     {
  1116.         DisplayError(ERR_OPEN, (ULONG)"asl.library", 36);
  1117.         return(FALSE);
  1118.     }
  1119.  
  1120.     return(TRUE);
  1121. }
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130. /**********************************************************************/
  1131. /*                          Close libraries                           */
  1132. /**********************************************************************/
  1133. static void CloseAll(void)
  1134. {
  1135.     if(MUIMasterBase)
  1136.         CloseLibrary(MUIMasterBase);
  1137.  
  1138.     if(AslBase)
  1139.         CloseLibrary(AslBase);
  1140.  
  1141.     if(IFFParseBase)
  1142.         CloseLibrary(IFFParseBase);
  1143.  
  1144.     if(UtilityBase)
  1145.         CloseLibrary(UtilityBase);
  1146.  
  1147.     if(IconBase)
  1148.         CloseLibrary(IconBase);
  1149.  
  1150.     if(DOSBase)
  1151.         CloseLibrary((struct Library *)DOSBase);
  1152.  
  1153.     if(IntuitionBase)
  1154.         CloseLibrary((struct Library *)IntuitionBase);
  1155. }
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163. /**********************************************************************/
  1164. /*                         Create application                         */
  1165. /**********************************************************************/
  1166. static BOOL InitApp(void)
  1167. {
  1168.         // Init list, in case the App can not be created
  1169.  
  1170.     NewList(&AvailableList);
  1171.  
  1172.         // Create the Application window
  1173.  
  1174.     AppObject    = ApplicationObject,
  1175.                 MUIA_Application_Title,        "ForceIcon",
  1176.                 MUIA_Application_Version,    MUIVERS,
  1177.                 MUIA_Application_Copyright,    "©1993/94 Kai Iske",
  1178.                 MUIA_Application_Author,    "Kai Iske",
  1179.                 MUIA_Application_Description,    "Forces Disk.info to image/position",
  1180.                 MUIA_Application_Base,        "FIcon",
  1181.                 MUIA_Application_SingleTask,    TRUE,
  1182.                 MUIA_Application_DiskObject,    DObj    = GetDiskObjectNew("PROGDIR:ForceIcon"),
  1183.                 MUIA_HelpFile,            "ForceIcon.guide",
  1184.  
  1185.             // Now head for the main window
  1186.  
  1187.         SubWindow, MainWindow =    WindowObject,
  1188.                         MUIA_Window_Title,    "ForceIcon "REVISION" - "REVDATE,
  1189.                         MUIA_Window_ID,        'FIMW',
  1190.                         MUIA_Window_SizeGadget,    TRUE,
  1191.                         MUIA_HelpNode,        NODE_MAIN,
  1192.  
  1193.                 // Do the gadgets
  1194.  
  1195.             WindowContents,
  1196.             VGroup,
  1197.  
  1198.                     // Columns of input
  1199.  
  1200.                 Child,
  1201.                 ColGroup(2),
  1202.  
  1203.                         // Create left column
  1204.  
  1205.                     Child, VGroup,
  1206.                         MUIA_HelpNode,    NODE_LEFT,
  1207.                         GroupFrameT("Used volumes/devices"),
  1208.  
  1209.  
  1210.                             // Create ListView
  1211.  
  1212.                         Child, UsedList        =    ListviewObject,
  1213.                                             MUIA_Listview_Input,        TRUE,
  1214.                                             MUIA_Listview_List,        ListObject, InputListFrame,
  1215.                                                 MUIA_Background,        MUII_ListBack,
  1216.                                                 MUIA_List_Format,        "COL=0",
  1217.                                                 MUIA_List_DisplayHook,        &DispViewHook,
  1218.                                             End,
  1219.                                         End,
  1220.  
  1221.                         Child, EditEntry    =    TextObject, ButtonFrame,
  1222.                                             MUIA_Text_Contents,    "Edit entry...",
  1223.                                             MUIA_Text_PreParse,    "\33c",
  1224.                                             MUIA_Background,    MUII_ButtonBack,
  1225.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1226.                                             MUIA_Text_HiChar,    'E',
  1227.                                             MUIA_ControlChar,    'e',
  1228.                                             MUIA_Disabled,        TRUE,
  1229.                                         End,
  1230.  
  1231.                         Child, CopyEntry    =    TextObject, ButtonFrame,
  1232.                                             MUIA_Text_Contents,    "Copy entry...",
  1233.                                             MUIA_Text_PreParse,    "\33c",
  1234.                                             MUIA_Background,    MUII_ButtonBack,
  1235.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1236.                                             MUIA_Text_HiChar,    'C',
  1237.                                             MUIA_ControlChar,    'c',
  1238.                                             MUIA_Disabled,        TRUE,
  1239.                                         End,
  1240.  
  1241.                         Child, RemoveEntry    =    TextObject, ButtonFrame,
  1242.                                             MUIA_Text_Contents,    "Remove entry",
  1243.                                             MUIA_Text_PreParse,    "\33c",
  1244.                                             MUIA_Background,    MUII_ButtonBack,
  1245.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1246.                                             MUIA_Text_HiChar,    'R',
  1247.                                             MUIA_ControlChar,    'r',
  1248.                                             MUIA_Disabled,        TRUE,
  1249.                                         End,
  1250.                     End, // First column
  1251.  
  1252.  
  1253.                         // Create right column
  1254.  
  1255.                     Child, VGroup,
  1256.                         MUIA_HelpNode,    NODE_RIGHT,
  1257.                         GroupFrameT("Available volumes/devices"),
  1258.  
  1259.                             // Create ListView
  1260.  
  1261.                         Child, AvailList    =    ListviewObject,
  1262.                                             MUIA_Listview_Input,        TRUE,
  1263.                                             MUIA_Listview_List,        ListObject, InputListFrame,
  1264.                                                 MUIA_Background,        MUII_ListBack,
  1265.                                                 MUIA_List_Format,        "COL=0",
  1266.                                                 MUIA_List_DisplayHook,        &DispViewHook,
  1267.                                             End,
  1268.                                         End,
  1269.  
  1270.                         Child, AddEntry        =    TextObject, ButtonFrame,
  1271.                                             MUIA_Text_Contents,    "Add entry",
  1272.                                             MUIA_Text_PreParse,    "\33c",
  1273.                                             MUIA_Background,    MUII_ButtonBack,
  1274.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1275.                                             MUIA_Text_HiChar,    'd',
  1276.                                             MUIA_ControlChar,    'd',
  1277.                                             MUIA_Disabled,        TRUE,
  1278.                                         End,
  1279.  
  1280.                         Child, AddEntryMan    =    TextObject, ButtonFrame,
  1281.                                             MUIA_Text_Contents,    "Add manually...",
  1282.                                             MUIA_Text_PreParse,    "\33c",
  1283.                                             MUIA_Background,    MUII_ButtonBack,
  1284.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1285.                                             MUIA_Text_HiChar,    'm',
  1286.                                             MUIA_ControlChar,    'm',
  1287.                                         End,
  1288.  
  1289.                         Child, RescanList    =    TextObject, ButtonFrame,
  1290.                                             MUIA_Text_Contents,    "Rescan list",
  1291.                                             MUIA_Text_PreParse,    "\33c",
  1292.                                             MUIA_Background,    MUII_ButtonBack,
  1293.                                             MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1294.                                             MUIA_Text_HiChar,    'l',
  1295.                                             MUIA_ControlChar,    'l',
  1296.                                         End,
  1297.                     End, // Second column
  1298.                 End, // Columns
  1299.  
  1300.  
  1301.                 Child, VSpace(1),
  1302.  
  1303.                     // Create control gadgets
  1304.  
  1305.                 Child, HGroup, MUIA_Group_SameWidth, TRUE,
  1306.  
  1307.                     Child, SaveObj        =    TextObject, ButtonFrame,
  1308.                                         MUIA_Text_Contents,    "Save",
  1309.                                         MUIA_Text_PreParse,    "\33c",
  1310.                                         MUIA_Background,    MUII_ButtonBack,
  1311.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1312.                                         MUIA_Text_HiChar,    'S',
  1313.                                         MUIA_ControlChar,    's',
  1314.                                     End,
  1315.  
  1316.                     Child, UseObj        =    TextObject, ButtonFrame,
  1317.                                         MUIA_Text_Contents,    "Use",
  1318.                                         MUIA_Text_PreParse,    "\33c",
  1319.                                         MUIA_Background,    MUII_ButtonBack,
  1320.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1321.                                         MUIA_Text_HiChar,    'U',
  1322.                                         MUIA_ControlChar,    'u',
  1323.                                     End,
  1324.  
  1325.                     Child, AboutObj        =    TextObject, ButtonFrame,
  1326.                                         MUIA_Text_Contents,    "About",
  1327.                                         MUIA_Text_PreParse,    "\33c",
  1328.                                         MUIA_Background,    MUII_ButtonBack,
  1329.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1330.                                         MUIA_Text_HiChar,    'A',
  1331.                                         MUIA_ControlChar,    'a',
  1332.                                     End,
  1333.  
  1334.                     Child, HideObj        =    TextObject, ButtonFrame,
  1335.                                         MUIA_Text_Contents,    "Hide",
  1336.                                         MUIA_Text_PreParse,    "\33c",
  1337.                                         MUIA_Background,    MUII_ButtonBack,
  1338.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1339.                                         MUIA_Text_HiChar,    'H',
  1340.                                         MUIA_ControlChar,    'h',
  1341.                                     End,
  1342.  
  1343.                     Child, QuitObj        =    TextObject, ButtonFrame,
  1344.                                         MUIA_Text_Contents,    "Quit",
  1345.                                         MUIA_Text_PreParse,    "\33c",
  1346.                                         MUIA_Background,    MUII_ButtonBack,
  1347.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1348.                                         MUIA_Text_HiChar,    'Q',
  1349.                                         MUIA_ControlChar,    'q',
  1350.                                     End,
  1351.                 End, // Control panel
  1352.             End, // main group
  1353.         End, // Main window
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.             // Head for Editwindow
  1360.  
  1361.         SubWindow, EditWindow = WindowObject,
  1362.                         MUIA_Window_Title,    "Edit entry",
  1363.                         MUIA_Window_ID,        'FIEW',
  1364.                         MUIA_Window_SizeGadget,    TRUE,
  1365.                         MUIA_Window_NoMenus,    TRUE,
  1366.                         MUIA_HelpNode,        NODE_EDIT,
  1367.  
  1368.             WindowContents, VGroup,
  1369.  
  1370.                     // Volume group
  1371.  
  1372.                 Child, VGroup, GroupFrameT("Entry type/name"), MUIA_Group_SameWidth, TRUE,
  1373.                     Child, ColGroup(2),
  1374.                         Child, KeyLabel1("Volume", 'V'),
  1375.                         Child, VolumeName    =    StringObject, StringFrame,
  1376.                                             MUIA_String_Contents,    "",
  1377.                                             MUIA_String_MaxLen,    128,
  1378.                                             MUIA_String_Format,    MUIV_String_Format_Left,
  1379.                                             MUIA_String_BufferPos,    0,
  1380.                                             MUIA_String_Reject,    ":/",
  1381.                                             MUIA_ControlChar,    'v',
  1382.                                         End,
  1383.  
  1384.                         Child, KeyLabel1("Type", 'e'),
  1385.                         Child, VolumeType    =    KeyCycle(TypeEntries, 'e'),
  1386.                     End,
  1387.                 End, // Volume group
  1388.  
  1389.  
  1390.                 Child, ColGroup(2),
  1391.                         // Position group
  1392.  
  1393.                     Child, VGroup, GroupFrameT("Position settings"), MUIA_Group_SameWidth, TRUE,
  1394.  
  1395.                         Child, ColGroup(2),
  1396.  
  1397.                             Child, KeyLabel1("IconPos", 's'),
  1398.                             Child, IconPosGroup = PageGroup,
  1399.  
  1400.                                 Child, IconPos[0] =    CycleObject, ButtonFrame,
  1401.                                                     MUIA_Cycle_Active,    0,
  1402.                                                     MUIA_Cycle_Entries,    ModeEntriesVol,
  1403.                                                     MUIA_ControlChar,    's',
  1404.                                             End,
  1405.  
  1406.                                 Child, IconPos[1] =    CycleObject, ButtonFrame,
  1407.                                                     MUIA_Cycle_Active,    0,
  1408.                                                     MUIA_Cycle_Entries,    ModeEntriesDev,
  1409.                                                     MUIA_ControlChar,    's',
  1410.                                             End,
  1411.                             End,
  1412.  
  1413.                             Child, KeyLabel1("Current X", 'X'),
  1414.                             Child, HGroup,
  1415.                                 Child, IconX    =    StringObject, StringFrame,
  1416.                                                 MUIA_String_Contents,    "",
  1417.                                                 MUIA_String_MaxLen,    7,
  1418.                                                 MUIA_String_Format,    MUIV_String_Format_Center,
  1419.                                                 MUIA_String_BufferPos,    1,
  1420.                                                 MUIA_String_Integer,    TRUE,
  1421.                                                 MUIA_ControlChar,    'x',
  1422.                                             End,
  1423.  
  1424.                                 Child, KeyLabel1("Current Y", 'Y'),
  1425.                                 Child, IconY    =    StringObject, StringFrame,
  1426.                                                 MUIA_String_Contents,    "",
  1427.                                                 MUIA_String_MaxLen,    7,
  1428.                                                 MUIA_String_Format,    MUIV_String_Format_Center,
  1429.                                                 MUIA_String_BufferPos,    1,
  1430.                                                 MUIA_String_Integer,    TRUE,
  1431.                                                 MUIA_ControlChar,    'y',
  1432.                                             End,
  1433.                             End,
  1434.  
  1435.                             Child, KeyLabel1("Position", 'P'),
  1436.                             Child, Position    =    CycleObject, ButtonFrame,
  1437.                                                 MUIA_Cycle_Active,    0,
  1438.                                                 MUIA_Cycle_Entries,    PositionEntries,
  1439.                                                 MUIA_ControlChar,    'p',
  1440.                                         End,
  1441.                         End,
  1442.                     End, // position group
  1443.  
  1444.  
  1445.  
  1446.                         // Icon group
  1447.  
  1448.                     Child, VGroup, GroupFrameT("Icon settings"), MUIA_Group_SameWidth, TRUE,
  1449.  
  1450.                         Child, VSpace(0),
  1451.                         Child, ColGroup(2),
  1452.  
  1453.                             Child, KeyLabel1("Use Icon", 'U'),
  1454.                             Child, UseIconGroup    = PageGroup,
  1455.  
  1456.                                 Child, UseIcon[0] =    CycleObject, ButtonFrame,
  1457.                                                     MUIA_Cycle_Active,    0,
  1458.                                                     MUIA_Cycle_Entries,    ModeEntriesVol,
  1459.                                                     MUIA_ControlChar,    'u',
  1460.                                             End,
  1461.  
  1462.                                 Child, UseIcon[1] =    CycleObject, ButtonFrame,
  1463.                                                     MUIA_Cycle_Active,    0,
  1464.                                                     MUIA_Cycle_Entries,    ModeEntriesDev,
  1465.                                                     MUIA_ControlChar,    'u',
  1466.                                             End,
  1467.                             End,
  1468.  
  1469.  
  1470.                             Child, KeyLabel1("Icon", 'I'),
  1471.                             Child, IconName            = PopaslObject,
  1472.                                                 MUIA_Popstring_String,        KeyString(0, 254, 'i'),
  1473.                                                 MUIA_Popstring_Button,        PopButton(MUII_PopFile),
  1474.                                                 MUIA_Popasl_Type,        ASL_FileRequest,
  1475.                                                 ASLFR_TitleText,        "Please select an icon...",
  1476.                                             End,
  1477.                         End,
  1478.                         Child, VSpace(0),
  1479.                     End, // Icon group
  1480.                 End,
  1481.  
  1482.                     // Create window group
  1483.  
  1484.                 Child, VGroup, GroupFrameT("Window settings"), MUIA_Group_SameWidth, TRUE,
  1485.  
  1486.                     Child, ColGroup(2),
  1487.  
  1488.                         Child, KeyLabel1("Use window", 'd'),
  1489.                         Child, UseWindowGroup    = PageGroup,
  1490.  
  1491.                             Child, UseWindow[0] =    CycleObject, ButtonFrame,
  1492.                                                 MUIA_Cycle_Active,    0,
  1493.                                                 MUIA_Cycle_Entries,    ModeEntriesVol,
  1494.                                                 MUIA_ControlChar,    'd',
  1495.                                         End,
  1496.  
  1497.                             Child, UseWindow[1] =    CycleObject, ButtonFrame,
  1498.                                                 MUIA_Cycle_Active,    0,
  1499.                                                 MUIA_Cycle_Entries,    ModeEntriesDev,
  1500.                                                 MUIA_ControlChar,    'd',
  1501.                                         End,
  1502.                         End,
  1503.  
  1504.  
  1505.                         Child, KeyLabel2("Left", 'L'),
  1506.                         Child, HGroup,
  1507.                             Child, WinX    =    StringObject, StringFrame,
  1508.                                             MUIA_String_Contents,    "",
  1509.                                             MUIA_String_MaxLen,    5,
  1510.                                             MUIA_String_Format,    MUIV_String_Format_Center,
  1511.                                             MUIA_String_BufferPos,    1,
  1512.                                             MUIA_String_Integer,    TRUE,
  1513.                                             MUIA_ControlChar,    'l',
  1514.                                         End,
  1515.  
  1516.                             Child, KeyLabel1("Top", 'T'),
  1517.                             Child, WinY    =    StringObject, StringFrame,
  1518.                                             MUIA_String_Contents,    "",
  1519.                                             MUIA_String_MaxLen,    5,
  1520.                                             MUIA_String_Format,    MUIV_String_Format_Center,
  1521.                                             MUIA_String_BufferPos,    1,
  1522.                                             MUIA_String_Integer,    TRUE,
  1523.                                             MUIA_ControlChar,    't',
  1524.                                         End,
  1525.  
  1526.                             Child, KeyLabel2("Width", 'W'),
  1527.                             Child, WinWidth    =    StringObject, StringFrame,
  1528.                                             MUIA_String_Contents,    "",
  1529.                                             MUIA_String_MaxLen,    5,
  1530.                                             MUIA_String_Format,    MUIV_String_Format_Center,
  1531.                                             MUIA_String_BufferPos,    1,
  1532.                                             MUIA_String_Integer,    TRUE,
  1533.                                             MUIA_ControlChar,    'h',
  1534.                                         End,
  1535.  
  1536.                             Child, KeyLabel1("Height", 'H'),
  1537.                             Child, WinHeight =    StringObject, StringFrame,
  1538.                                             MUIA_String_Contents,    "",
  1539.                                             MUIA_String_MaxLen,    5,
  1540.                                             MUIA_String_Format,    MUIV_String_Format_Center,
  1541.                                             MUIA_String_BufferPos,    1,
  1542.                                             MUIA_String_Integer,    TRUE,
  1543.                                             MUIA_ControlChar,    'w',
  1544.                                         End,
  1545.                         End,
  1546.  
  1547.                         Child, KeyLabel1("Window", 'n'),
  1548.                         Child, LookWin =    CycleObject, ButtonFrame,
  1549.                                             MUIA_Cycle_Active,    0,
  1550.                                             MUIA_Cycle_Entries,    LookWinEntries,
  1551.                                             MUIA_ControlChar,    'n',
  1552.                                     End,
  1553.  
  1554.  
  1555.  
  1556.                         Child, KeyLabel1("Use flags", 'f'),
  1557.                         Child, UseFlagsGroup    = PageGroup,
  1558.  
  1559.                             Child, UseFlags[0] =    CycleObject, ButtonFrame,
  1560.                                                 MUIA_Cycle_Active,    0,
  1561.                                                 MUIA_Cycle_Entries,    ModeEntriesVol,
  1562.                                                 MUIA_ControlChar,    'f',
  1563.                                         End,
  1564.  
  1565.                             Child, UseFlags[1] =    CycleObject, ButtonFrame,
  1566.                                                 MUIA_Cycle_Active,    0,
  1567.                                                 MUIA_Cycle_Entries,    ModeEntriesDev,
  1568.                                                 MUIA_ControlChar,    'f',
  1569.                                         End,
  1570.                         End,
  1571.  
  1572.                         Child, KeyLabel1("Flags", 'g'),
  1573.                         Child, FlagModes    =    CycleObject, ButtonFrame,
  1574.                                             MUIA_Cycle_Active,    0,
  1575.                                             MUIA_Cycle_Entries,    FlagModesEntries,
  1576.                                             MUIA_ControlChar,    'g',
  1577.                                     End,
  1578.                     End,
  1579.                 End, // window group
  1580.  
  1581.  
  1582.  
  1583.                 Child, VSpace(1),
  1584.  
  1585.                     // Create control gadgets
  1586.  
  1587.                 Child, HGroup, MUIA_Group_SameWidth, TRUE,
  1588.  
  1589.                     Child, EditOkObj    =    TextObject, ButtonFrame,
  1590.                                         MUIA_Text_Contents,    "Ok",
  1591.                                         MUIA_Text_PreParse,    "\33c",
  1592.                                         MUIA_Background,    MUII_ButtonBack,
  1593.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1594.                                         MUIA_Text_HiChar,    'O',
  1595.                                         MUIA_ControlChar,    'o',
  1596.                                     End,
  1597.  
  1598.                     Child, EditCancelObj    =    TextObject, ButtonFrame,
  1599.                                         MUIA_Text_Contents,    "Cancel",
  1600.                                         MUIA_Text_PreParse,    "\33c",
  1601.                                         MUIA_Background,    MUII_ButtonBack,
  1602.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1603.                                         MUIA_Text_HiChar,    'C',
  1604.                                         MUIA_ControlChar,    'c',
  1605.                                     End,
  1606.                 End, // Control gadgets
  1607.             End, // Edit contents
  1608.         End, // Edit window
  1609.  
  1610.  
  1611.  
  1612.  
  1613.             // Head for "manually" window
  1614.  
  1615.         SubWindow, ManWindow = WindowObject,
  1616.                         MUIA_Window_Title,    "",
  1617.                         MUIA_Window_ID,        'FINW',
  1618.                         MUIA_Window_SizeGadget,    TRUE,
  1619.                         MUIA_Window_NoMenus,    TRUE,
  1620.                         MUIA_HelpNode,        NODE_MANUAL,
  1621.  
  1622.             WindowContents, VGroup,
  1623.  
  1624.                 Child, VGroup, GroupFrameT("Entry type/name"),
  1625.  
  1626.                         // String gadget
  1627.  
  1628.                     Child, ColGroup(2),
  1629.  
  1630.                         Child, KeyLabel1("Volume", 'V'),
  1631.                         Child, ManVolName    =    StringObject, StringFrame,
  1632.                                         MUIA_String_Contents,    "",
  1633.                                         MUIA_String_MaxLen,    128,
  1634.                                         MUIA_String_Format,    MUIV_String_Format_Left,
  1635.                                         MUIA_String_BufferPos,    1,
  1636.                                         MUIA_String_Reject,    ":/",
  1637.                                         MUIA_ControlChar,    'v',
  1638.                                     End,
  1639.  
  1640.                         Child, KeyLabel1("Type", 'T'),
  1641.                         Child, ManVolType    =    KeyCycle(TypeEntries, 't'),
  1642.                     End,
  1643.                 End,
  1644.  
  1645.                 Child, VSpace(1),
  1646.  
  1647.                     // Control gadgets
  1648.  
  1649.                 Child, HGroup, MUIA_Group_SameWidth, TRUE,
  1650.  
  1651.                     Child, ManOkObj    =        TextObject, ButtonFrame,
  1652.                                         MUIA_Text_Contents,    "Ok",
  1653.                                         MUIA_Text_PreParse,    "\33c",
  1654.                                         MUIA_Background,    MUII_ButtonBack,
  1655.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1656.                                         MUIA_Text_HiChar,    'O',
  1657.                                         MUIA_ControlChar,    'o',
  1658.                                     End,
  1659.  
  1660.                     Child, ManCancelObj    =    TextObject, ButtonFrame,
  1661.                                         MUIA_Text_Contents,    "Cancel",
  1662.                                         MUIA_Text_PreParse,    "\33c",
  1663.                                         MUIA_Background,    MUII_ButtonBack,
  1664.                                         MUIA_InputMode,        MUIV_InputMode_RelVerify,
  1665.                                         MUIA_Text_HiChar,    'C',
  1666.                                         MUIA_ControlChar,    'c',
  1667.                                     End,
  1668.                 End, // Control gadgets
  1669.             End, // Man contents
  1670.         End, // Man window
  1671.     End; // End application
  1672.  
  1673.         // Appobject there and got a list of available entries ???
  1674.  
  1675.     if(AppObject && GetDevVolList(&AvailableList))
  1676.     {
  1677.         struct    VolEntry    *ThisEntry;
  1678.         int            i;
  1679.  
  1680.  
  1681.             // Main window settings
  1682.  
  1683.  
  1684.             // SetCycle chain
  1685.  
  1686.         DoMethod(MainWindow, MUIM_Window_SetCycleChain,
  1687.             UsedList,
  1688.             AvailList,
  1689.             EditEntry,
  1690.             CopyEntry,
  1691.             RemoveEntry,
  1692.             AddEntry,
  1693.             AddEntryMan,
  1694.             RescanList,
  1695.             SaveObj,
  1696.             UseObj,
  1697.             AboutObj,
  1698.             HideObj,
  1699.             QuitObj,
  1700.         NULL);
  1701.  
  1702.             // Set default object
  1703.  
  1704.         set(MainWindow, MUIA_Window_DefaultObject, AvailList);
  1705.  
  1706.             // Set notifications
  1707.  
  1708.         DoMethod(MainWindow, MUIM_Notify,
  1709.             MUIA_Window_CloseRequest,    TRUE,
  1710.             AppObject,            2,
  1711.             MUIM_Application_ReturnID,    ID_HIDE);
  1712.  
  1713.             // Set IDs for gadgets
  1714.  
  1715.         DoMethod(UsedList, MUIM_Notify,
  1716.             MUIA_Listview_DoubleClick,    TRUE,
  1717.             AppObject,            2,
  1718.             MUIM_Application_ReturnID,    ID_USEDLIST);
  1719.  
  1720.         DoMethod(EditEntry, MUIM_Notify,
  1721.             MUIA_Pressed,            FALSE,
  1722.             AppObject,            2,
  1723.             MUIM_Application_ReturnID,    ID_EDITENTRY);
  1724.  
  1725.         DoMethod(CopyEntry, MUIM_Notify,
  1726.             MUIA_Pressed,            FALSE,
  1727.             AppObject,            2,
  1728.             MUIM_Application_ReturnID,    ID_COPYENTRY);
  1729.  
  1730.         DoMethod(RemoveEntry, MUIM_Notify,
  1731.             MUIA_Pressed,            FALSE,
  1732.             AppObject,            2,
  1733.             MUIM_Application_ReturnID,    ID_REMOVEENTRY);
  1734.  
  1735.         DoMethod(AvailList, MUIM_Notify,
  1736.             MUIA_Listview_DoubleClick,    TRUE,
  1737.             AppObject,            2,
  1738.             MUIM_Application_ReturnID,    ID_AVAILLIST);
  1739.  
  1740.         DoMethod(AddEntry, MUIM_Notify,
  1741.             MUIA_Pressed,            FALSE,
  1742.             AppObject,            2,
  1743.             MUIM_Application_ReturnID,    ID_ADDENTRY);
  1744.  
  1745.         DoMethod(AddEntryMan, MUIM_Notify,
  1746.             MUIA_Pressed,            FALSE,
  1747.             AppObject,            2,
  1748.             MUIM_Application_ReturnID,    ID_ADDENTRYMAN);
  1749.  
  1750.         DoMethod(RescanList, MUIM_Notify,
  1751.             MUIA_Pressed,            FALSE,
  1752.             AppObject,            2,
  1753.             MUIM_Application_ReturnID,    ID_RESCANLIST);
  1754.  
  1755.         DoMethod(SaveObj, MUIM_Notify,
  1756.             MUIA_Pressed,            FALSE,
  1757.             AppObject,            2,
  1758.             MUIM_Application_ReturnID,    ID_SAVE);
  1759.  
  1760.         DoMethod(UseObj, MUIM_Notify,
  1761.             MUIA_Pressed,            FALSE,
  1762.             AppObject,            2,
  1763.             MUIM_Application_ReturnID,    ID_USE);
  1764.  
  1765.         DoMethod(AboutObj, MUIM_Notify,
  1766.             MUIA_Pressed,            FALSE,
  1767.             AppObject,            2,
  1768.             MUIM_Application_ReturnID,    ID_ABOUT);
  1769.  
  1770.         DoMethod(HideObj, MUIM_Notify,
  1771.             MUIA_Pressed,            FALSE,
  1772.             AppObject,            2,
  1773.             MUIM_Application_ReturnID,    ID_HIDE);
  1774.  
  1775.         DoMethod(QuitObj, MUIM_Notify,
  1776.             MUIA_Pressed,            FALSE,
  1777.             AppObject,            2,
  1778.             MUIM_Application_ReturnID,    ID_QUIT);
  1779.  
  1780.             // Set disable notify-hooks
  1781.  
  1782.         DoMethod(UsedList, MUIM_Notify,
  1783.             MUIA_List_Active,        MUIV_EveryTime,
  1784.             AppObject,            3,
  1785.             MUIM_CallHook,            &DisableHook, UsedList);
  1786.  
  1787.  
  1788.         DoMethod(AvailList, MUIM_Notify,
  1789.             MUIA_List_Active,        MUIV_EveryTime,
  1790.             AppObject,            3,
  1791.             MUIM_CallHook,            &DisableHook, AvailList);
  1792.  
  1793.  
  1794.  
  1795.             // Edit window settings
  1796.  
  1797.             // Set cycle chain
  1798.  
  1799.         DoMethod(EditWindow, MUIM_Window_SetCycleChain,
  1800.             VolumeName,
  1801.             VolumeType,
  1802.             IconPos[0],
  1803.             IconPos[1],
  1804.             IconX,
  1805.             IconY,
  1806.             Position,
  1807.             UseIcon[0],
  1808.             UseIcon[1],
  1809.             IconName,
  1810.             UseWindow[0],
  1811.             UseWindow[1],
  1812.             WinX,
  1813.             WinY,
  1814.             WinWidth,
  1815.             WinHeight,
  1816.             UseFlags[0],
  1817.             UseFlags[1],
  1818.             FlagModes,
  1819.             EditOkObj,
  1820.             EditCancelObj,
  1821.         NULL);
  1822.  
  1823.  
  1824.             // Set notifications
  1825.  
  1826.         DoMethod(EditWindow, MUIM_Notify,
  1827.             MUIA_Window_CloseRequest,    TRUE,
  1828.             AppObject,            2,
  1829.             MUIM_Application_ReturnID,    ID_EDITCANCEL);
  1830.  
  1831.  
  1832.         DoMethod(EditOkObj, MUIM_Notify,
  1833.             MUIA_Pressed,            FALSE,
  1834.             AppObject,            2,
  1835.             MUIM_Application_ReturnID,    ID_EDITOK);
  1836.  
  1837.  
  1838.         DoMethod(EditCancelObj, MUIM_Notify,
  1839.             MUIA_Pressed,            FALSE,
  1840.             AppObject,            2,
  1841.             MUIM_Application_ReturnID,    ID_EDITCANCEL);
  1842.  
  1843.         DoMethod(Position, MUIM_Notify,
  1844.             MUIA_Cycle_Active,        MUIV_EveryTime,
  1845.             AppObject,            2,
  1846.             MUIM_Application_ReturnID,    ID_POSITION);
  1847.  
  1848.         DoMethod(LookWin, MUIM_Notify,
  1849.             MUIA_Cycle_Active,        MUIV_EveryTime,
  1850.             AppObject,            2,
  1851.             MUIM_Application_ReturnID,    ID_DRAWER);
  1852.  
  1853.         DoMethod(IconX, MUIM_Notify,
  1854.             MUIA_String_Acknowledge,    MUIV_EveryTime,
  1855.             AppObject,            2,
  1856.             MUIM_Application_ReturnID,    ID_ICONX);
  1857.  
  1858.         DoMethod(IconY, MUIM_Notify,
  1859.             MUIA_String_Acknowledge,    MUIV_EveryTime,
  1860.             AppObject,            2,
  1861.             MUIM_Application_ReturnID,    ID_ICONY);
  1862.  
  1863.         DoMethod(WinX, MUIM_Notify,
  1864.             MUIA_String_Acknowledge,    MUIV_EveryTime,
  1865.             AppObject,            2,
  1866.             MUIM_Application_ReturnID,    ID_WINX);
  1867.  
  1868.         DoMethod(WinY, MUIM_Notify,
  1869.             MUIA_String_Acknowledge,    MUIV_EveryTime,
  1870.             AppObject,            2,
  1871.             MUIM_Application_ReturnID,    ID_WINY);
  1872.  
  1873.         DoMethod(WinWidth, MUIM_Notify,
  1874.             MUIA_String_Acknowledge,    MUIV_EveryTime,
  1875.             AppObject,            2,
  1876.             MUIM_Application_ReturnID,    ID_WINWIDTH);
  1877.  
  1878.         DoMethod(WinHeight, MUIM_Notify,
  1879.             MUIA_String_Acknowledge,    MUIV_EveryTime,
  1880.             AppObject,            2,
  1881.             MUIM_Application_ReturnID,    ID_WINHEIGHT);
  1882.  
  1883.         DoMethod(VolumeType, MUIM_Notify,
  1884.             MUIA_Cycle_Active,        MUIV_EveryTime,
  1885.             IconPosGroup,            3,
  1886.             MUIM_Set, MUIA_Group_ActivePage, MUIV_TriggerValue);
  1887.  
  1888.         DoMethod(VolumeType, MUIM_Notify,
  1889.             MUIA_Cycle_Active,        MUIV_EveryTime,
  1890.             AppObject,            2,
  1891.             MUIM_CallHook, &PageChangeHook);
  1892.  
  1893.  
  1894.  
  1895.         DoMethod(VolumeType, MUIM_Notify,
  1896.             MUIA_Cycle_Active,        MUIV_EveryTime,
  1897.             UseIconGroup,            3,
  1898.             MUIM_Set, MUIA_Group_ActivePage, MUIV_TriggerValue);
  1899.  
  1900.         DoMethod(VolumeType, MUIM_Notify,
  1901.             MUIA_Cycle_Active,        MUIV_EveryTime,
  1902.             UseWindowGroup,            3,
  1903.             MUIM_Set, MUIA_Group_ActivePage, MUIV_TriggerValue);
  1904.  
  1905.         DoMethod(VolumeType, MUIM_Notify,
  1906.             MUIA_Cycle_Active,        MUIV_EveryTime,
  1907.             UseFlagsGroup,            3,
  1908.             MUIM_Set, MUIA_Group_ActivePage, MUIV_TriggerValue);
  1909.  
  1910.  
  1911.         for(i = 0; i < 2; i++)
  1912.         {
  1913.             DoMethod(IconPos[i], MUIM_Notify,
  1914.                 MUIA_Cycle_Active,        MUIV_EveryTime,
  1915.                 AppObject,            3,
  1916.                 MUIM_CallHook,            &DisableHook, IconPos[i]);
  1917.  
  1918.  
  1919.             DoMethod(UseIcon[i], MUIM_Notify,
  1920.                 MUIA_Cycle_Active,        MUIV_EveryTime,
  1921.                 AppObject,            3,
  1922.                 MUIM_CallHook,            &DisableHook, UseIcon[i]);
  1923.  
  1924.  
  1925.             DoMethod(UseWindow[i], MUIM_Notify,
  1926.                 MUIA_Cycle_Active,        MUIV_EveryTime,
  1927.                 AppObject,            3,
  1928.                 MUIM_CallHook,            &DisableHook, UseWindow[i]);
  1929.  
  1930.  
  1931.             DoMethod(UseFlags[i], MUIM_Notify,
  1932.                 MUIA_Cycle_Active,        MUIV_EveryTime,
  1933.                 AppObject,            3,
  1934.                 MUIM_CallHook,            &DisableHook, UseFlags[i]);
  1935.         }
  1936.  
  1937.  
  1938.  
  1939.  
  1940.             // Man window settings
  1941.  
  1942.             // Set cycle chaing
  1943.  
  1944.         DoMethod(ManWindow, MUIM_Window_SetCycleChain,
  1945.             ManVolName,
  1946.             ManVolType,
  1947.             ManOkObj,
  1948.             ManCancelObj,
  1949.         NULL);
  1950.  
  1951.  
  1952.             // Set notifications
  1953.  
  1954.         DoMethod(ManWindow, MUIM_Notify,
  1955.             MUIA_Window_CloseRequest,    TRUE,
  1956.             AppObject,            2,
  1957.             MUIM_Application_ReturnID,    ID_MANCANCEL);
  1958.  
  1959.  
  1960.         DoMethod(ManOkObj, MUIM_Notify,
  1961.             MUIA_Pressed,            FALSE,
  1962.             AppObject,            2,
  1963.             MUIM_Application_ReturnID,    ID_MANOK);
  1964.  
  1965.  
  1966.         DoMethod(ManCancelObj, MUIM_Notify,
  1967.             MUIA_Pressed,            FALSE,
  1968.             AppObject,            2,
  1969.             MUIM_Application_ReturnID,    ID_MANCANCEL);
  1970.  
  1971.  
  1972.  
  1973.  
  1974.             // Add list of used entries
  1975.  
  1976.         ObtainSemaphore(&FIconSema->FIconSema);
  1977.         ThisEntry    = (struct VolEntry *)FIconSema->VolumeList.lh_Head;
  1978.  
  1979.         while(ThisEntry->Link.ln_Succ)
  1980.         {
  1981.             DoMethod(UsedList, MUIM_List_InsertSingle, (APTR)ThisEntry, MUIV_List_Insert_Bottom);
  1982.  
  1983.             ThisEntry    = (struct VolEntry *)ThisEntry->Link.ln_Succ;
  1984.         }
  1985.         ReleaseSemaphore(&FIconSema->FIconSema);
  1986.  
  1987.  
  1988.             // Add list of available entries
  1989.  
  1990.         ThisEntry    = (struct VolEntry *)AvailableList.lh_Head;
  1991.  
  1992.         while(ThisEntry->Link.ln_Succ)
  1993.         {
  1994.             DoMethod(AvailList, MUIM_List_InsertSingle, (APTR)ThisEntry, MUIV_List_Insert_Bottom);
  1995.  
  1996.             ThisEntry    = (struct VolEntry *)ThisEntry->Link.ln_Succ;
  1997.         }
  1998.  
  1999.  
  2000.  
  2001.  
  2002.             // Open main window
  2003.  
  2004.         set(MainWindow, MUIA_Window_Open, TRUE);
  2005.     }
  2006.     else
  2007.     {
  2008.         if(MUI_Error() != MUIE_SingleTask)
  2009.             DisplayError(ERR_NO_APP, NULL);
  2010.     }
  2011.  
  2012.  
  2013.     return((BOOL)(AppObject != NULL));
  2014. }
  2015.  
  2016.  
  2017.  
  2018.  
  2019. /**********************************************************************/
  2020. /*                       Remove our application                       */
  2021. /**********************************************************************/
  2022. static void RemoveApp(void)
  2023. {
  2024.     if(AppObject)
  2025.     {
  2026.         set(MainWindow, MUIA_Window_Open, FALSE);
  2027.         MUI_DisposeObject(AppObject);
  2028.     }
  2029.  
  2030.         // Dispose DiskObject
  2031.  
  2032.     if(DObj)
  2033.         FreeDiskObject(DObj);
  2034. }
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042. /**********************************************************************/
  2043. /*                          Display function                          */
  2044. /**********************************************************************/
  2045. static ULONG    __saveds __asm DispViewFunc(register __a0 struct Hook *MyHook, register __a2 char **array, register __a1 struct VolEntry *Data)
  2046. {
  2047.     static        char    Buffer[140];
  2048.  
  2049.     if(Data->Link.ln_Type == LDF_VOLUMES)
  2050.     {
  2051.         strcpy(Buffer, "\0338");
  2052.         strcat(Buffer, Data->VolName);
  2053.     }
  2054.     else
  2055.         strcpy(Buffer, Data->VolName);
  2056.  
  2057.     *array        = Buffer;
  2058.  
  2059.     return(NULL);
  2060. }
  2061.  
  2062.  
  2063.  
  2064.  
  2065.  
  2066.  
  2067. /**********************************************************************/
  2068. /*                   Hook for setting gadgetstates                    */
  2069. /**********************************************************************/
  2070. static ULONG    __saveds __asm DisableFunc(register __a0 struct Hook *MyHook, register __a2 APTR Obj, register __a1 APTR *Data)
  2071. {
  2072.     ULONG    State;
  2073.  
  2074.     if(*Data == UsedList)
  2075.     {
  2076.         get(UsedList, MUIA_List_Active, &State);
  2077.         State    = (State == MUIV_List_Active_Off ? TRUE : FALSE);
  2078.         set(EditEntry, MUIA_Disabled, State);
  2079.         set(CopyEntry, MUIA_Disabled, State);
  2080.         set(RemoveEntry, MUIA_Disabled, State);
  2081.     }
  2082.     else if(*Data == AvailList)
  2083.     {
  2084.         get(AvailList, MUIA_List_Active, &State);
  2085.         State    = (State == MUIV_List_Active_Off ? TRUE : FALSE);
  2086.         set(AddEntry, MUIA_Disabled, State);
  2087.     }
  2088.     else if((*Data == IconPos[0]) || (*Data == IconPos[1]))
  2089.     {
  2090.         get(*Data, MUIA_Cycle_Active, &State);
  2091.         set(IconX, MUIA_Disabled, (State != MODE_USE));
  2092.         set(IconY, MUIA_Disabled, (State != MODE_USE));
  2093.         set(Position, MUIA_Disabled, (State != MODE_USE));
  2094.     }
  2095.     else if((*Data == UseIcon[0]) || (*Data == UseIcon[1]))
  2096.     {
  2097.         get(*Data, MUIA_Cycle_Active, &State);
  2098.         set(IconName, MUIA_Disabled, (State != MODE_USE));
  2099.     }
  2100.     else if((*Data == UseWindow[0]) || (*Data == UseWindow[1]))
  2101.     {
  2102.         get(*Data, MUIA_Cycle_Active, &State);
  2103.         set(WinX, MUIA_Disabled, (State != MODE_USE));
  2104.         set(WinY, MUIA_Disabled, (State != MODE_USE));
  2105.         set(WinWidth, MUIA_Disabled, (State != MODE_USE));
  2106.         set(WinHeight, MUIA_Disabled, (State != MODE_USE));
  2107.         set(LookWin, MUIA_Disabled, (State != MODE_USE));
  2108.     }
  2109.     else if((*Data == UseFlags[0]) || (*Data == UseFlags[1]))
  2110.     {
  2111.         get(*Data, MUIA_Cycle_Active, &State);
  2112.         set(FlagModes, MUIA_Disabled, (State != MODE_USE));
  2113.     }
  2114.  
  2115.     return(0);
  2116. }
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123. /**********************************************************************/
  2124. /*   Change gadget states on settings of cycle gadget (VolumeType)    */
  2125. /**********************************************************************/
  2126. static ULONG    __saveds __asm PageChangeFunc(register __a0 struct Hook *MyHook, register __a2 APTR Obj, register __a1 APTR *Data)
  2127. {
  2128.     ULONG    Page;
  2129.     ULONG    State;
  2130.  
  2131.         // Get current page
  2132.  
  2133.     get(VolumeType, MUIA_Cycle_Active, &Page);
  2134.  
  2135.         // Set gadget states
  2136.  
  2137.     get(IconPos[Page], MUIA_Cycle_Active, &State);
  2138.     set(IconX, MUIA_Disabled, (State != MODE_USE));
  2139.     set(IconY, MUIA_Disabled, (State != MODE_USE));
  2140.     set(Position, MUIA_Disabled, (State != MODE_USE));
  2141.  
  2142.     get(UseIcon[Page], MUIA_Cycle_Active, &State);
  2143.     set(IconName, MUIA_Disabled, (State != MODE_USE));
  2144.  
  2145.     get(UseWindow[Page], MUIA_Cycle_Active, &State);
  2146.     set(WinX, MUIA_Disabled, (State != MODE_USE));
  2147.     set(WinY, MUIA_Disabled, (State != MODE_USE));
  2148.     set(WinWidth, MUIA_Disabled, (State != MODE_USE));
  2149.     set(WinHeight, MUIA_Disabled, (State != MODE_USE));
  2150.     set(LookWin, MUIA_Disabled, (State != MODE_USE));
  2151.  
  2152.     get(UseFlags[Page], MUIA_Cycle_Active, &State);
  2153.     set(FlagModes, MUIA_Disabled, (State != MODE_USE));
  2154.  
  2155.     return(0);
  2156. }
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169. /**********************************************************************/
  2170. /*             Add a new volumes/device to the used list              */
  2171. /**********************************************************************/
  2172. static struct VolEntry *AddNewVolume(char *Name, ULONG Type, struct VolEntry *CopyPtr)
  2173. {
  2174.     struct    VolEntry    *NewEntry    = NULL,
  2175.                 *ThisEntry;
  2176.  
  2177.         // Check for exitance
  2178.  
  2179.     if(CheckExists(Name))
  2180.     {
  2181.         DisplayError(ERR_EXISTS, (ULONG)Name);
  2182.         return(NewEntry);
  2183.     }
  2184.  
  2185.         // Try to get our semaphore
  2186.  
  2187.     ObtainSemaphore(&FIconSema->FIconSema);
  2188.  
  2189.         // Get memory for new entry
  2190.  
  2191.     if((NewEntry = AllocVecPool(FIconSema, sizeof(struct VolEntry))))
  2192.     {
  2193.             // One entry plus
  2194.  
  2195.         FIconSema->VolumeList.lh_Type++;
  2196.  
  2197.             // Add entry and fill out structure
  2198.  
  2199.         if(Type == LDF_VOLUMES)
  2200.             AddHead(&FIconSema->VolumeList, (struct Node *)NewEntry);
  2201.         else
  2202.             AddTail(&FIconSema->VolumeList, (struct Node *)NewEntry);
  2203.  
  2204.         NewEntry->Link.ln_Name    = NewEntry->VolName;
  2205.         NewEntry->Link.ln_Type    = Type;
  2206.         strcpy(NewEntry->VolName, Name);
  2207.  
  2208.             // Copy contents of other entry ???
  2209.  
  2210.         if(CopyPtr)
  2211.         {
  2212.             strcpy(NewEntry->IconName, CopyPtr->IconName);
  2213.             NewEntry->Left        = CopyPtr->Left;
  2214.             NewEntry->Top        = CopyPtr->Top;
  2215.             NewEntry->IconPos    = CopyPtr->IconPos;
  2216.             NewEntry->UseAlt    = CopyPtr->UseAlt;
  2217.             NewEntry->UseWin    = CopyPtr->UseWin;
  2218.             NewEntry->WinX        = CopyPtr->WinX;
  2219.             NewEntry->WinY        = CopyPtr->WinY;
  2220.             NewEntry->WinWidth    = CopyPtr->WinWidth;
  2221.             NewEntry->WinHeight    = CopyPtr->WinHeight;
  2222.             NewEntry->UseFlags    = CopyPtr->UseFlags;
  2223.             NewEntry->WinFlags    = CopyPtr->WinFlags;
  2224.         }
  2225.  
  2226.             // Remove entries from listview (Used)
  2227.  
  2228.         DoMethod(UsedList, MUIM_List_Clear, NULL);
  2229.  
  2230.             // Sort the list again
  2231.  
  2232.         SortList(&FIconSema->VolumeList, TRUE);
  2233.  
  2234.             // Readd list
  2235.  
  2236.         ThisEntry    = (struct VolEntry *)FIconSema->VolumeList.lh_Head;
  2237.         while(ThisEntry->Link.ln_Succ)
  2238.         {
  2239.             DoMethod(UsedList, MUIM_List_InsertSingle, (APTR)ThisEntry, MUIV_List_Insert_Bottom);
  2240.  
  2241.             ThisEntry    = (struct VolEntry *)ThisEntry->Link.ln_Succ;
  2242.         }
  2243.     }
  2244.     else
  2245.     {
  2246.         DisplayError(ERR_NOMEM, NULL);
  2247.         NewEntry    = NULL;
  2248.     }
  2249.  
  2250.         // Free our semaphore
  2251.  
  2252.     ReleaseSemaphore(&FIconSema->FIconSema);
  2253.  
  2254.     return(NewEntry);
  2255. }
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264. /**********************************************************************/
  2265. /*        Check for existance of a volume within the user list        */
  2266. /**********************************************************************/
  2267. static BOOL CheckExists(char *Name)
  2268. {
  2269.     BOOL    RetVal = FALSE;
  2270.  
  2271.     ObtainSemaphore(&FIconSema->FIconSema);
  2272.  
  2273.     if(!IsListEmpty(&FIconSema->VolumeList))
  2274.     {
  2275.         struct    VolEntry    *ThisEntry    = (struct VolEntry *)FIconSema->VolumeList.lh_Head;
  2276.  
  2277.         do
  2278.         {
  2279.             if(!stricmp(ThisEntry->VolName, Name))
  2280.                 RetVal = TRUE;
  2281.  
  2282.             ThisEntry = (struct VolEntry *)ThisEntry->Link.ln_Succ;
  2283.         } while(!RetVal && ThisEntry->Link.ln_Succ);
  2284.     }
  2285.  
  2286.     ReleaseSemaphore(&FIconSema->FIconSema);
  2287.  
  2288.     return(RetVal);
  2289. }
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297. /**********************************************************************/
  2298. /*                       Save Prefs to disk/env                       */
  2299. /**********************************************************************/
  2300. static BOOL            DoSavePrefs(char *PrefsName);
  2301. static BOOL SavePrefs(BOOL EnvMode)
  2302. {
  2303.         // On ENV: mode, simply save to ENV: only
  2304.  
  2305.     if(DoSavePrefs("ENV:ForceIcon_prefs.iff"))
  2306.     {
  2307.             // Otherwise write to envarc: as well
  2308.  
  2309.         if(!EnvMode)
  2310.             return(DoSavePrefs("ENVARC:ForceIcon_prefs.iff"));
  2311.         else
  2312.             return(TRUE);
  2313.     }
  2314.     return(FALSE);
  2315. }
  2316. static BOOL DoSavePrefs(char *PrefsName)
  2317. {
  2318.     struct    IFFHandle    *PrefsHandle;
  2319.     LONG    Error;
  2320.     BOOL    GoOn = FALSE;
  2321.     UWORD    VersChunk[] =
  2322.     {
  2323.         VERNUM,
  2324.         REVNUM
  2325.     };
  2326.  
  2327.  
  2328.     ObtainSemaphore(&FIconSema->FIconSema);
  2329.  
  2330.         // Get handle for IFF
  2331.  
  2332.     if((PrefsHandle = AllocIFF()))
  2333.     {
  2334.             // Open file for save
  2335.  
  2336.         if((PrefsHandle->iff_Stream = Open(PrefsName, MODE_NEWFILE)))
  2337.         {
  2338.                 // Init Handle
  2339.  
  2340.             InitIFFasDOS(PrefsHandle);
  2341.  
  2342.                 // Open Handle
  2343.  
  2344.             if(!(Error = OpenIFF(PrefsHandle, IFFF_WRITE)))
  2345.             {
  2346.                     // Write FORM chunk
  2347.  
  2348.                 if(!(Error = PushChunk(PrefsHandle, 'FOIC', 'FORM', IFFSIZE_UNKNOWN)))
  2349.                 {
  2350.                         // Write version chunk
  2351.  
  2352.                     if(!(Error = PushChunk(PrefsHandle, 'FOIC', 'VERS', IFFSIZE_UNKNOWN)))
  2353.                     {
  2354.                         if((Error = WriteChunkBytes(PrefsHandle, &VersChunk[0], (sizeof(UWORD) * 2))) == (sizeof(UWORD) * 2))
  2355.                             Error = PopChunk(PrefsHandle);
  2356.                         else
  2357.                             Error = IoErr();
  2358.                     }
  2359.  
  2360.                         // Write Prefs chunk
  2361.  
  2362.                     if(!Error && !(Error = PushChunk(PrefsHandle, 'FOIC', 'PREF', IFFSIZE_UNKNOWN)))
  2363.                     {
  2364.                         struct    VolEntry    *ThisEntry    = (struct VolEntry *)FIconSema->VolumeList.lh_Head;
  2365.                         UWORD    NumEntries            = FIconSema->VolumeList.lh_Type;
  2366.                         BOOL    NoErr = TRUE;
  2367.  
  2368.                                 // Write all entries of volume list
  2369.  
  2370.                         if((Error = WriteChunkBytes(PrefsHandle, &NumEntries, sizeof(UWORD))) == sizeof(UWORD))
  2371.                         {
  2372.                             while(NumEntries-- && NoErr)
  2373.                             {
  2374.                                 UWORD    EntryType = ThisEntry->Link.ln_Type;
  2375.  
  2376.                                 if((Error = WriteChunkBytes(PrefsHandle, &EntryType, sizeof(UWORD))) == sizeof(UWORD))
  2377.                                 {
  2378.                                     if((Error = WriteChunkBytes(PrefsHandle, &ThisEntry->VolName, 130)) == 130)
  2379.                                     {
  2380.                                         if((Error = WriteChunkBytes(PrefsHandle, &ThisEntry->IconName, 256)) == 256)
  2381.                                         {
  2382.                                             if((Error = WriteChunkBytes(PrefsHandle, &ThisEntry->Left, (sizeof(UWORD) * 36))) != (sizeof(UWORD) * 36))
  2383.                                                 NoErr = FALSE;
  2384.                                         }
  2385.                                     }
  2386.                                 }
  2387.  
  2388.                                 ThisEntry = (struct VolEntry *)ThisEntry->Link.ln_Succ;
  2389.                             }
  2390.  
  2391.                             if(NoErr)
  2392.                             {
  2393.                                 if(!(Error = PopChunk(PrefsHandle)))
  2394.                                     GoOn = TRUE;
  2395.                             }
  2396.                         }
  2397.                     }
  2398.                 }
  2399.  
  2400.                 if((Error = PopChunk(PrefsHandle)))
  2401.                     GoOn = FALSE;
  2402.  
  2403.                 CloseIFF(PrefsHandle);
  2404.             }
  2405.  
  2406.             Close(PrefsHandle->iff_Stream);
  2407.         }
  2408.         else
  2409.             Error = IoErr();
  2410.  
  2411.         FreeIFF(PrefsHandle);
  2412.     }
  2413.     else
  2414.         Error = ERR_NOMEM;
  2415.  
  2416.     if(!GoOn)
  2417.         DisplayError(Error, (ULONG)PrefsName);
  2418.  
  2419.     ReleaseSemaphore(&FIconSema->FIconSema);
  2420.  
  2421.     return(GoOn);
  2422. }
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428. /**********************************************************************/
  2429. /*                  Make a specific entry diskchange                  */
  2430. /**********************************************************************/
  2431. static void DskChange(struct VolEntry *ListEntry)
  2432. {
  2433.     struct    List    ChangeList;
  2434.  
  2435.     NewList(&ChangeList);
  2436.  
  2437.  
  2438.         // Create list of connected devices
  2439.  
  2440.     if(GetDosEntries(&ChangeList, LDF_VOLUMES))
  2441.     {
  2442.         struct    DosList        *DList;
  2443.         struct    VolEntry    *ThisEntry;
  2444.         struct    DevProc        *DevProc;
  2445.         char            DevName[130];
  2446.         BOOL            FoundDev,
  2447.                     DoDskCh;
  2448.  
  2449.             // Loop for all volumes in list
  2450.  
  2451.         while((ThisEntry = (struct VolEntry *)RemHead(&ChangeList)))
  2452.         {
  2453.             FoundDev    = FALSE;
  2454.  
  2455.                 // Find name of device this volume resides in
  2456.  
  2457.             if((DList = LockDosList(LDF_DEVICES|LDF_READ)))
  2458.             {
  2459.                 while((DList = NextDosEntry(DList, LDF_DEVICES|LDF_READ)))
  2460.                 {
  2461.                     if(ThisEntry->DriverTask == DList->dol_Task)
  2462.                     {
  2463.                         setmem(DevName, 130, 0);
  2464.                         strncpy(DevName, ((char *)BADDR(DList->dol_Name) + 1), *((char *)BADDR(DList->dol_Name)));
  2465.                         FoundDev    = TRUE;
  2466.                     }
  2467.                 }
  2468.                 UnLockDosList(LDF_DEVICES|LDF_READ);
  2469.             }
  2470.  
  2471.                 // Found corresponding device ???
  2472.  
  2473.             if(FoundDev)
  2474.             {
  2475.                     // Check whether to diskchange
  2476.  
  2477.                 if(ListEntry->Link.ln_Type == LDF_DEVICES)
  2478.                     DoDskCh    = (MyStrCmp(ListEntry->VolName, DevName) == 0);
  2479.                 else
  2480.                     DoDskCh    = (MyStrCmp(ListEntry->VolName, ThisEntry->VolName) == 0);
  2481.  
  2482.                     // Diskchange device ???
  2483.  
  2484.                 if(DoDskCh)
  2485.                 {
  2486.                     strcat(DevName, ":");
  2487.  
  2488.                     if(ThisEntry->DriverTask && (DevProc = GetDeviceProc(DevName, NULL)))
  2489.                     {
  2490.                         if(TypeOfMem(DevProc->dvp_Port))
  2491.                         {
  2492.                             if(DoPkt(DevProc->dvp_Port, ACTION_INHIBIT, DOSTRUE, NULL, NULL, NULL, NULL))
  2493.                                 DoPkt(DevProc->dvp_Port, ACTION_INHIBIT, DOSFALSE, NULL, NULL, NULL, NULL);
  2494.                         }
  2495.                         FreeDeviceProc(DevProc);
  2496.                     }
  2497.                 }
  2498.             }
  2499.  
  2500.             FreeVecPool(FIconSema, ThisEntry);
  2501.         }
  2502.     }
  2503. }
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510. /**********************************************************************/
  2511. /*       Now include the LoadRoutine and the VolumeList routine       */
  2512. /**********************************************************************/
  2513. #include    "LoadPrefs.h"
  2514. #include    "VolList.h"
  2515. #include    "Error.h"
  2516. #include    "Rendezvous.h"
  2517. #include    "CheckToolTypes.h"
  2518. #include    "PoolVec.h"
  2519.