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 //-----\_/ \_/---------\ ___________________________________ /------
22 // Interface setup and entrypoints for ScalosDelete
26 // int wbmain (WBStartup *);
27 // int main (int , char **);
28 // void ExitMUI (APTR, STRPTR);
29 // void InitMUI (void);
30 // void SetupInterface(void);
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
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
55 #include"Delete.module.h"
57 //----------------------------------------------------------------------------
61 int wbmain (struct WBStartup
*);
62 int main (int, char **);
63 void ExitMUI (APTR
, STRPTR
);
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
77 extern struct ExecBase
*SysBase
;
78 struct Library
*MUIMasterBase
= NULL
;
79 struct Library
*AslBase
= NULL
;
81 T_UTILITYBASE UtilityBase
= NULL
;
83 struct ScalosBase
*ScalosBase
= NULL
;
84 T_LOCALEBASE LocaleBase
= NULL
;
85 struct Catalog
*WordsCat
= NULL
;
86 static struct Locale
*DeleteLocale
= NULL
;
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
;
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 */
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..)
167 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
170 EasyRequest(NULL
, &ErrorDisplay
, NULL
, errString
, 0);
172 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
174 MUI_DisposeObject(errApp
);
176 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
186 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
188 CloseCatalog(WordsCat
);
189 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
191 CloseLocale(DeleteLocale
);
192 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
196 DropInterface((struct Interface
*)IIntuition
);
199 CloseLibrary((struct Library
*) IntuitionBase
);
202 DropInterface((struct Interface
*)IMUIMaster
);
205 CloseLibrary(MUIMasterBase
);
208 DropInterface((struct Interface
*)IAsl
);
211 CloseLibrary(AslBase
);
214 CloseLibrary((struct Library
*) UtilityBase
);
218 DropInterface((struct Interface
*)IScalos
);
221 CloseLibrary(&ScalosBase
->scb_LibNode
);
222 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
225 DropInterface((struct Interface
*)ILocale
);
228 CloseLibrary((struct Library
*) LocaleBase
);
230 d1(KPrintF("%s/%s/%ld: END\n", __FILE__
, __FUNC__
, __LINE__
));
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
".");
252 IMUIMaster
= (struct MUIMasterIFace
*)GetInterface((struct Library
*)MUIMasterBase
, "main", 1, NULL
);
256 if(!(AslBase
= OpenLibrary(AslName
, 39)))
258 ExitMUI(NULL
, "Unable to open "AslName
".");
263 IAsl
= (struct AslIFace
*)GetInterface((struct Library
*)AslBase
, "main", 1, NULL
);
266 if(!(IntuitionBase
= (struct IntuitionBase
*) OpenLibrary(IntuitionName
, 39)))
268 ExitMUI(NULL
, "Unable to open " IntuitionName
".");
273 IIntuition
= (struct IntuitionIFace
*)GetInterface((struct Library
*)IntuitionBase
, "main", 1, NULL
);
277 if(!(UtilityBase
= (T_UTILITYBASE
) OpenLibrary(UTILITYNAME
, 39)))
279 ExitMUI(NULL
, "Unable to open "UTILITYNAME
".");
283 if(!(ScalosBase
= (struct ScalosBase
*) OpenLibrary("scalos.library", 39)))
285 ExitMUI(NULL
, "Unable to open scalos.library.");
290 IScalos
= (struct ScalosIFace
*)GetInterface((struct Library
*)ScalosBase
, "main", 1, NULL
);
294 if(!(LocaleBase
= (T_LOCALEBASE
)OpenLibrary("locale.library", 37)))
296 ExitMUI(NULL
, "Unable to open locale.library v39+");
301 ILocale
= (struct LocaleIFace
*)GetInterface((struct Library
*)LocaleBase
, "main", 1, NULL
);
305 DeleteLocale
= OpenLocale(NULL
);
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");
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
));
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
)
352 if (!CheckMCCVersion(MUIC_NList
, 20, 121) ||
353 !CheckMCCVersion(MUIC_NListview
, 19, 66) ||
354 !CheckMCCVersion(MUIC_Lamp
, 11, 1) )
359 // Bomb if the user has started the program from shell (daft user...) otherwise
360 // read the filelist...
363 ExitMUI(MUI_App
, "Delete.module may not be started from shell");
366 // Bomb out if something has gone clogs-skyward
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
);
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
);
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
);
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...
422 Source
= DoMethod(MUI_App
, MUIM_Application_NewInput
, &Sig
);
425 case MUIV_Application_ReturnID_Quit
:
429 DoMethod(MUI_App
, MUIM_Application_Save
, MUIV_Application_Save_ENVARC
);
431 DoMethod(MUI_App
, MUIM_Application_Save
, MUIV_Application_Save_ENV
);
434 DoMethod(MUI_App
, MUIM_Application_Load
, MUIV_Application_Load_ENV
);
437 GetDetails((struct WBStartup
*)argv
);
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
);
452 // Clean up and begone.
453 ExitMUI(MUI_App
, NULL
);
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
,
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
,
517 Child
, TextUndoPossible
= TextObject
,
518 MUIA_Text_Contents
, GetLocString(MSGID_UNDO_NOT_POSSIBLE
),
523 MUIA_Group_Spacing
, 0,
524 Child
, LV_Files
= NListviewObject
,
526 MUIA_NListview_Vert_ScrollBar
, TRUE
,
527 MUIA_NListview_NList
, NListObject
,
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
,
538 End
, //NListviewObject
539 Child
, BT_Details
= KeyButtonChain(GetLocString(MSG_BUTTON_FULL
), Keys
[0][0], 1),
542 Child
, TX_ReadOut
= TextObject
,
544 MUIA_Background
, MUII_TextBack
,
546 MUIA_Text_PreParse
, "\33c",
547 MUIA_FixHeightTxt
, " ",
555 MUIA_Background
, MUII_GroupBack
,
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
)),
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
)),
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
)),
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
)),
582 GroupFrameT(GetLocString(MSG_LABEL_TLOC
)),
584 Child
, ST_TrashDir
= PopaslObject
,
585 MUIA_Popstring_String
, StringObject
,
587 MUIA_String_MaxLen
, 128,
589 MUIA_ControlChar
, Keys
[5][0],
590 MUIA_ShortHelp
, GetLocString(MSG_HELP_TLOC
),
591 MUIA_ExportID
, MAKE_ID('S', 'T', 'T', 'C'),
593 MUIA_Popstring_Button
, PopButton(MUII_PopDrawer
),
595 ASLFR_TitleText
, GetLocString(MSG_ASL_TITLE
),
596 ASLFR_RejectIcons
, TRUE
,
597 ASLFR_DrawersOnly
, TRUE
,
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),
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),
617 Child
, GP_Progress
= VGroup
,
619 MUIA_Background
, MUII_GroupBack
,
622 Child
, TX_Progress
= TextObject
,
623 MUIA_Background
, MUII_TextBack
,
626 MUIA_Background
, MUII_TextBack
,
627 MUIA_Text_PreParse
, "\33c",
628 MUIA_FixHeightTxt
, " ",
630 Child
, BT_STOP
= KeyButtonChain(GetLocString(MSG_BUTTON_STOP
), Keys
[12][0], 1),
633 Child
, GA_Progress
= GaugeObject
,
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
),
642 MUIA_Scale_Horiz
, TRUE
,
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
,
656 MUIA_Background
, MUII_TextBack
,
657 MUIA_Text_Contents
, GetLocString(MSG_ABOUT_HEAD
),
662 MUIA_Text_Contents
, GetLocString(MSG_LABEL_VERS
),
663 MUIA_Text_PreParse
, "\33r",
666 MUIA_Text_Contents
, VersionBuffer
,
670 MUIA_Text_Contents
, GetLocString(MSG_LABEL_COMP
),
671 MUIA_Text_PreParse
, "\33r",
674 MUIA_Text_Contents
, DateBuffer
,
678 Child
, ScrollgroupObject
,
679 MUIA_Scrollgroup_Contents
, VGroupV
,
682 MUIA_Background
, MUII_TextBack
,
683 MUIA_Text_Contents
, GetLocString(MSG_ABOUT_BODY
),
686 End
, //ScrollgroupObject
688 Child
, BT_About_MUI
= KeyButtonChain(GetLocString(MSG_BUTTON_AMUI
), Keys
[13][0], 1),
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
),
698 Child
, MenuAboutMUI
= MenuitemObject
,
699 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_PROJECT_ABOUTMUI
),
701 Child
, MenuitemObject
,
702 MUIA_Menuitem_Title
, -1,
704 Child
, MenuQuit
= MenuitemObject
,
705 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_PROJECT_QUIT
),
706 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_PROJECT_QUIT_SHORT
),
710 End
, //MenuStripObject
711 End
; //ApplicationObject
714 //----------------------------------------------------------------------------
716 CONST_STRPTR
GetLocString(ULONG MsgId
)
718 struct Delete_LocaleInfo li
;
720 li
.li_Catalog
= WordsCat
;
722 li
.li_LocaleBase
= LocaleBase
;
724 li
.li_ILocale
= ILocale
;
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
)
738 size_t Len
= strlen(dest
);
746 while (DestLen
> 1 && *src
)
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
)
765 while (*src
&& MaxLen
> 1)
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
,
792 set(WIN_AboutMUI
, MUIA_Window_Open
, TRUE
);
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
)
817 d1(kprintf(__FILE__
"/" __FUNC__
"/%ld: %s ", name
, __LINE__
);)
823 struct Library
*base
;
826 // First we attempt to acquire the version and revision through MUI
827 Object
*obj
= MUI_NewObject((STRPTR
) name
, TAG_DONE
);
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
);)
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
;
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
);)
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
))
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)
883 struct Library
*result
;
886 if ((result
= (struct Library
*) FindName(&((struct ExecBase
*)SysBase
)->LibList
, name
)))
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
))
911 // No MCC at all - no need to attempt flush
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
))
927 //----------------------------------------------------------------------------