Initial import of Scalos. To decrease size I have
[AROS-Contrib.git] / scalos / Modules / Delete.MUI / Source / Delete.module.c
blobc07cab797dff1d23db05f9c5c82f10093f9d3ee1
1 // Delete.module.c
2 // $Date$
3 // $Revision$
4 // $Id$
6 // ___ ___
7 // _/ /_______\ \_ ___ ___ __ _ _ __ ___ ___.
8 //__// / _______ \ \\___/ \___
9 //_/ | ' \__ __/ ` | \_/ © Copyright 1999, Christopher Page \__
10 // \ | | | |__ | | / \ Released as Free Software under the GNU GPL /.
11 // >| . | _/ . |< >--- --- -- - - -- --- ---<.
12 // / \ \ | | / / \ / This file is part of the ScalosDelete code \.
13 // \ \ \_/ \_/ / / \ and it is released under the GNU GPL. Please /.
14 // \ \ / / \ read the "COPYING" file which should have /.
15 // //\ \_________/ /\\ //\ been included in the distribution arc. /.
16 //- --\ _______ /-- - --\ for full details of the license /-----
17 //-----\_/ \_/---------\ ___________________________________ /------
18 // \_/ \_/.
20 // Description:
22 // Interface setup and entrypoints for ScalosDelete
24 // Functions:
26 // int wbmain (WBStartup *);
27 // int main (int , char **);
28 // void ExitMUI (APTR, STRPTR);
29 // void InitMUI (void);
30 // void SetupInterface(void);
32 // Detail:
34 // This file contains the setup/ shutdown, interface creation and entrypoint
35 // functions for ScalosDelete. It is written for StormC so some modification
36 // will be required to recompile under other systems. Note that StormC uses
37 // wbmain() as the entrypoint for workbench launched programs, you can probably
38 // remove this if you recompile under SAS/C or similar (DiceC uses the same
39 // mechanism).
41 // Modification History:
43 // [02 June 1999, Chris <chris@worldfoundry.demon.co.uk>]
45 // Converted header notice to GNU GPL version, checked and recommented where
46 // required.
48 // Fold Markers:
50 // Start: /*GFS*/
51 // End: /*GFE*/
53 #define Delete_CODE
54 #define Delete_ARRAY
55 #include"Delete.module.h"
57 //----------------------------------------------------------------------------
59 /*GFE*/
60 // Prototypes
61 int wbmain (struct WBStartup *);
62 int main (int, char **);
63 void ExitMUI (APTR, STRPTR);
64 void InitMUI (void);
65 void SetupInterface (void);
67 static SAVEDS(APTR) INTERRUPT OpenAboutMUIHookFunc(struct Hook *hook, Object *o, Msg msg);
68 static SAVEDS(void) INTERRUPT EnableTrashcanHookFunc(struct Hook *hook, Object *o, Msg msg);
69 static BOOL CheckMCCVersion(CONST_STRPTR name, ULONG minver, ULONG minrev);
71 //----------------------------------------------------------------------------
73 const char Version[] = VERSTAG;
75 // Library bases and classes. Only hand-open the ones we really need a specific
76 // version of..
77 extern struct ExecBase *SysBase;
78 struct Library *MUIMasterBase = NULL;
79 struct Library *AslBase = NULL;
80 #ifndef __amigaos4__
81 T_UTILITYBASE UtilityBase = NULL;
82 #endif
83 struct ScalosBase *ScalosBase = NULL;
84 T_LOCALEBASE LocaleBase = NULL;
85 struct Catalog *WordsCat = NULL;
86 static struct Locale *DeleteLocale = NULL;
88 #ifdef __amigaos4__
89 struct IntuitionBase *IntuitionBase = NULL;
91 struct MUIMasterIFace *IMUIMaster = NULL;
92 struct AslIFace *IAsl = NULL;
93 struct ScalosIFace *IScalos = NULL;
94 struct LocaleIFace *ILocale = NULL;
95 struct IntuitionIFace *IIntuition = NULL;
96 #endif
98 // MUI globals
99 /*GFS*/
100 Object *MUI_App = NULL;
101 Object *WI_Delete = NULL;
103 Object *LV_Files = NULL;
104 Object *BT_Details = NULL;
105 Object *TX_ReadOut = NULL;
107 Object *BT_Delete = NULL;
108 Object *BT_About = NULL;
109 Object *BT_Cancel = NULL;
111 Object *GP_Progress = NULL;
112 Object *TX_Progress = NULL;
113 Object *GA_Progress = NULL;
114 Object *BT_STOP = NULL;
116 Object *ST_TrashDir = NULL;
117 Object *CM_TrashCan = NULL;
118 Object *CM_DirConf = NULL;
119 Object *CM_FileConf = NULL;
120 Object *CM_Quiet = NULL;
121 Object *BT_Save = NULL;
122 Object *BT_Use = NULL;
123 Object *BT_Restore = NULL;
125 CONST_STRPTR Pages[ 3] = { NULL };
126 CONST_STRPTR Keys [14] = { NULL };
128 static Object *LampUndoPossible;
129 static Object *TextUndoPossible;
131 Object *WI_About = NULL;
132 Object *BT_About_MUI = NULL;
133 static Object *MenuAbout;
134 static Object *MenuAboutMUI;
135 static Object *MenuQuit;
136 static Object *WIN_AboutMUI;
138 static struct Hook AboutMUIHook = { { NULL, NULL }, HOOKFUNC_DEF(OpenAboutMUIHookFunc), NULL };
139 static struct Hook EnableTrashcanHook = { { NULL, NULL }, HOOKFUNC_DEF(EnableTrashcanHookFunc), NULL };
141 //----------------------------------------------------------------------------
143 /* void ExitMUI(APTR, STRPTR) */
144 /* -=-=-=-=-=-=-=-=-=-=-=-=-= */
145 /* If an error occurs, or when the window is closed, this routine is called */
146 /* to clean up all the resources, display an error message if required and */
147 /* then exit(). */
148 /* */
149 /* Parameters: */
150 /* errApp Pointer to the MUI Application object to close. */
151 /* errString String to display in an EasyRequest. If this is */
152 /* NULL then nothing is displayed */
154 /*GFS*/ void ExitMUI(APTR errApp, STRPTR errString)
156 // LONG EntryNum = 0;
158 struct EasyStruct ErrorDisplay =
160 sizeof(struct EasyStruct),
162 "Delete.module Error", // Not localised (may not have Locale y'see..)
163 "%s",
164 "Ok",
167 d1(KPrintF("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
168 // Show the error
169 if(errString)
170 EasyRequest(NULL, &ErrorDisplay, NULL, errString, 0);
172 d1(KPrintF("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
173 if(errApp)
174 MUI_DisposeObject(errApp);
176 d1(KPrintF("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
178 // Clean up
179 if(FileBuffer)
180 free(FileBuffer);
181 if(PathBuffer)
182 free(PathBuffer);
183 if(DirBuffer)
184 free(DirBuffer);
186 d1(KPrintF("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
187 if(WordsCat)
188 CloseCatalog(WordsCat );
189 d1(KPrintF("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
190 if (DeleteLocale)
191 CloseLocale(DeleteLocale);
192 d1(KPrintF("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
194 #ifdef __amigaos4__
195 if (IIntuition )
196 DropInterface((struct Interface *)IIntuition );
197 #endif
198 if (IntuitionBase)
199 CloseLibrary((struct Library *) IntuitionBase);
200 #ifdef __amigaos4__
201 if(IMUIMaster )
202 DropInterface((struct Interface *)IMUIMaster );
203 #endif
204 if(MUIMasterBase)
205 CloseLibrary(MUIMasterBase);
206 #ifdef __amigaos4__
207 if(IAsl )
208 DropInterface((struct Interface *)IAsl );
209 #endif
210 if(AslBase )
211 CloseLibrary(AslBase );
212 #ifndef __amigaos4__
213 if(UtilityBase )
214 CloseLibrary((struct Library *) UtilityBase );
215 #endif
216 #ifdef __amigaos4__
217 if(IScalos )
218 DropInterface((struct Interface *)IScalos );
219 #endif
220 if(ScalosBase )
221 CloseLibrary(&ScalosBase->scb_LibNode);
222 d1(KPrintF("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
223 #ifdef __amigaos4__
224 if(ILocale )
225 DropInterface((struct Interface *)ILocale );
226 #endif
227 if(LocaleBase )
228 CloseLibrary((struct Library *) LocaleBase );
230 d1(KPrintF("%s/%s/%ld: END\n", __FILE__, __FUNC__, __LINE__));
232 exit(0);
233 }/*GFE*/
236 /* void InitMUI(void) */
237 /* -=-=-=-=-=-=-=-=-= */
238 /* This routine opens the libraries and locale catalog. If an error occurs */
239 /* (ie: library will not open, memory allocation fails etc) then ExitMUI() */
240 /* is called with an error. Note that the error messages are not localised as*/
241 /* locale.library may not be available when the error is encountered.. */
243 /*GFS*/ void InitMUI(void)
245 if(!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME, MUIMASTER_VMIN)))
247 ExitMUI(NULL, "Unable to open "MUIMASTER_NAME".");
249 #ifdef __amigaos4__
250 else
252 IMUIMaster = (struct MUIMasterIFace *)GetInterface((struct Library *)MUIMasterBase, "main", 1, NULL);
254 #endif
256 if(!(AslBase = OpenLibrary(AslName , 39)))
258 ExitMUI(NULL, "Unable to open "AslName".");
260 #ifdef __amigaos4__
261 else
263 IAsl = (struct AslIFace *)GetInterface((struct Library *)AslBase, "main", 1, NULL);
265 #endif
266 if(!(IntuitionBase = (struct IntuitionBase *) OpenLibrary(IntuitionName , 39)))
268 ExitMUI(NULL, "Unable to open " IntuitionName ".");
270 #ifdef __amigaos4__
271 else
273 IIntuition = (struct IntuitionIFace *)GetInterface((struct Library *)IntuitionBase, "main", 1, NULL);
275 #endif
276 #ifndef __amigaos4__
277 if(!(UtilityBase = (T_UTILITYBASE) OpenLibrary(UTILITYNAME, 39)))
279 ExitMUI(NULL, "Unable to open "UTILITYNAME".");
281 #endif
283 if(!(ScalosBase = (struct ScalosBase *) OpenLibrary("scalos.library", 39)))
285 ExitMUI(NULL, "Unable to open scalos.library.");
287 #ifdef __amigaos4__
288 else
290 IScalos = (struct ScalosIFace *)GetInterface((struct Library *)ScalosBase, "main", 1, NULL);
292 #endif
294 if(!(LocaleBase = (T_LOCALEBASE)OpenLibrary("locale.library", 37)))
296 ExitMUI(NULL, "Unable to open locale.library v39+");
298 #ifdef __amigaos4__
299 else
301 ILocale = (struct LocaleIFace *)GetInterface((struct Library *)LocaleBase, "main", 1, NULL);
303 #endif
305 DeleteLocale = OpenLocale(NULL);
306 if (DeleteLocale)
307 WordsCat = OpenCatalogA(DeleteLocale, "Scalos/Delete.catalog", NULL);
309 if(!(FileBuffer = malloc(MAX_FILENAME_LEN)))
311 ExitMUI(NULL, "Unable to allocate file buffer");
314 if(!(PathBuffer = malloc(MAX_FILENAME_LEN)))
316 ExitMUI(NULL, "Unable to allocate path buffer");
319 if(!(DirBuffer = malloc(MAX_FILENAME_LEN)))
321 ExitMUI(NULL, "Unable to allocate directory buffer");
323 }/*GFE*/
325 #if 0
326 /* int wbmain(WBStartup *) */
327 /* -=-=-=-=-=-=-=-=-=-=-=- */
328 /* Entry point for WB started programs. Required by StormC and DiceC but can */
329 /* probably be removed for other system. It just calls main() with argc set */
330 /* to 0 and argv pointing to the WBStartup message. */
332 /*GFS*/ int wbmain(struct WBStartup *wb_Startup)
334 return (main(0, (char **)wb_Startup));
335 }/*GFE*/
336 #endif
338 /* int main(int char **) */
339 /* -=-=-=-=-=-=-=-=-=-=- */
340 /* Eh? You want COMMENTS?? For *MAIN*??? Oh, all right then main routine.. */
341 /* there that's all your getting. Comments indeed.. */
343 /*GFS*/ int main(int argc, char **argv)
345 BOOL Running = TRUE;
346 ULONG Sig = 0;
347 ULONG Source = 0;
349 // Wake up MUI...
350 InitMUI();
352 if (!CheckMCCVersion(MUIC_NList, 20, 121) ||
353 !CheckMCCVersion(MUIC_NListview, 19, 66) ||
354 !CheckMCCVersion(MUIC_Lamp, 11, 1) )
355 return 10;
357 SetupInterface();
359 // Bomb if the user has started the program from shell (daft user...) otherwise
360 // read the filelist...
361 if(argc != 0)
363 ExitMUI(MUI_App, "Delete.module may not be started from shell");
366 // Bomb out if something has gone clogs-skyward
367 if(!MUI_App)
369 ExitMUI(MUI_App, "Unable to create application");
372 CallHookPkt(&EnableTrashcanHook, MUI_App, NULL);
374 // Some domethods to make processing easier.
375 DoMethod(WI_Delete , MUIM_Notify, MUIA_Window_CloseRequest, TRUE , MUI_App , 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
376 DoMethod(BT_Cancel , MUIM_Notify, MUIA_Pressed , FALSE , MUI_App , 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
378 DoMethod(BT_Delete , MUIM_Notify, MUIA_Pressed , FALSE , MUI_App , 2, MUIM_Application_ReturnID, DELETE_IT);
379 DoMethod(BT_Details , MUIM_Notify, MUIA_Pressed , FALSE , MUI_App , 2, MUIM_Application_ReturnID, DETAIL_IT);
380 DoMethod(BT_STOP , MUIM_Notify, MUIA_Pressed , FALSE , MUI_App , 2, MUIM_Application_ReturnID, STOP_IT );
382 DoMethod(BT_Save , MUIM_Notify, MUIA_Pressed , FALSE , MUI_App , 2, MUIM_Application_ReturnID, PREFSSAVE);
383 DoMethod(BT_Use , MUIM_Notify, MUIA_Pressed , FALSE , MUI_App , 2, MUIM_Application_ReturnID, PREFSUSE );
384 DoMethod(BT_Restore , MUIM_Notify, MUIA_Pressed , FALSE , MUI_App , 2, MUIM_Application_ReturnID, PREFSLOAD);
386 DoMethod(CM_TrashCan , MUIM_Notify, MUIA_Selected , MUIV_EveryTime,
387 MUI_App, 2, MUIM_CallHook, &EnableTrashcanHook);
389 // About handling...
390 DoMethod(WI_About , MUIM_Notify, MUIA_Window_CloseRequest, TRUE , WI_About, 3, MUIM_Set, MUIA_Window_Open, FALSE );
391 DoMethod(BT_About , MUIM_Notify, MUIA_Pressed , FALSE, WI_About, 3, MUIM_Set, MUIA_Window_Open, TRUE );
392 DoMethod(BT_About_MUI, MUIM_Notify, MUIA_Pressed , FALSE, MUI_App , 2, MUIM_Application_AboutMUI , WI_About);
394 // Menu handling
395 DoMethod(MenuAbout, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
396 WI_About, 3, MUIM_Set, MUIA_Window_Open, TRUE);
397 DoMethod(MenuAboutMUI, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
398 MUI_App, 2, MUIM_CallHook, &AboutMUIHook);
399 DoMethod(MenuQuit, MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,
400 MUI_App, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
402 // Read in the settings
403 DoMethod(MUI_App, MUIM_Application_Load, MUIV_Application_Load_ENV);
405 // Get the show on the road...
406 set(WI_Delete, MUIA_Window_Open, TRUE);
408 // +jmc+ : Activate delete button gadget
409 set(WI_Delete, MUIA_Window_ActiveObject, BT_Delete);
411 // Open the about window & GNU GPL details....
412 get(CM_Quiet , MUIA_Selected , &Source);
413 if(Source == 0)
414 set(WI_About, MUIA_Window_Open, TRUE);
416 if(!ListFiles((struct WBStartup *)argv))
417 ExitMUI(MUI_App, NULL);
419 // Main loop: Block on the MUI Notify...
420 while (Running)
422 Source = DoMethod(MUI_App, MUIM_Application_NewInput, &Sig);
423 switch(Source)
425 case MUIV_Application_ReturnID_Quit:
426 Running = FALSE;
427 break;
428 case PREFSSAVE:
429 DoMethod(MUI_App, MUIM_Application_Save, MUIV_Application_Save_ENVARC);
430 case PREFSUSE :
431 DoMethod(MUI_App, MUIM_Application_Save, MUIV_Application_Save_ENV);
432 break;
433 case PREFSLOAD:
434 DoMethod(MUI_App, MUIM_Application_Load, MUIV_Application_Load_ENV);
435 break;
436 case DETAIL_IT:
437 GetDetails((struct WBStartup *)argv);
438 break;
439 case DELETE_IT:
440 set(BT_Details, MUIA_Disabled, TRUE);
441 set(BT_Delete, MUIA_Disabled, TRUE);
442 set(BT_About, MUIA_Disabled, TRUE);
443 set(BT_Cancel, MUIA_Disabled, TRUE);
444 KillFiles((struct WBStartup *)argv);
445 Running = FALSE;
446 break;
448 if(Running && Sig)
449 Wait(Sig);
452 // Clean up and begone.
453 ExitMUI(MUI_App, NULL);
455 return 0;
456 }/*GFE*/
459 /* void SetupInterface(void) */
460 /* -=-=-=-=-=-=-=-=-=-=-=-=- */
461 /* Sets up the interface all in one compound command. Much easier to read */
462 /* than lots of small functions adding bits here and there IMO... */
464 /*GFS*/ void SetupInterface(void)
466 char VersionBuffer[64];
467 char DateBuffer [64];
469 // Set up the compiled and version info...
470 sprintf(VersionBuffer, "%d.%d", VERSION, REVISION);
471 sprintf(DateBuffer , "%s %s" , __TIME__, __DATE__);
473 // Localise the page names
474 Pages[0] = GetLocString(MSG_PAGES_FILES);
475 Pages[1] = GetLocString(MSG_PAGES_PREFS);
477 // and the key shortcuts. Bit of a hack this really....
478 Keys[ 0] = GetLocString(MSG_KEY_DETAILS);
479 Keys[ 1] = GetLocString(MSG_KEY_TRASH );
480 Keys[ 2] = GetLocString(MSG_KEY_DIRS );
481 Keys[ 3] = GetLocString(MSG_KEY_FILES );
482 Keys[ 4] = GetLocString(MSG_KEY_QUIET );
483 Keys[ 5] = GetLocString(MSG_KEY_TLOC );
484 Keys[ 6] = GetLocString(MSG_KEY_SAVE );
485 Keys[ 7] = GetLocString(MSG_KEY_USE );
486 Keys[ 8] = GetLocString(MSG_KEY_REST );
487 Keys[ 9] = GetLocString(MSG_KEY_DELETE );
488 Keys[10] = GetLocString(MSG_KEY_ABOUT );
489 Keys[11] = GetLocString(MSG_KEY_CANCEL );
490 Keys[12] = GetLocString(MSG_KEY_STOP );
491 Keys[13] = GetLocString(MSG_KEY_AMUI );
493 MUI_App = ApplicationObject,
494 MUIA_Application_Title , GetLocString(MSG_APP_TITLE),
495 MUIA_Application_Version , &Version[1],
496 MUIA_Application_Copyright , "(C)1999 Chris Page, The World Foundry",
497 MUIA_Application_Author , "Chris Page, The World Foundry",
498 MUIA_Application_Description, GetLocString(MSG_APP_DESC),
499 MUIA_Application_Base , BASENAME,
500 MUIA_Application_SingleTask , TRUE,
501 /*GFS*/ SubWindow, WI_Delete = WindowObject,
502 MUIA_Window_Title , GetLocString(MSG_WIN_TITLE),
503 MUIA_Window_ID , MAKE_ID('M','A','I','N'),
504 MUIA_Window_ScreenTitle, VSTR,
505 WindowContents, VGroup,
506 Child, RegisterGroup(Pages),
507 MUIA_CycleChain, TRUE,
508 MUIA_Background, MUII_RegisterBack,
509 Child, VGroup,
510 Child, HGroup,
511 GroupFrame,
512 MUIA_Background, MUII_GroupBack,
513 Child, LampUndoPossible = LampObject,
514 MUIA_Lamp_Type, MUIV_Lamp_Type_Huge,
515 MUIA_Lamp_Color, MUIV_Lamp_Color_Off,
516 End, //LampObject
517 Child, TextUndoPossible = TextObject,
518 MUIA_Text_Contents, GetLocString(MSGID_UNDO_NOT_POSSIBLE),
519 End, //TextObject
520 End, //HGroup
522 Child, VGroup,
523 MUIA_Group_Spacing, 0,
524 Child, LV_Files = NListviewObject,
525 MUIA_CycleChain, 1,
526 MUIA_NListview_Vert_ScrollBar, TRUE,
527 MUIA_NListview_NList , NListObject,
528 MUIA_CycleChain, 1,
529 MUIA_NList_Input , FALSE,
530 MUIA_NList_DragSortable , FALSE,
531 MUIA_NList_Title , TRUE,
532 MUIA_NList_Format , "BAR,BAR,BAR,",
533 MUIA_NList_ConstructHook , &ConList,
534 MUIA_NList_DestructHook , &DesList,
535 MUIA_NList_DisplayHook , &DisList,
536 MUIA_NList_CompareHook , &CmpList,
537 End, //NListObject
538 End, //NListviewObject
539 Child, BT_Details = KeyButtonChain(GetLocString(MSG_BUTTON_FULL), Keys[0][0], 1),
540 End, //VGroup
542 Child, TX_ReadOut = TextObject,
543 TextFrame,
544 MUIA_Background, MUII_TextBack,
545 MUIA_Weight , 800,
546 MUIA_Text_PreParse, "\33c",
547 MUIA_FixHeightTxt , " ",
548 End, //TextObject
550 End, //VGroup
552 Child, VGroup,
553 Child, ColGroup(4),
554 GroupFrame,
555 MUIA_Background, MUII_GroupBack,
557 Child, HVSpace,
558 Child, KeyLabel1(GetLocString(MSG_LABEL_TRASH), Keys[1][0]),
559 Child, CM_TrashCan = KeyCheckMarkHelpID(TRUE, Keys[1][0], 1, MAKE_ID('C', 'M', 'T', 'C'), GetLocString(MSG_HELP_TRASH)),
560 Child, HVSpace,
562 Child, HVSpace,
563 Child, KeyLabel1(GetLocString(MSG_LABEL_DIRS) , Keys[2][0]),
564 Child, CM_DirConf = KeyCheckMarkHelpID(FALSE, Keys[2][0], 1, MAKE_ID('C', 'M', 'D', 'C'), GetLocString(MSG_HELP_DIRS )),
565 Child, HVSpace,
567 Child, HVSpace,
568 Child, KeyLabel1(GetLocString(MSG_LABEL_FILES), Keys[3][0]),
569 Child, CM_FileConf = KeyCheckMarkHelpID(FALSE, Keys[3][0], 1, MAKE_ID('C', 'M', 'F', 'C'), GetLocString(MSG_HELP_FILES)),
570 Child, HVSpace,
572 Child, HVSpace,
573 Child, KeyLabel1(GetLocString(MSG_LABEL_QUIET), Keys[4][0]),
574 Child, CM_Quiet = KeyCheckMarkHelpID(TRUE, Keys[4][0], 1, MAKE_ID('C', 'M', 'Q', 'I'), GetLocString(MSG_HELP_QUIET)),
575 Child, HVSpace,
577 End, //ColGroup
579 Child, HVSpace,
581 Child, HGroup,
582 GroupFrameT(GetLocString(MSG_LABEL_TLOC)),
584 Child, ST_TrashDir = PopaslObject,
585 MUIA_Popstring_String, StringObject,
586 StringFrame,
587 MUIA_String_MaxLen , 128,
588 MUIA_CycleChain , 1,
589 MUIA_ControlChar , Keys[5][0],
590 MUIA_ShortHelp , GetLocString(MSG_HELP_TLOC),
591 MUIA_ExportID , MAKE_ID('S', 'T', 'T', 'C'),
592 End, //StringObject
593 MUIA_Popstring_Button, PopButton(MUII_PopDrawer),
594 MUIA_CycleChain , 1,
595 ASLFR_TitleText , GetLocString(MSG_ASL_TITLE),
596 ASLFR_RejectIcons , TRUE,
597 ASLFR_DrawersOnly , TRUE,
598 End, //PopaslObject
599 End, //HGroup
600 Child, VSpace(0),
601 Child, HGroup,
602 MUIA_Group_SameSize, TRUE,
603 Child, BT_Save = KeyButtonChain(GetLocString(MSG_BUTTON_SAVE), Keys[6][0], 1),
604 Child, BT_Use = KeyButtonChain(GetLocString(MSG_BUTTON_USE ), Keys[7][0], 1),
605 Child, BT_Restore = KeyButtonChain(GetLocString(MSG_BUTTON_REST), Keys[8][0], 1),
606 End, //HGroup
607 End, //VGroup
608 End, //RegisterGroup
610 Child, HGroup,
611 MUIA_Group_SameSize, TRUE,
612 Child, BT_Delete = KeyButtonChain(GetLocString(MSG_BUTTON_DEL), Keys[ 9][0], 1),
613 Child, BT_About = KeyButtonChain(GetLocString(MSG_BUTTON_ABT), Keys[10][0], 1),
614 Child, BT_Cancel = KeyButtonChain(GetLocString(MSG_BUTTON_CAN), Keys[11][0], 1),
615 End, //HGroup
617 Child, GP_Progress = VGroup,
618 GroupFrame,
619 MUIA_Background, MUII_GroupBack,
620 MUIA_ShowMe, FALSE,
621 Child, HGroup,
622 Child, TX_Progress = TextObject,
623 MUIA_Background, MUII_TextBack,
624 TextFrame,
625 MUIA_Weight , 800,
626 MUIA_Background, MUII_TextBack,
627 MUIA_Text_PreParse, "\33c",
628 MUIA_FixHeightTxt , " ",
629 End, //TextObject
630 Child, BT_STOP = KeyButtonChain(GetLocString(MSG_BUTTON_STOP), Keys[12][0], 1),
631 End, //HGroup
632 Child, VGroup,
633 Child, GA_Progress = GaugeObject,
634 GaugeFrame,
635 MUIA_Gauge_Current , 0,
636 MUIA_Gauge_Max , 100,
637 MUIA_Gauge_Horiz , TRUE,
638 MUIA_FixHeightTxt , " ",
639 MUIA_Gauge_InfoText, GetLocString(MSG_LABEL_INFO),
640 End, //GaugeObject
641 Child, ScaleObject,
642 MUIA_Scale_Horiz , TRUE,
643 End, //ScaleObject
644 End, //VGroup
645 End, //VGroup
646 End, //VGroup
647 /*GFE*/ End, //WindowObject
649 /*GFS*/ SubWindow, WI_About = WindowObject,
650 MUIA_Window_Title , GetLocString(MSG_BUTTON_ABT),
651 MUIA_Window_ID , MAKE_ID('A','B','O','T'),
652 MUIA_Window_ScreenTitle, VSTR,
653 WindowContents, VGroup,
654 Child, TextObject,
655 TextFrame,
656 MUIA_Background, MUII_TextBack,
657 MUIA_Text_Contents, GetLocString(MSG_ABOUT_HEAD),
658 End, //TextObject
659 Child, ColGroup(7),
660 Child, HSpace(0),
661 Child, TextObject,
662 MUIA_Text_Contents, GetLocString(MSG_LABEL_VERS),
663 MUIA_Text_PreParse, "\33r",
664 End, //TextObject
665 Child, TextObject,
666 MUIA_Text_Contents, VersionBuffer,
667 End, //TextObject
668 Child, HSpace(0),
669 Child, TextObject,
670 MUIA_Text_Contents, GetLocString(MSG_LABEL_COMP),
671 MUIA_Text_PreParse, "\33r",
672 End, //TextObject
673 Child, TextObject,
674 MUIA_Text_Contents, DateBuffer,
675 End, //TextObject
676 Child, HSpace(0),
677 End, //ColGroup
678 Child, ScrollgroupObject,
679 MUIA_Scrollgroup_Contents, VGroupV,
680 VirtualFrame ,
681 Child, TextObject,
682 MUIA_Background, MUII_TextBack,
683 MUIA_Text_Contents, GetLocString(MSG_ABOUT_BODY),
684 End, //TextObject
685 End, //VGroupV
686 End, //ScrollgroupObject
688 Child, BT_About_MUI = KeyButtonChain(GetLocString(MSG_BUTTON_AMUI), Keys[13][0], 1),
689 End, //VGroup
690 /*GFE*/ End, //WindowObject
692 MUIA_Application_Menustrip, MenustripObject,
693 Child, MenuObjectT(GetLocString(MSGID_MENU_PROJECT)),
695 Child, MenuAbout = MenuitemObject,
696 MUIA_Menuitem_Title, GetLocString(MSGID_MENU_PROJECT_ABOUT),
697 End,
698 Child, MenuAboutMUI = MenuitemObject,
699 MUIA_Menuitem_Title, GetLocString(MSGID_MENU_PROJECT_ABOUTMUI),
700 End,
701 Child, MenuitemObject,
702 MUIA_Menuitem_Title, -1,
703 End,
704 Child, MenuQuit = MenuitemObject,
705 MUIA_Menuitem_Title, GetLocString(MSGID_MENU_PROJECT_QUIT),
706 MUIA_Menuitem_Shortcut, GetLocString(MSGID_MENU_PROJECT_QUIT_SHORT),
707 End,
709 End, //MenuObjectT
710 End, //MenuStripObject
711 End; //ApplicationObject
712 }/*GFE*/
714 //----------------------------------------------------------------------------
716 CONST_STRPTR GetLocString(ULONG MsgId)
718 struct Delete_LocaleInfo li;
720 li.li_Catalog = WordsCat;
721 #ifndef __amigaos4__
722 li.li_LocaleBase = LocaleBase;
723 #else
724 li.li_ILocale = ILocale;
725 #endif
727 // KPrintF(__FILE__ "%s/%ld: Catalog=%08lx LocaleBase=%08lx\n",
728 // __FUNC__, __LINE__, li.li_Catalog, li.li_LocaleBase);
730 return (CONST_STRPTR) GetDeleteString(&li, MsgId);
733 //----------------------------------------------------------------------------
735 STRPTR safe_strcat(STRPTR dest, CONST_STRPTR src, size_t DestLen)
737 STRPTR dst;
738 size_t Len = strlen(dest);
740 if (DestLen < Len)
741 return dest;
743 DestLen -= Len;
744 dst = dest + Len;
746 while (DestLen > 1 && *src)
748 *dst++ = *src++;
749 DestLen--;
751 *dst = '\0';
753 return dest;
756 //----------------------------------------------------------------------------
758 #if !defined(__SASC) &&!defined(__MORPHOS__)
759 // Replacement for SAS/C library functions
761 size_t stccpy(char *dest, const char *src, size_t MaxLen)
763 size_t Count = 0;
765 while (*src && MaxLen > 1)
767 *dest++ = *src++;
768 MaxLen--;
769 Count++;
771 *dest = '\0';
772 Count++;
774 return Count;
777 #endif /* __SASC */
779 //----------------------------------------------------------------------------
781 static SAVEDS(APTR) INTERRUPT OpenAboutMUIHookFunc(struct Hook *hook, Object *o, Msg msg)
783 if (NULL == WIN_AboutMUI)
785 WIN_AboutMUI = MUI_NewObject(MUIC_Aboutmui,
786 MUIA_Window_RefWindow, WI_Delete,
787 MUIA_Aboutmui_Application, MUI_App,
788 End;
791 if (WIN_AboutMUI)
792 set(WIN_AboutMUI, MUIA_Window_Open, TRUE);
794 return 0;
797 //----------------------------------------------------------------------------
799 static SAVEDS(void) INTERRUPT EnableTrashcanHookFunc(struct Hook *hook, Object *o, Msg msg)
801 ULONG UseTrashcan = 0;
803 get(CM_TrashCan, MUIA_Selected, &UseTrashcan);
805 set(ST_TrashDir, MUIA_Disabled, UseTrashcan);
806 set(LampUndoPossible, MUIA_Lamp_Color, UseTrashcan ? MUIV_Lamp_Color_Ok : MUIV_Lamp_Color_Error);
807 set(TextUndoPossible, MUIA_Text_Contents, GetLocString(UseTrashcan ? MSGID_UNDO_OK : MSGID_UNDO_NOT_POSSIBLE));
810 //----------------------------------------------------------------------------
812 // Checks if a certain version of a MCC is available
813 static BOOL CheckMCCVersion(CONST_STRPTR name, ULONG minver, ULONG minrev)
815 BOOL flush = TRUE;
817 d1(kprintf(__FILE__ "/" __FUNC__ "/%ld: %s ", name, __LINE__);)
819 while (1)
821 ULONG ver = 0;
822 ULONG rev = 0;
823 struct Library *base;
824 char libname[256];
826 // First we attempt to acquire the version and revision through MUI
827 Object *obj = MUI_NewObject((STRPTR) name, TAG_DONE);
828 if (obj)
830 get(obj, MUIA_Version, &ver);
831 get(obj, MUIA_Revision, &rev);
833 MUI_DisposeObject(obj);
835 if(ver > minver || (ver == minver && rev >= minrev))
837 d1(kprintf(__FILE__ "/" __FUNC__ "/%ld: v%ld.%ld found through MUIA_Version/Revision\n", __LINE__, ver, rev);)
838 return TRUE;
842 // If we did't get the version we wanted, let's try to open the
843 // libraries ourselves and see what happens...
844 stccpy(libname, "PROGDIR:mui", sizeof(libname));
845 AddPart(libname, name, sizeof(libname));
847 if ((base = OpenLibrary(&libname[8], 0)) || (base = OpenLibrary(&libname[0], 0)))
849 UWORD OpenCnt = base->lib_OpenCnt;
851 ver = base->lib_Version;
852 rev = base->lib_Revision;
854 CloseLibrary(base);
856 // we add some additional check here so that eventual broken .mcc also have
857 // a chance to pass this test (i.e. Toolbar.mcc is broken)
858 if (ver > minver || (ver == minver && rev >= minrev))
860 d1(kprintf(__FILE__ "/" __FUNC__ "/%ld: v%ld.%ld found through OpenLibrary()\n", __LINE__, ver, rev);)
861 return TRUE;
864 if (OpenCnt > 1)
866 if (MUI_Request(NULL, NULL, 0L,
867 (STRPTR) GetLocString(MSGID_STARTUP_FAILURE),
868 (STRPTR) GetLocString(MSGID_STARTUP_RETRY_QUIT_GAD),
869 (STRPTR) GetLocString(MSGID_STARTUP_MCC_IN_USE),
870 name, minver, minrev, ver, rev))
872 flush = TRUE;
874 else
875 break;
878 // Attempt to flush the library if open count is 0 or because the
879 // user wants to retry (meaning there's a chance that it's 0 now)
881 if (flush)
883 struct Library *result;
885 Forbid();
886 if ((result = (struct Library *) FindName(&((struct ExecBase *)SysBase)->LibList, name)))
887 RemLibrary(result);
888 Permit();
889 flush = FALSE;
891 else
893 d1(kprintf(__FILE__ "/" __FUNC__ "/%ld: couldn`t find minimum required version.\n", __LINE__);)
895 // We're out of luck - open count is 0, we've tried to flush
896 // and still haven't got the version we want
897 if (MUI_Request(NULL, NULL, 0L,
898 (STRPTR) GetLocString(MSGID_STARTUP_FAILURE),
899 (STRPTR) GetLocString(MSGID_STARTUP_RETRY_QUIT_GAD),
900 (STRPTR) GetLocString(MSGID_STARTUP_OLD_MCC),
901 name, minver, minrev, ver, rev))
903 flush = TRUE;
905 else
906 break;
909 else
911 // No MCC at all - no need to attempt flush
912 flush = FALSE;
913 if (!MUI_Request(NULL, NULL, 0L,
914 (STRPTR) GetLocString(MSGID_STARTUP_FAILURE),
915 (STRPTR) GetLocString(MSGID_STARTUP_RETRY_QUIT_GAD),
916 (STRPTR) GetLocString(MSGID_STARTUP_MCC_NOT_FOUND),
917 name, minver, minrev))
919 break;
924 return FALSE;
927 //----------------------------------------------------------------------------