2 Copyright © 2011, The AROS Development Team. All rights reserved.
11 #include <proto/dos.h>
12 #include <proto/intuition.h>
13 #include <proto/exec.h>
14 #include <proto/icon.h>
15 #include <proto/workbench.h>
16 #include <proto/arossupport.h>
18 #include "workbook_intern.h"
21 /* Allocate classes and run the main app */
22 static int WB_Main(struct WorkbookBase
*wb
)
26 wb
->wb_WBApp
= WBApp_MakeClass(wb
);
30 wb
->wb_WBWindow
= WBWindow_MakeClass(wb
);
34 wb
->wb_WBVirtual
= WBVirtual_MakeClass(wb
);
35 if (!wb
->wb_WBVirtual
)
38 wb
->wb_WBSet
= WBSet_MakeClass(wb
);
42 wb
->wb_WBIcon
= WBIcon_MakeClass(wb
);
46 wb
->wb_App
= NewObject(WBApp
, NULL
, TAG_END
);
48 DoMethod(wb
->wb_App
, WBAM_WORKBENCH
, 0);
49 DisposeObject(wb
->wb_App
);
55 FreeClass(wb
->wb_WBIcon
);
57 FreeClass(wb
->wb_WBSet
);
59 FreeClass(wb
->wb_WBVirtual
);
61 FreeClass(wb
->wb_WBWindow
);
63 FreeClass(wb
->wb_WBApp
);
71 /* This wrapper is needed, so that we can start
72 * workbench items from an Input handler
74 AROS_PROCH(wbOpener
, argstr
, argsize
, SysBase
)
78 APTR WorkbenchBase
= OpenLibrary("workbench.library", 0);
79 APTR DOSBase
= OpenLibrary("dos.library", 0);
81 if (WorkbenchBase
&& DOSBase
) {
82 /* 'argstr' is already an absolute path */
83 OpenWorkbenchObject(argstr
, TAG_END
);
86 CloseLibrary(DOSBase
);
87 CloseLibrary(WorkbenchBase
);
95 ULONG
WorkbookMain(void)
97 struct WorkbookBase
*wb
;
99 int rc
= RETURN_ERROR
;
103 wb
= AllocVec(sizeof(*wb
), MEMF_ANY
| MEMF_CLEAR
);
107 wb
->wb_DOSBase
= OpenLibrary("dos.library", 0);
108 if (wb
->wb_DOSBase
== NULL
)
111 DOSBase
= wb
->wb_DOSBase
;
113 wb
->wb_IntuitionBase
= OpenLibrary("intuition.library",0);
114 if (wb
->wb_IntuitionBase
== NULL
)
117 wb
->wb_UtilityBase
= OpenLibrary("utility.library",0);
118 if (wb
->wb_UtilityBase
== NULL
)
121 wb
->wb_GadToolsBase
= OpenLibrary("gadtools.library",0);
122 if (wb
->wb_GadToolsBase
== NULL
)
125 /* Version 44 or later for DrawIconStateA */
126 wb
->wb_IconBase
= OpenLibrary("icon.library",44);
127 if (wb
->wb_IconBase
== NULL
)
130 /* Version 44 or later for OpenWorkbenchObject */
131 wb
->wb_WorkbenchBase
= OpenLibrary("workbench.library",44);
132 if (wb
->wb_WorkbenchBase
== NULL
)
135 wb
->wb_GfxBase
= OpenLibrary("graphics.library",0);
136 if (wb
->wb_GfxBase
== NULL
)
139 wb
->wb_LayersBase
= OpenLibrary("layers.library", 0);
140 if (wb
->wb_LayersBase
== NULL
)
143 wb
->wb_OpenerSegList
= CreateSegList(wbOpener
);
144 if (wb
->wb_OpenerSegList
== BNULL
)
147 SetConsoleTask(NULL
);
150 UnLoadSeg(wb
->wb_OpenerSegList
);
154 if (wb
->wb_LayersBase
)
155 CloseLibrary(wb
->wb_LayersBase
);
158 CloseLibrary(wb
->wb_GfxBase
);
160 if (wb
->wb_WorkbenchBase
)
161 CloseLibrary(wb
->wb_WorkbenchBase
);
164 CloseLibrary(wb
->wb_IconBase
);
166 if (wb
->wb_GadToolsBase
)
167 CloseLibrary(wb
->wb_GadToolsBase
);
169 if (wb
->wb_IntuitionBase
)
170 CloseLibrary(wb
->wb_GadToolsBase
);
173 CloseLibrary(wb
->wb_DOSBase
);