Emilio Grimaldo wrote:
> When I have a pixmap button, I have the pixmaps have to reside
> in the same directory where the executable is found (due to
> the fl_set_pixmap_file(obj, PixmapFile), which is a bit
> unpractical as one usually executes the program without cd'ing
> to that directory. As a result empty pixmaps are shown in
> the application :-( Did I miss something? am I doing something
> wrong?
Well, you didn4t miss something. But this problem is a generell
one, not a special XForms one. I did the following to solve this
problem and make it portable to other directory structures at
distribution time.
(1) I defined a default XPM path, relative to the binaries location
(2) I created an environment variable MY_XPM_PATH which, if set,
is used instead of the builtin default
(3) I created an application parameter "-p path" which overwites
the two previous settings, if given.
-----------------
Some code follows
-----------------
...
#include <getopt.h>
#define XPMPATH_VAR "XPMPATH"
#define XPMPATH "./xpm"
main()
{
int c;
char xpmPath[NAME_MAX];
...
/* If 'XPMPATH_VAR' is set in the environment, get it! */
strcpy(xpmPath, getenv(XPMPATH_VAR)?getenv(XPMPATH_VAR):"");
...
while ( (c = getopt(argc, argv, "b:d:D:hp:s:")) != EOF ) {
switch (c) {
...
case 'p':
/* If pixmap path is given as an option, get it! */
strcpy(xpmPath, optarg);
break;
...
} /* switch */
} /* while */
...
/* If neither the environment variable 'XPMPATH_VAR' */
/* nor the option "-p xpmpath" was given, use the default */
if ( !(xpmPath[0] != '\0') ) {
strcpy(xpmPath, XPMPATH);
}
...
} /* main */
HTH,
Frank.
-- --------------------------------------------------------------- _/_/_/_/ _/_/ _/_/_/ EAD-Systeme GmbH _/ _/ _/ _/ _/ Nachfeldstr. 4 _/_/_/ _/ _/ _/ _/ D-82490 Farchant, Germany _/ _/_/_/_/_/ _/ _/ Phone: +49 8821 9623-0 _/_/_/_/ _/ _/ _/_/_/_/ Fax: +49 8821 9623-20 --------------------------------------------------------------- Email: EAD-Frank.Stefani@t-online.de ---------------------------------------------------------------_________________________________________________ To unsubscribe, send the message "unsubscribe" to xforms-request@bob.usuf2.usuhs.mil or see http://bob.usuf2.usuhs.mil/mailserv/xforms.html Xforms Home Page: http://bragg.phys.uwm.edu/xforms List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/