revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / gadtools / gadtools_init.c
blobd82eec8c30d1005c8ee6432402fcae1088586b1a
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: GadTools initialization code.
6 Lang: English.
7 */
8 #include <exec/libraries.h>
9 #include <exec/types.h>
11 #include <aros/symbolsets.h>
12 #include <utility/tagitem.h>
13 #include <utility/utility.h>
14 #include <intuition/classes.h>
15 #include <intuition/imageclass.h>
16 #include <proto/exec.h>
18 #include "gadtools_intern.h"
19 #include LC_LIBDEFS_FILE
21 #ifndef INTUITIONNAME
22 #define INTUITIONNAME "intuition.library"
23 #endif
24 /****************************************************************************************/
26 static int openall(LIBBASETYPEPTR LIBBASE)
28 if ((UtilityBase = OpenLibrary("utility.library", 0)) != NULL) {
29 if ((GfxBase = OpenLibrary("graphics.library", 0)) != NULL) {
30 if ((LayersBase = OpenLibrary("layers.library", 0)) != NULL) {
31 if ((IntuitionBase = OpenLibrary("intuition.library", 0)) != NULL) {
32 return TRUE;
34 CloseLibrary(LayersBase);
36 CloseLibrary(GfxBase);
38 CloseLibrary(UtilityBase);
40 return FALSE;
43 static void closeall(LIBBASETYPEPTR LIBBASE)
45 CloseLibrary(IntuitionBase);
46 CloseLibrary(LayersBase);
47 CloseLibrary(GfxBase);
48 CloseLibrary(UtilityBase);
51 static int InitRootClass(LIBBASETYPEPTR LIBBASE)
53 return openall(LIBBASE);
56 static int Init(LIBBASETYPEPTR LIBBASE)
58 /* This function is single-threaded by exec by calling Forbid. */
59 InitSemaphore(&LIBBASE->bevelsema);
60 LIBBASE->bevel = NULL;
62 /* You would return NULL here if the init failed. */
63 return TRUE;
66 /****************************************************************************************/
68 Object *makebevelobj(struct GadToolsBase_intern *GadToolsBase)
70 Object * obj;
71 struct TagItem tags[4];
73 tags[0].ti_Tag = IA_EdgesOnly;
74 tags[0].ti_Data = TRUE;
75 tags[1].ti_Tag = IA_Left;
76 tags[1].ti_Data = 0UL;
77 tags[2].ti_Tag = IA_Top;
78 tags[2].ti_Data = 0UL;
79 tags[3].ti_Tag = TAG_DONE;
80 obj = NewObjectA(NULL, FRAMEICLASS, tags);
82 return obj;
85 /****************************************************************************************/
87 static int Open(LIBBASETYPEPTR LIBBASE)
90 This function is single-threaded by exec by calling Forbid.
91 If you break the Forbid() another task may enter this function
92 at the same time. Take care.
95 if (!LIBBASE->bevel)
96 LIBBASE->bevel = (struct Image *)makebevelobj(GadToolsBase);
97 if (!LIBBASE->bevel)
98 return FALSE;
100 return TRUE;
103 /****************************************************************************************/
105 static int Expunge(LIBBASETYPEPTR LIBBASE)
108 This function is single-threaded by exec by calling Forbid.
109 If you break the Forbid() another task may enter this function
110 at the same time. Take care.
113 if (LIBBASE->bevel)
114 DisposeObject(LIBBASE->bevel);
115 LIBBASE->bevel = NULL;
117 closeall(LIBBASE);
119 return TRUE;
122 /****************************************************************************************/
124 DECLARESET(CLASSESINIT);
125 ADD2SET(InitRootClass, CLASSESINIT, -20);
127 ADD2INITLIB(Init, 0);
128 ADD2OPENLIB(Open, 0);
129 ADD2EXPUNGELIB(Expunge, 0);