home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 4 / FreshFish_May-June1994.bin / new / amigalibdisks / d984 / forceicon / source / ficonprefs.c < prev    next >
C/C++ Source or Header  |  1994-04-04  |  59KB  |  2,375 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.