XmGetPixmap - Motif

This is a discussion on XmGetPixmap - Motif ; Hello, the following piece of code: static void addButton( const char *i_pixmapFile, const char *commandLine ) { char className[1024]; char pathName[1024]; char *l_pixmapFile = strdup( i_pixmapFile ); sprintf( className, "button.%d", (int)numButtons ); if( *commandLine == '/' ) strcpy( pathName, commandLine ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: XmGetPixmap

  1. XmGetPixmap

    Hello,

    the following piece of code:

    static void addButton(
    const char *i_pixmapFile, const char *commandLine
    )
    {
    char className[1024];
    char pathName[1024];
    char *l_pixmapFile = strdup( i_pixmapFile );

    sprintf( className, "button.%d", (int)numButtons );
    if( *commandLine == '/' )
    strcpy( pathName, commandLine );
    else
    sprintf( pathName, "%s/%s", "/usr/bin", commandLine );

    theButtons[numButtons].pixmap = XmGetPixmap(
    XtScreen(topLevel),
    l_pixmapFile,
    BlackPixelOfScreen(XtScreen(topLevel)),
    WhitePixelOfScreen(XtScreen(topLevel))
    );
    free( l_pixmapFile );
    if( theButtons[numButtons].pixmap == XmUNSPECIFIED_PIXMAP )
    fprintf( stderr, "Cannot load %s\n", i_pixmapFile );
    else
    {
    theButtons[numButtons].commandLine = strdup( pathName );
    theButtons[numButtons].button = XtVaCreateManagedWidget(
    className,
    xmPushButtonWidgetClass,
    toolbar,
    XmNlabelType, XmPIXMAP,
    XmNlabelPixmap, theButtons[numButtons].pixmap,
    NULL
    );
    XtAddCallback(
    theButtons[numButtons].button,
    XmNactivateCallback,
    execCommand, (XtPointer)numButtons
    );

    numButtons++;
    }
    }


    works fine when I compile and run the program with Kubuntu 6.06 LTS (32
    Bit). The same executable copied to my 64 Bit Open Suse 10.1 machine
    does not work because XmGetPixmap returns XmUNSPECIFIED_PIXMAP. Even
    recompiling the program on my OpenSuse machine did not help.

    Of course: I _DID_ check whether the pixmap file exists on the second
    machine and I have read permissions.

    Any ideas?

    Thanks in Advance

    Martin

    --
    Firma/Company: CRESD GmbH
    Phone: +49-89-65 30 95 63 Fax: +49-89-65 30 95 64
    WWW: http://www.cresd.de
    S-Mail: Freibadstr. 14, D-81543 München
    PGP-Key: http://www.cresd.de/edv/pgpkey.txt
    Open BC (Einladung) http://www.openbc.com/go/invita/4561755

  2. Re: XmGetPixmap


    "Martin Gäckler" wrote in message
    news:ejintp$vc8$1@online.de...
    > Hello,
    >
    > the following piece of code:
    >
    > static void addButton(
    > const char *i_pixmapFile, const char *commandLine
    > )
    > {
    > char className[1024];
    > char pathName[1024];
    > char *l_pixmapFile = strdup( i_pixmapFile );
    >
    > sprintf( className, "button.%d", (int)numButtons );
    > if( *commandLine == '/' )
    > strcpy( pathName, commandLine );
    > else
    > sprintf( pathName, "%s/%s", "/usr/bin", commandLine );
    >
    > theButtons[numButtons].pixmap = XmGetPixmap(
    > XtScreen(topLevel),
    > l_pixmapFile,
    > BlackPixelOfScreen(XtScreen(topLevel)),
    > WhitePixelOfScreen(XtScreen(topLevel))
    > );
    > free( l_pixmapFile );
    > if( theButtons[numButtons].pixmap == XmUNSPECIFIED_PIXMAP )
    > fprintf( stderr, "Cannot load %s\n", i_pixmapFile );
    > else
    > {
    > theButtons[numButtons].commandLine = strdup( pathName );
    > theButtons[numButtons].button = XtVaCreateManagedWidget(
    > className,
    > xmPushButtonWidgetClass,
    > toolbar,
    > XmNlabelType, XmPIXMAP,
    > XmNlabelPixmap, theButtons[numButtons].pixmap,
    > NULL
    > );
    > XtAddCallback(
    > theButtons[numButtons].button,
    > XmNactivateCallback,
    > execCommand, (XtPointer)numButtons
    > );
    >
    > numButtons++;
    > }
    > }
    >
    >
    > works fine when I compile and run the program with Kubuntu 6.06 LTS (32
    > Bit). The same executable copied to my 64 Bit Open Suse 10.1 machine does
    > not work because XmGetPixmap returns XmUNSPECIFIED_PIXMAP. Even
    > recompiling the program on my OpenSuse machine did not help.
    >
    > Of course: I _DID_ check whether the pixmap file exists on the second
    > machine and I have read permissions.
    >
    > Any ideas?
    >
    > Thanks in Advance
    >
    > Martin
    >
    > --
    > Firma/Company: CRESD GmbH
    > Phone: +49-89-65 30 95 63 Fax: +49-89-65 30 95 64
    > WWW: http://www.cresd.de
    > S-Mail: Freibadstr. 14, D-81543 München
    > PGP-Key: http://www.cresd.de/edv/pgpkey.txt
    > Open BC (Einladung) http://www.openbc.com/go/invita/4561755


    Have you printed out the name of the file as passed into the function,
    to ensure it is what you think it is?

    Is the file name an absolute pathname (starst with "/")?
    If not, XmGetPixmap goes through a lot of hoops trying to find
    the file, based on the XBMLANGPATH environment variable
    (for Motif 1.2), or the XMICONSEARCHPATH,
    XMICONBSEARCHPATH, XAPPLRESDIR, and HOME
    environment variables. Are you sure these variables are the same on
    both platforms, and the file is in the same place?

    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Software Reuse Project



  3. Re: XmGetPixmap

    Hello,

    thanks for your mail.

    Fred Kleinschmidt schrieb:
    > Have you printed out the name of the file as passed into the function,
    > to ensure it is what you think it is?

    Yes, this is the source:

    theButtons[numButtons].pixmap = XmGetPixmap(
    XtScreen(topLevel),
    l_pixmapFile,
    BlackPixelOfScreen(XtScreen(topLevel)),
    WhitePixelOfScreen(XtScreen(topLevel))
    );
    if( theButtons[numButtons].pixmap == XmUNSPECIFIED_PIXMAP )
    fprintf( stderr, "Cannot load %s\n", l_pixmapFile );

    This is the output:

    Cannot load /opt/seamonkey/chrome/icons/default/default.xpm

    > Is the file name an absolute pathname (starst with "/")?


    Yes, see above.

    > If not, XmGetPixmap goes through a lot of hoops trying to find
    > the file, based on the XBMLANGPATH environment variable
    > (for Motif 1.2), or the XMICONSEARCHPATH,
    > XMICONBSEARCHPATH, XAPPLRESDIR, and HOME
    > environment variables.


    I know this.

    > Are you sure these variables are the same on
    > both platforms, and the file is in the same place?
    >


    No, I'm not sure, but I don't need them. But, I know, that the file
    exists. I have copied the filename from the error message to konqueror
    on the same machine to check, whether the file exists and I have read
    permissions.

    Martin

    --
    Firma/Company: CRESD GmbH
    Phone: +49-89-65 30 95 63 Fax: +49-89-65 30 95 64
    WWW: http://www.cresd.de
    S-Mail: Freibadstr. 14, D-81543 München
    PGP-Key: http://www.cresd.de/edv/pgpkey.txt
    Open BC (Einladung) http://www.openbc.com/go/invita/4561755

+ Reply to Thread