8 extern void W_InitNotificationCenter(void);
11 struct W_Application WMApplication
;
14 char *_WINGS_progname
= NULL
;
19 W_ApplicationInitialized(void)
21 return _WINGS_progname
!=NULL
;
26 WMInitializeApplication(char *applicationName
, int *argc
, char **argv
)
32 assert(applicationName
!=NULL
);
34 _WINGS_progname
= argv
[0];
36 WMApplication
.applicationName
= wstrdup(applicationName
);
37 WMApplication
.argc
= *argc
;
39 WMApplication
.argv
= wmalloc((*argc
+1)*sizeof(char*));
40 for (i
=0; i
<*argc
; i
++) {
41 WMApplication
.argv
[i
] = wstrdup(argv
[i
]);
43 WMApplication
.argv
[i
] = NULL
;
45 /* initialize notification center */
46 W_InitNotificationCenter();
51 WMSetResourcePath(char *path
)
53 if (WMApplication
.resourcePath
)
54 wfree(WMApplication
.resourcePath
);
55 WMApplication
.resourcePath
= wstrdup(path
);
60 WMGetApplicationName()
62 return WMApplication
.applicationName
;
67 checkFile(char *path
, char *folder
, char *ext
, char *resource
)
72 extralen
= (ext
? strlen(ext
) : 0) + (folder
? strlen(folder
) : 0) + 4;
73 ret
= wmalloc(strlen(path
)+strlen(resource
)+extralen
+8);
84 strcat(ret
, resource
);
86 if (access(ret
, F_OK
)!=0) {
96 WMPathForResourceOfType(char *resource
, char *ext
)
103 * Paths are searched in this order:
106 * - GNUSTEP_USER_ROOT/Apps/ApplicationName.app/ext
107 * - ~/GNUstep/Apps/ApplicationName.app/ext
108 * - GNUSTEP_LOCAL_ROOT/Apps/ApplicationName.app/ext
109 * - /usr/local/GNUstep/Apps/ApplicationName.app/ext
110 * - GNUSTEP_SYSTEM_ROOT/Apps/ApplicationName.app/ext
111 * - /usr/GNUstep/Apps/ApplicationName.app/ext
114 if (WMApplication
.resourcePath
) {
115 path
= checkFile(WMApplication
.resourcePath
, NULL
, ext
, resource
);
120 if (WMApplication
.argv
[0]) {
121 tmp
= wstrdup(WMApplication
.argv
[0]);
123 while (i
> 0 && tmp
[i
]!='/')
127 path
= checkFile(tmp
, NULL
, ext
, resource
);
136 appdir
= wmalloc(strlen(WMApplication
.applicationName
)+10);
137 sprintf(appdir
, "Apps/%s.app", WMApplication
.applicationName
);
139 if (getenv("GNUSTEP_USER_ROOT")) {
140 path
= checkFile(getenv("GNUSTEP_USER_ROOT"), appdir
, ext
, resource
);
147 tmp
= wusergnusteppath();
149 path
= checkFile(tmp
, appdir
, ext
, resource
);
156 if (getenv("GNUSTEP_LOCAL_ROOT")) {
157 path
= checkFile(getenv("GNUSTEP_LOCAL_ROOT"), appdir
, ext
, resource
);
164 path
= checkFile("/usr/local/GNUstep", appdir
, ext
, resource
);
171 if (getenv("GNUSTEP_SYSTEM_ROOT")) {
172 path
= checkFile(getenv("GNUSTEP_SYSTEM_ROOT"), appdir
, ext
, resource
);
179 path
= checkFile("/usr/GNUstep", appdir
, ext
, resource
);