9 #include <exec/types.h>
10 #include <exec/memory.h>
11 #include <exec/ports.h>
13 #include <exec/execbase.h>
17 #include <libraries/dos.h>
18 #include <libraries/dosextens.h>
19 #include <libraries/gadtools.h>
20 #include <libraries/asl.h>
21 #include <libraries/mui.h>
22 #include <devices/clipboard.h>
23 #include <workbench/workbench.h>
24 #include <workbench/icon.h>
25 #include <intuition/intuition.h>
26 #include <intuition/classusr.h>
27 #include <prefs/prefhdr.h>
29 #include <clib/alib_protos.h>
33 #include <proto/exec.h>
34 #include <proto/dos.h>
35 #include <proto/icon.h>
36 #include <proto/intuition.h>
37 #include <proto/gadtools.h>
38 #include <proto/utility.h>
39 #include <proto/asl.h>
40 #include <proto/muimaster.h>
41 #include <proto/locale.h>
42 #include <proto/scalosprefsplugin.h>
45 #include <Year.h> // +jmc+
46 #include <scalosdebug.h>
48 #include <scalos/scalosprefsplugin.h>
49 #include <scalos/scalosmenuprefsplugin.h>
51 struct ScalosMenu_LocaleInfo
55 struct LocaleIFace
*li_ILocale
;
58 #define ScalosMenu_NUMBERS
59 #define ScalosMenu_ARRAY
60 #define ScalosMenu_CODE
61 #include STR(SCALOSLOCALE)
63 //----------------------------------------------------------------------------
65 // limits for various menu entries
66 #define MAX_MENU (NOMENU + 1)
67 #define MAX_MENUITEM (NOITEM + 1)
68 #define MAX_SUBITEM (NOSUB + 1)
70 #define Sizeof(array) (sizeof(array) / sizeof((array)[0]))
72 //----------------------------------------------------------------------------
74 #if !defined(__amigaos4__) && !defined(__AROS__)
77 long _stack
= 16384; // minimum stack size, used by SAS/C startup code
80 //----------------------------------------------------------------------------
82 // local data structures
84 #define KeyButtonHelp(name,key,HelpText)\
87 MUIA_Font, MUIV_Font_Button,\
88 MUIA_Text_Contents, name,\
89 MUIA_Text_PreParse, "\33c",\
90 MUIA_Text_HiChar , key,\
91 MUIA_ControlChar , key,\
92 MUIA_CycleChain , TRUE, \
93 MUIA_InputMode , MUIV_InputMode_RelVerify,\
94 MUIA_Background , MUII_ButtonBack,\
95 MUIA_ShortHelp, HelpText,\
99 #define Application_Return_EDIT 0
100 #define Application_Return_USE 1001
101 #define Application_Return_SAVE 1002
103 //----------------------------------------------------------------------------
107 static void init(void);
108 static void fail(APTR APP_Main
, CONST_STRPTR str
);
109 static BOOL
OpenLibraries(void);
110 static void CloseLibraries(void);
111 static SAVEDS(APTR
) INTERRUPT
OpenAboutMUIFunc(struct Hook
*hook
, Object
*o
, Msg msg
);
112 static STRPTR
GetLocString(ULONG MsgId
);
113 //static void TranslateStringArray(STRPTR *stringArray);
114 static struct MUI_CustomClass
*OpenPrefsModule(CONST_STRPTR FileName
);
115 static struct TagItem
*CreatePluginSubWindowArray(void);
116 static void DisposePrefsPlugin(void);
117 static BOOL
CheckMCCforPlugin(STRPTR
*UsedClasses
, size_t MaxUsedClasses
);
118 static BOOL
CheckMCCVersion(CONST_STRPTR name
, ULONG minver
, ULONG minrev
);
119 #if !defined(__SASC) &&!defined(__MORPHOS__) && !defined(__amigaos4__)
120 size_t stccpy(char *dest
, const char *src
, size_t MaxLen
);
121 #endif /* !defined(__SASC) &&!defined(__MORPHOS__) */
123 //----------------------------------------------------------------------------
127 struct Library
*MUIMasterBase
;
128 T_LOCALEBASE LocaleBase
;
129 struct Library
*IconBase
;
130 struct IntuitionBase
*IntuitionBase
;
131 struct Library
*ScalosPrefsPluginBase
;
134 extern struct Library
*SysBase
;
135 struct MUIMasterIFace
*IMUIMaster
;
136 struct LocaleIFace
*ILocale
;
137 struct IconIFace
*IIcon
;
138 struct IntuitionIFace
*IIntuition
;
139 struct ScalosPrefsPluginIFace
*IScalosPrefsPlugin
;
142 static struct Catalog
*MenuCatalog
;
144 static struct Hook AboutMUIHook
= { { NULL
, NULL
}, HOOKFUNC_DEF(OpenAboutMUIFunc
), NULL
};
146 static struct MUI_CustomClass
*MenuPluginClass
;
148 static struct TagItem
*SubWindowTagList
;
150 static APTR Group_Plugin
;
151 static Object
**PluginSubWindows
;
152 static APTR APP_Main
;
153 static APTR WIN_Main
;
154 static APTR WIN_AboutMUI
;
155 static APTR SaveButton
, UseButton
, CancelButton
;
156 static APTR MenuOpen
, MenuSaveAs
, MenuAbout
, MenuAboutMUI
, MenuQuit
;
157 static APTR MenuResetToDefaults
, MenuLastSaved
, MenuRestore
;
158 static APTR MenuMerge
, MenuImport
, MenuImportTD
, MenuImportP
;
159 static APTR MenuCreateIcons
;
160 static APTR MenuCollapseAll
, MenuExpandAll
;
162 //----------------------------------------------------------------------------
164 int main(int argc
, char *argv
[])
166 LONG Action
= Application_Return_EDIT
;
168 struct RDArgs
*rdArgs
= NULL
;
169 CONST_STRPTR GivenFileName
= NULL
;
170 BPTR oldDir
= (BPTR
)NULL
;
171 ULONG fCreateIcons
= TRUE
;
172 struct DiskObject
*MenuDiskObject
= NULL
;
173 struct DiskObject
*icon
= NULL
;
175 STRPTR UsedClasses
[32];
176 struct WBStartup
*WBenchMsg
=
177 (argc
== 0) ? (struct WBStartup
*)argv
: NULL
;
181 d1(kprintf(__FUNC__
"/%ld: \n", __LINE__
));
183 if (WBenchMsg
&& WBenchMsg
->sm_ArgList
)
185 static char PrgNamePath
[512];
188 if (WBenchMsg
->sm_NumArgs
> 1)
190 arg
= &WBenchMsg
->sm_ArgList
[1];
191 GivenFileName
= arg
->wa_Name
;
195 arg
= &WBenchMsg
->sm_ArgList
[0];
198 ProgramName
= PrgNamePath
;
200 NameFromLock(WBenchMsg
->sm_ArgList
[0].wa_Lock
, PrgNamePath
, sizeof(PrgNamePath
));
201 AddPart(PrgNamePath
, WBenchMsg
->sm_ArgList
[0].wa_Name
, sizeof(PrgNamePath
));
203 oldDir
= CurrentDir(arg
->wa_Lock
);
205 icon
= GetDiskObject(arg
->wa_Name
);
210 tt
= FindToolType(icon
->do_ToolTypes
, "CREATEICONS");
213 if (MatchToolValue(tt
, "NO"))
214 fCreateIcons
= FALSE
;
217 tt
= FindToolType(icon
->do_ToolTypes
, "ACTION");
220 if (MatchToolValue(tt
, "EDIT"))
221 Action
= Application_Return_EDIT
;
222 if (MatchToolValue(tt
, "USE"))
223 Action
= Application_Return_USE
;
224 if (MatchToolValue(tt
, "SAVE"))
225 Action
= Application_Return_SAVE
;
234 ProgramName
= argv
[0];
236 memset(ArgArray
, 0, sizeof(ArgArray
));
238 rdArgs
= ReadArgs("FROM,EDIT/S,USE/S,SAVE/S", ArgArray
, NULL
);
241 GivenFileName
= (CONST_STRPTR
) ArgArray
[0];
243 Action
= Application_Return_EDIT
;
245 Action
= Application_Return_USE
;
247 Action
= Application_Return_SAVE
;
250 d1(kprintf(__FUNC__
"/%ld: MenuPluginClass=%08lx\n", __LINE__
, MenuPluginClass
));
252 if (NULL
== MenuPluginClass
)
253 fail(APP_Main
, "Failed to open Menu Plugin.");
255 MenuDiskObject
= GetDiskObject(ProgramName
);
257 Group_Plugin
= NewObject(MenuPluginClass
->mcc_Class
, 0,
258 MUIA_ScalosPrefs_CreateIcons
, fCreateIcons
,
259 MUIA_ScalosPrefs_ProgramName
, (IPTR
) ProgramName
,
262 d1(kprintf(__FUNC__
"/%ld: Group_Plugin=%08lx\n", __LINE__
, Group_Plugin
));
263 if (NULL
== Group_Plugin
)
264 fail(APP_Main
, "Failed to create Group_Plugin.");
266 if (!CheckMCCforPlugin(UsedClasses
, Sizeof(UsedClasses
)))
267 fail(APP_Main
, "Required MCC missing.");
269 SubWindowTagList
= CreatePluginSubWindowArray();
271 d1(kprintf(__FUNC__
"/%ld: \n", __LINE__
));
273 APP_Main
= ApplicationObject
,
274 MUIA_Application_Title
, GetLocString(MSGID_TITLENAME
),
275 MUIA_Application_Version
, "$VER: Scalos Menu V40.20 (" __DATE__
")" COMPILER_STRING
,
276 MUIA_Application_Copyright
, "The Scalos Team, 2000" CURRENTYEAR
,
277 MUIA_Application_Author
, "The Scalos Team",
278 MUIA_Application_Description
, "Scalos Menu preferences editor",
279 MUIA_Application_Base
, "SCALOS_MENU",
280 MenuDiskObject
? MUIA_Application_DiskObject
: TAG_IGNORE
, MenuDiskObject
,
281 #if defined(MUIA_Application_UsedClasses)
282 MUIA_Application_UsedClasses
, UsedClasses
,
283 #endif /* MUIA_Application_UsedClasses */
285 SubWindow
, WIN_Main
= WindowObject
,
286 MUIA_Window_Title
, GetLocString(MSGID_TITLENAME
),
287 MUIA_Window_ID
, MAKE_ID('M','A','I','N'),
288 MUIA_Window_AppWindow
, TRUE
,
289 WindowContents
, VGroup
,
293 Child
, SaveButton
= KeyButtonHelp(GetLocString(MSGID_SAVENAME
),
294 's', GetLocString(MSGID_SHORTHELP_SAVEBUTTON
)),
295 Child
, UseButton
= KeyButtonHelp(GetLocString(MSGID_USENAME
),
296 'u', GetLocString(MSGID_SHORTHELP_USEBUTTON
)),
297 Child
, CancelButton
= KeyButtonHelp(GetLocString(MSGID_CANCELNAME
),
298 'c', GetLocString(MSGID_SHORTHELP_CANCELBUTTON
)),
303 MUIA_Application_Menustrip
, MenustripObject
,
304 Child
, MenuObjectT(GetLocString(MSGID_MENU_PROJECT
)),
305 Child
, MenuOpen
= MenuitemObject
,
306 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_PROJECT_OPEN
),
307 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_PROJECT_OPEN_SHORT
),
309 Child
, MenuMerge
= MenuitemObject
,
310 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_PROJECT_MERGE
),
311 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_PROJECT_MERGE_SHORT
),
313 Child
, MenuSaveAs
= MenuitemObject
,
314 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_PROJECT_SAVEAS
),
315 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_PROJECT_SAVEAS_SHORT
),
317 Child
, MenuitemObject
,
318 MUIA_Menuitem_Title
, -1,
320 Child
, MenuImport
= MenuitemObject
,
321 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_PROJECT_IMPORT
),
322 Child
, MenuImportTD
= MenuitemObject
,
323 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_PROJECT_IMPORT_TD
),
324 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_PROJECT_IMPORT_TD_SHORT
),
326 Child
, MenuImportP
= MenuitemObject
,
327 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_PROJECT_IMPORT_P
),
328 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_PROJECT_IMPORT_P_SHORT
),
331 Child
, MenuitemObject
,
332 MUIA_Menuitem_Title
, -1,
334 Child
, MenuAbout
= MenuitemObject
,
335 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_PROJECT_ABOUT
),
337 Child
, MenuAboutMUI
= MenuitemObject
,
338 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_PROJECT_ABOUTMUI
),
340 Child
, MenuitemObject
,
341 MUIA_Menuitem_Title
, -1,
343 Child
, MenuQuit
= MenuitemObject
,
344 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_PROJECT_QUIT
),
345 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_PROJECT_QUIT_SHORT
),
349 Child
, MenuObjectT(GetLocString(MSGID_MENU_EDIT
)),
350 Child
, MenuResetToDefaults
= MenuitemObject
,
351 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_EDIT_RESETTODEFAULTS
),
352 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_EDIT_RESETTODEFAULTS_SHORT
),
354 Child
, MenuLastSaved
= MenuitemObject
,
355 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_EDIT_LASTSAVED
),
356 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_EDIT_LASTSAVED_SHORT
),
358 Child
, MenuRestore
= MenuitemObject
,
359 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_EDIT_RESTORE
),
360 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_EDIT_RESTORE_SHORT
),
362 Child
, MenuitemObject
,
363 MUIA_Menuitem_Title
, -1,
365 Child
, MenuCollapseAll
= MenuitemObject
,
366 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_EDIT_COLLAPSEALL
),
368 Child
, MenuExpandAll
= MenuitemObject
,
369 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_EDIT_EXPANDALL
),
372 Child
, MenuObjectT(GetLocString(MSGID_MENU_SETTINGS
)),
373 Child
, MenuCreateIcons
= MenuitemObject
,
374 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_SETTINGS_CREATEICONS
),
375 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_SETTINGS_CREATEICONS_SHORT
),
376 MUIA_Menuitem_Checkit
, TRUE
,
377 MUIA_Menuitem_Checked
, fCreateIcons
,
380 End
, //MenuStripObject
382 SubWindowTagList
? TAG_MORE
: TAG_IGNORE
, SubWindowTagList
,
383 End
; //ApplicationObject
385 d1(kprintf(__FUNC__
"/%ld: APP_Main=%08lx\n", __LINE__
, APP_Main
));
387 if (NULL
== APP_Main
)
389 MUI_DisposeObject(Group_Plugin
);
391 fail(APP_Main
, "Failed to create Application.");
394 set(Group_Plugin
, MUIA_ScalosPrefs_MainWindow
, (IPTR
) WIN_Main
);
395 set(Group_Plugin
, MUIA_ScalosPrefs_Application
, (IPTR
) APP_Main
);
397 DoMethod(Group_Plugin
, MUIM_ScalosPrefs_PageActive
, TRUE
);
399 DoMethod(WIN_Main
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
400 WIN_Main
, 3, MUIM_Set
, MUIA_Window_Open
, FALSE
);
401 DoMethod(WIN_Main
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
402 APP_Main
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
403 DoMethod(CancelButton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
404 APP_Main
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
406 DoMethod(MenuQuit
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
407 APP_Main
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
409 DoMethod(SaveButton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
410 APP_Main
, 2, MUIM_Application_ReturnID
, Application_Return_SAVE
);
412 DoMethod(UseButton
, MUIM_Notify
,MUIA_Pressed
, FALSE
,
413 APP_Main
, 2, MUIM_Application_ReturnID
, Application_Return_USE
);
415 DoMethod(MenuQuit
, MUIM_Notify
,MUIA_Menuitem_Trigger
,MUIV_EveryTime
,
416 APP_Main
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
418 DoMethod(MenuOpen
, MUIM_Notify
,MUIA_Menuitem_Trigger
,MUIV_EveryTime
,
419 Group_Plugin
, 1, MUIM_ScalosPrefs_OpenConfig
);
421 DoMethod(MenuSaveAs
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
422 Group_Plugin
, 1, MUIM_ScalosPrefs_SaveConfigAs
);
424 DoMethod(MenuResetToDefaults
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
425 Group_Plugin
, 1, MUIM_ScalosPrefs_ResetToDefaults
);
427 DoMethod(MenuLastSaved
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
428 Group_Plugin
, 1, MUIM_ScalosPrefs_LastSavedConfig
);
430 DoMethod(MenuRestore
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
431 Group_Plugin
, 1, MUIM_ScalosPrefs_RestoreConfig
);
433 DoMethod(MenuAbout
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
434 Group_Plugin
, 1, MUIM_ScalosPrefs_About
);
436 DoMethod(MenuAboutMUI
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
437 APP_Main
, 2, MUIM_CallHook
, &AboutMUIHook
);
439 DoMethod(MenuImportTD
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
440 Group_Plugin
, 1, MUIM_ScalosPrefs_MenuPrefs_ImportTD
);
442 DoMethod(MenuImportP
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
443 Group_Plugin
, 1, MUIM_ScalosPrefs_MenuPrefs_ImportP
);
445 DoMethod(MenuMerge
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
446 Group_Plugin
, 1, MUIM_ScalosPrefs_MenuPrefs_Merge
);
448 DoMethod(MenuCollapseAll
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
449 Group_Plugin
, 1, MUIM_ScalosPrefs_MenuPrefs_CollapseAll
);
451 DoMethod(MenuExpandAll
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
452 Group_Plugin
, 1, MUIM_ScalosPrefs_MenuPrefs_ExpandAll
);
454 DoMethod(MenuCreateIcons
, MUIM_Notify
, MUIA_Menuitem_Checked
, MUIV_EveryTime
,
455 Group_Plugin
, 3, MUIM_Set
, MUIA_ScalosPrefs_CreateIcons
, MUIV_TriggerValue
);
459 DoMethod(Group_Plugin
, MUIM_ScalosPrefs_ParseToolTypes
, icon
->do_ToolTypes
);
464 DoMethod(Group_Plugin
, MUIM_ScalosPrefs_LoadNamedConfig
, GivenFileName
);
468 DoMethod(Group_Plugin
, MUIM_ScalosPrefs_LoadConfig
);
471 if (Application_Return_EDIT
== Action
)
473 set(WIN_Main
, MUIA_Window_Open
, TRUE
);
475 get(WIN_Main
, MUIA_Window_Open
, &win_opened
);
484 Action
= DoMethod(APP_Main
, MUIM_Application_NewInput
, &sigs
);
488 case MUIV_Application_ReturnID_Quit
:
489 case Application_Return_SAVE
:
490 case Application_Return_USE
:
497 sigs
= Wait(sigs
| SIGBREAKF_CTRL_C
);
499 if (sigs
& SIGBREAKF_CTRL_C
)
509 printf("failed to open main window !\n");
515 case Application_Return_SAVE
:
516 DoMethod(Group_Plugin
, MUIM_ScalosPrefs_SaveConfig
);
518 case Application_Return_USE
:
519 DoMethod(Group_Plugin
, MUIM_ScalosPrefs_UseConfig
);
523 set(WIN_Main
, MUIA_Window_Open
, FALSE
);
526 FreeDiskObject(MenuDiskObject
);
532 FreeDiskObject(icon
);
535 fail(APP_Main
, NULL
);
541 static VOID
fail(APTR APP_Main
, CONST_STRPTR str
)
544 MUI_DisposeObject(APP_Main
);
546 DisposePrefsPlugin();
550 CloseCatalog(MenuCatalog
);
566 static void init(void)
568 if (!OpenLibraries())
569 fail(NULL
, "Failed to open "MUIMASTER_NAME
".");
572 MenuCatalog
= OpenCatalogA(NULL
, "Scalos/ScalosMenu.catalog", NULL
);
574 MenuPluginClass
= OpenPrefsModule("Menu.prefsplugin");
578 static BOOL
OpenLibraries(void)
580 IntuitionBase
= (struct IntuitionBase
*) OpenLibrary("intuition.library", 39);
581 if (NULL
== IntuitionBase
)
584 IIntuition
= (struct IntuitionIFace
*)GetInterface((struct Library
*)IntuitionBase
, "main", 1, NULL
);
585 if (NULL
== IIntuition
)
589 MUIMasterBase
= OpenLibrary("zune.library", 0);
590 if (NULL
== MUIMasterBase
)
591 MUIMasterBase
= OpenLibrary(MUIMASTER_NAME
, MUIMASTER_VMIN
-1);
592 if (NULL
== MUIMasterBase
)
595 IMUIMaster
= (struct MUIMasterIFace
*)GetInterface((struct Library
*)MUIMasterBase
, "main", 1, NULL
);
596 if (NULL
== IMUIMaster
)
600 IconBase
= OpenLibrary("icon.library", 0);
601 if (NULL
== IconBase
)
604 IIcon
= (struct IconIFace
*)GetInterface((struct Library
*)IconBase
, "main", 1, NULL
);
609 LocaleBase
= (T_LOCALEBASE
) OpenLibrary("locale.library", 39);
612 ILocale
= (struct LocaleIFace
*)GetInterface((struct Library
*)LocaleBase
, "main", 1, NULL
);
619 static void CloseLibraries(void)
624 DropInterface((struct Interface
*)ILocale
);
630 CloseLibrary((struct Library
*) LocaleBase
);
636 DropInterface((struct Interface
*)IIcon
);
642 CloseLibrary(IconBase
);
648 DropInterface((struct Interface
*)IMUIMaster
);
654 CloseLibrary(MUIMasterBase
);
655 MUIMasterBase
= NULL
;
660 DropInterface((struct Interface
*)IIntuition
);
666 CloseLibrary((struct Library
*) IntuitionBase
);
667 IntuitionBase
= NULL
;
671 //----------------------------------------------------------------------------
673 static STRPTR
GetLocString(ULONG MsgId
)
675 struct ScalosMenu_LocaleInfo li
;
677 li
.li_Catalog
= MenuCatalog
;
679 li
.li_LocaleBase
= LocaleBase
;
681 li
.li_ILocale
= ILocale
;
684 return (STRPTR
) GetScalosMenuString(&li
, MsgId
);
687 static void TranslateStringArray(STRPTR *stringArray)
691 *stringArray = GetLocString((IPTR) *stringArray);
696 //----------------------------------------------------------------------------
698 static SAVEDS(APTR
) INTERRUPT
OpenAboutMUIFunc(struct Hook
*hook
, Object
*o
, Msg msg
)
700 if (NULL
== WIN_AboutMUI
)
702 WIN_AboutMUI
= MUI_NewObject(MUIC_Aboutmui
,
703 MUIA_Window_RefWindow
, WIN_Main
,
704 MUIA_Aboutmui_Application
, APP_Main
,
709 set(WIN_AboutMUI
, MUIA_Window_Open
, TRUE
);
714 //----------------------------------------------------------------------------
716 static struct MUI_CustomClass
*OpenPrefsModule(CONST_STRPTR FileName
)
718 struct MUI_CustomClass
*pclass
= NULL
;
720 d1(kprintf(__FUNC__
"/%ld: FileName=<%s>\n", __LINE__
, FileName
));
723 ScalosPrefsPluginBase
= OpenLibrary(FileName
, 0);
724 d1(kprintf(__FUNC__
"/%ld: ScalosPrefsPluginBase=%08lx\n", __LINE__
, ScalosPrefsPluginBase
));
725 if (NULL
== ScalosPrefsPluginBase
)
728 IScalosPrefsPlugin
= (struct ScalosPrefsPluginIFace
*)GetInterface(
729 ScalosPrefsPluginBase
, "main", 1, NULL
733 pclass
= (struct MUI_CustomClass
*) SCAGetPrefsInfo(SCAPREFSINFO_GetClass
);
734 d1(kprintf(__FUNC__
"/%ld: PluginClass=%08lx\n", __LINE__
, pclass
));
740 DisposePrefsPlugin();
746 static struct TagItem
*CreatePluginSubWindowArray(void)
748 struct TagItem
*SubWindowTagList
;
750 ULONG SubWindowCount
= 0;
753 d1(kprintf(__FUNC__
"/%ld: \n", __LINE__
));
755 PluginSubWindows
= (Object
**) DoMethod(Group_Plugin
, MUIM_ScalosPrefs_CreateSubWindows
);
757 d1(kprintf(__FUNC__
"/%ld: PluginSubWindows=%08lx\n", __LINE__
, PluginSubWindows
));
759 for (n
=0; PluginSubWindows
&& PluginSubWindows
[n
]; n
++)
762 d1(kprintf(__FUNC__
"/%ld: SubWindowCount=%lu\n", __LINE__
, SubWindowCount
));
764 SubWindowTagList
= ti
= calloc(1 + SubWindowCount
, sizeof(struct TagItem
));
766 d1(kprintf(__FUNC__
"/%ld: SubWindowTagList=%08lx\n", __LINE__
, SubWindowTagList
));
767 if (NULL
== SubWindowTagList
)
770 for (n
=0; PluginSubWindows
&& PluginSubWindows
[n
]; n
++)
772 ti
->ti_Tag
= MUIA_Application_Window
;
773 ti
->ti_Data
= (IPTR
) PluginSubWindows
[n
];
777 ti
->ti_Tag
= TAG_END
;
779 d1(kprintf(__FUNC__
"/%ld: SubWindowTagList=%08lx\n", __LINE__
, SubWindowTagList
));
781 return SubWindowTagList
;
785 static void DisposePrefsPlugin(void)
788 if (IScalosPrefsPlugin
)
790 DropInterface((struct Interface
*)IScalosPrefsPlugin
);
791 IScalosPrefsPlugin
= NULL
;
794 if (ScalosPrefsPluginBase
)
796 d1(kprintf(__FUNC__
"/%ld: Plugin=<%s> OpenCount=%ld\n", \
797 __LINE__
, ScalosPrefsPluginBase
->lib_Node
.ln_Name
, ScalosPrefsPluginBase
->lib_OpenCnt
));
799 if (NULL
== Group_Plugin
)
800 CloseLibrary(ScalosPrefsPluginBase
);
801 ScalosPrefsPluginBase
= NULL
;
805 static BOOL
CheckMCCforPlugin(STRPTR
*UsedClasses
, size_t MaxUsedClasses
)
807 const struct MUIP_ScalosPrefs_MCCList
*RequiredMccList
= NULL
;
809 RequiredMccList
= (const struct MUIP_ScalosPrefs_MCCList
*) DoMethod(Group_Plugin
, MUIM_ScalosPrefs_GetListOfMCCs
);
811 while (RequiredMccList
&& RequiredMccList
->MccName
)
813 if (!CheckMCCVersion(RequiredMccList
->MccName
,
814 RequiredMccList
->MccMinVersion
,
815 RequiredMccList
->MccMinRevision
))
818 if (MaxUsedClasses
> 1)
820 *UsedClasses
++ = (STRPTR
) RequiredMccList
->MccName
;
832 //----------------------------------------------------------------------------
834 // Checks if a certain version of a MCC is available
835 static BOOL
CheckMCCVersion(CONST_STRPTR name
, ULONG minver
, ULONG minrev
)
839 d1(kprintf(__FILE__
"/" __FUNC__
"/%ld: %s ", name
, __LINE__
);)
845 struct Library
*base
;
848 // First we attempt to acquire the version and revision through MUI
849 Object
*obj
= MUI_NewObject((STRPTR
) name
, TAG_DONE
);
852 get(obj
, MUIA_Version
, &ver
);
853 get(obj
, MUIA_Revision
, &rev
);
855 MUI_DisposeObject(obj
);
857 if(ver
> minver
|| (ver
== minver
&& rev
>= minrev
))
859 d1(kprintf(__FILE__
"/" __FUNC__
"/%ld: v%ld.%ld found through MUIA_Version/Revision\n", __LINE__
, ver
, rev
);)
864 // If we did't get the version we wanted, let's try to open the
865 // libraries ourselves and see what happens...
866 stccpy(libname
, "PROGDIR:mui", sizeof(libname
));
867 AddPart(libname
, name
, sizeof(libname
));
869 if ((base
= OpenLibrary(&libname
[8], 0)) || (base
= OpenLibrary(&libname
[0], 0)))
871 UWORD OpenCnt
= base
->lib_OpenCnt
;
873 ver
= base
->lib_Version
;
874 rev
= base
->lib_Revision
;
878 // we add some additional check here so that eventual broken .mcc also have
879 // a chance to pass this test (i.e. Toolbar.mcc is broken)
880 if (ver
> minver
|| (ver
== minver
&& rev
>= minrev
))
882 d1(kprintf(__FILE__
"/" __FUNC__
"/%ld: v%ld.%ld found through OpenLibrary()\n", __LINE__
, ver
, rev
);)
888 if (MUI_Request(NULL
, NULL
, 0L, GetLocString(MSGID_STARTUP_FAILURE
),
889 GetLocString(MSGID_STARTUP_RETRY_QUIT_GAD
), GetLocString(MSGID_STARTUP_MCC_IN_USE
),
890 (IPTR
) name
, minver
, minrev
, ver
, rev
))
898 // Attempt to flush the library if open count is 0 or because the
899 // user wants to retry (meaning there's a chance that it's 0 now)
903 struct Library
*result
;
906 if ((result
= (struct Library
*) FindName(&((struct ExecBase
*)SysBase
)->LibList
, name
)))
913 d1(kprintf(__FILE__
"/" __FUNC__
"/%ld: couldn`t find minimum required version.\n", __LINE__
);)
915 // We're out of luck - open count is 0, we've tried to flush
916 // and still haven't got the version we want
918 if (MUI_Request(NULL
, NULL
, 0L, GetLocString(MSGID_STARTUP_FAILURE
),
919 GetLocString(MSGID_STARTUP_RETRY_QUIT_GAD
), GetLocString(MSGID_STARTUP_OLD_MCC
),
920 (IPTR
) name
, minver
, minrev
, ver
, rev
))
930 // No MCC at all - no need to attempt flush
932 if (!MUI_Request(NULL
, NULL
, 0L, GetLocString(MSGID_STARTUP_FAILURE
),
933 GetLocString(MSGID_STARTUP_RETRY_QUIT_GAD
), GetLocString(MSGID_STARTUP_MCC_NOT_FOUND
),
934 (IPTR
) name
, minver
, minrev
))
944 //----------------------------------------------------------------------------
946 #if !defined(__SASC) && !defined(__amigaos4__)
947 // Replacement for SAS/C library functions
949 #if !defined(__MORPHOS__)
950 // Replacement for SAS/C library functions
952 size_t stccpy(char *dest
, const char *src
, size_t MaxLen
)
956 while (*src
&& MaxLen
> 1)
967 #endif /*__MORPHOS__*/
969 #endif /* !defined(__SASC) && !defined(__amigaos4__) */
970 //-----------------------------------------------------------------------------