9 #include "X11/Xlocale.h"
12 extern void W_InitNotificationCenter(void);
15 struct W_Application WMApplication
;
18 char *_WINGS_progname
= NULL
;
23 W_ApplicationInitialized(void)
25 return _WINGS_progname
!=NULL
;
30 WMInitializeApplication(char *applicationName
, int *argc
, char **argv
)
36 assert(applicationName
!=NULL
);
39 setlocale(LC_ALL
, "");
42 if (getenv("NLSPATH"))
43 bindtextdomain("WINGs", getenv("NLSPATH"));
45 bindtextdomain("WINGs", LOCALEDIR
);
48 _WINGS_progname
= argv
[0];
50 WMApplication
.applicationName
= wstrdup(applicationName
);
51 WMApplication
.argc
= *argc
;
53 WMApplication
.argv
= wmalloc((*argc
+1)*sizeof(char*));
54 for (i
=0; i
<*argc
; i
++) {
55 WMApplication
.argv
[i
] = wstrdup(argv
[i
]);
57 WMApplication
.argv
[i
] = NULL
;
59 /* initialize notification center */
60 W_InitNotificationCenter();
65 WMSetResourcePath(char *path
)
67 if (WMApplication
.resourcePath
)
68 wfree(WMApplication
.resourcePath
);
69 WMApplication
.resourcePath
= wstrdup(path
);
74 WMGetApplicationName()
76 return WMApplication
.applicationName
;
81 checkFile(char *path
, char *folder
, char *ext
, char *resource
)
86 extralen
= (ext
? strlen(ext
) : 0) + (folder
? strlen(folder
) : 0) + 4;
87 ret
= wmalloc(strlen(path
)+strlen(resource
)+extralen
+8);
98 strcat(ret
, resource
);
100 if (access(ret
, F_OK
)!=0) {
110 WMPathForResourceOfType(char *resource
, char *ext
)
117 * Paths are searched in this order:
120 * - GNUSTEP_USER_ROOT/Apps/ApplicationName.app/ext
121 * - ~/GNUstep/Apps/ApplicationName.app/ext
122 * - GNUSTEP_LOCAL_ROOT/Apps/ApplicationName.app/ext
123 * - /usr/local/GNUstep/Apps/ApplicationName.app/ext
124 * - GNUSTEP_SYSTEM_ROOT/Apps/ApplicationName.app/ext
125 * - /usr/GNUstep/Apps/ApplicationName.app/ext
128 if (WMApplication
.resourcePath
) {
129 path
= checkFile(WMApplication
.resourcePath
, NULL
, ext
, resource
);
134 if (WMApplication
.argv
[0]) {
135 tmp
= wstrdup(WMApplication
.argv
[0]);
137 while (i
> 0 && tmp
[i
]!='/')
141 path
= checkFile(tmp
, NULL
, ext
, resource
);
150 appdir
= wmalloc(strlen(WMApplication
.applicationName
)+10);
151 sprintf(appdir
, "Apps/%s.app", WMApplication
.applicationName
);
153 if (getenv("GNUSTEP_USER_ROOT")) {
154 path
= checkFile(getenv("GNUSTEP_USER_ROOT"), appdir
, ext
, resource
);
161 tmp
= wusergnusteppath();
163 path
= checkFile(tmp
, appdir
, ext
, resource
);
170 if (getenv("GNUSTEP_LOCAL_ROOT")) {
171 path
= checkFile(getenv("GNUSTEP_LOCAL_ROOT"), appdir
, ext
, resource
);
178 path
= checkFile("/usr/local/GNUstep", appdir
, ext
, resource
);
185 if (getenv("GNUSTEP_SYSTEM_ROOT")) {
186 path
= checkFile(getenv("GNUSTEP_SYSTEM_ROOT"), appdir
, ext
, resource
);
193 path
= checkFile("/usr/GNUstep", appdir
, ext
, resource
);