#include "src/rplexternals.h" #include "motif.h" declareExternalFunction(XmSetIcon) declareObject(filename); declareObject(widget); Pixmap icon; string name; HEADER declareHelpString("Set application icon\n" " 2: widget shell\n" " 1: filename\n"); numberOfArguments(2); FUNCTION if (initializationDone eq true) then pullFromStack(filename, string); returnOnError(freeObject(filename)); pullFromStack(widget, external); returnOnError(freeObject(filename); freeObject(widget)); ifIsExternal(widget, WIDGET) then orElse executionError("Type mismath error"); returnOnError(freeObject(filename); freeObject(widget)); endIf getString(filename, name); select(XpmReadFileToPixmap( XtDisplay(target(objectContainer(Widget, widget))), XtWindow(target(objectContainer(Widget, widget))), name, &icon, NULL, NULL)) exclusiveCase(XpmOpenFailed) executionError("XpmOpenFailed"); endExclusiveCase exclusiveCase(XpmFileInvalid) executionError("XpmOpenFailed"); endExclusiveCase exclusiveCase(XpmNoMemory) systemError("XpmNoMemory"); endExclusiveCase endSelect returnOnError(freeObject(filename); freeObject(widget)); XtVaSetValues(target(objectContainer(Widget, widget)), XmNiconPixmap, icon, NULL); /* Icon is not copied, thus we haven't to free pixmap. XFreePixmap(XtDisplay(target(objectContainer(Widget, widget))), icon); */ freeObject(widget); freeObject(filename); orElse executionError("Application not initialized"); returnOnError(); endIf END endExternalFunction // vim: ts=4