home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff284.lzh / IconTools / fix.c < prev    next >
C/C++ Source or Header  |  1989-11-27  |  2KB  |  90 lines

  1. /************************************************************
  2.   fix.c  By: Stephen Vermeulen
  3.  
  4.   Copyright (C) 1989 By Stephen Vermeulen
  5.  
  6.   Use this tool to set the type of an icon.
  7.  
  8.   It has the following syntax:
  9.  
  10.       fix file [Detail [Block]]
  11.  
  12.   when this is typed, fix will load the file called "file.info"
  13.   and if it is a drawer, disk or trashcan type icon will change
  14.   the pen colours used in the borders of the window that workbench
  15.   opens when the disk/drawer/trashcan opens.
  16. ************************************************************/
  17.  
  18. #include <intuition/intuition.h>
  19. #include <workbench/workbench.h>
  20. #include <stdio.h>
  21. #include <functions.h>
  22.  
  23. #define NO_ICONS       4
  24.  
  25. extern ULONG IconBase;
  26.  
  27. /************************************************************
  28.   The following routine just opens the libraries
  29. ************************************************************/
  30.  
  31. short OpenLibs()
  32. {
  33.   short flags; /* any libraries that do not open get recorded here */
  34.  
  35.   flags = 0;
  36.   IconBase = (ULONG) OpenLibrary("icon.library", 0L);
  37.   if (!IconBase) flags |= NO_ICONS;
  38.   return(flags);
  39. }
  40.  
  41. void CloseLibs(flags)
  42. short flags;
  43. {
  44.   if (!(flags & NO_ICONS))     CloseLibrary(IconBase);
  45. }
  46.  
  47. void main(argc, argv)
  48. short argc;
  49. char *argv[];
  50. {
  51.   short lib_flags, icon_type;
  52.   struct DiskObject *dobj, *drawer_obj;
  53.   struct DrawerData *dd_temp;
  54.  
  55.   if (argc >= 2)
  56.   {
  57.     lib_flags  = OpenLibs();
  58.     if (!lib_flags)
  59.     {
  60.       if (dobj = GetDiskObject(argv[1]))
  61.       {
  62.         if ((dobj->do_Type == 1) || (dobj->do_Type == 2) || (dobj->do_Type == 5))
  63.         {
  64.           /** ok to proceed **/
  65.  
  66.           if (argc >= 3)
  67.             dobj->do_DrawerData->dd_NewWindow.DetailPen = atoi(argv[2]);
  68.           else
  69.             dobj->do_DrawerData->dd_NewWindow.DetailPen = 2;
  70.           if (argc == 4)
  71.             dobj->do_DrawerData->dd_NewWindow.BlockPen = atoi(argv[3]);
  72.           else
  73.             dobj->do_DrawerData->dd_NewWindow.BlockPen = 3;
  74.           PutDiskObject(argv[1], dobj);
  75.         }
  76.         FreeDiskObject(dobj);
  77.       }
  78.     }
  79.     CloseLibs(lib_flags);
  80.   }
  81.   else
  82.   {
  83.     puts("Syntax is: fix icon [Detail [Block]]");
  84.     puts("  ... don't use the .icon suffix!  Sets the detail and block colours");
  85.     puts("for the borders of WorkBench drawer windows.");
  86.     puts("Written by: Stephen Vermeulen, PO Box 3295, Station B,");
  87.     puts("Calgary, Alberta, CANADA, T2M 4L8.");
  88.   }
  89. }
  90.