Pixmap FindBitmap(char *name, unsigned int *widthp, unsigned int *heightp) { char *bigname; Pixmap pm; if (!name) return None; /* * Generate a full pathname if any special prefix characters (such as ~) * are used. If the bigname is different from name, bigname will need to * be freed. */ bigname = ExpandFilename(name); if (!bigname) return None; /* * look along bitmapFilePath resource same as toolkit clients */ pm = XmuLocateBitmapFile(ScreenOfDisplay(dpy, Scr->screen), bigname, NULL, 0, (int *)widthp, (int *)heightp, &HotX, &HotY); if (pm == None && Scr->IconDirectory && bigname[0] != '/') { if (bigname != name) free(bigname); /* * Attempt to find icon in old IconDirectory (now obsolete) */ bigname = (char *)malloc(strlen(name) + strlen(Scr->IconDirectory) + 2); if (!bigname) { fprintf(stderr, "%s: unable to allocate memory for \"%s/%s\"\n", ProgramName, Scr->IconDirectory, name); return None; } (void)sprintf(bigname, "%s/%s", Scr->IconDirectory, name); if (XReadBitmapFile(dpy, Scr->Root, bigname, widthp, heightp, &pm, &HotX, &HotY) != BitmapSuccess) { pm = None; } } if (bigname != name) free(bigname); #ifdef DEBUG if (pm == None) { fprintf(stderr, "%s: unable to find bitmap \"%s\"\n", ProgramName, name); } #endif return pm; }
int do_string_keyword (int keyword, char *s) { switch (keyword) { case kws_UsePPosition: { int ppos = ParseUsePPosition (s); if (ppos < 0) { twmrc_error_prefix(); fprintf (stderr, "ignoring invalid UsePPosition argument \"%s\"\n", s); } else { Scr->UsePPosition = ppos; } return 1; } case kws_IconFont: if (!Scr->HaveFonts) Scr->IconFont.name = s; return 1; case kws_ResizeFont: if (!Scr->HaveFonts) Scr->SizeFont.name = s; return 1; case kws_MenuFont: if (!Scr->HaveFonts) Scr->MenuFont.name = s; return 1; case kws_TitleFont: if (!Scr->HaveFonts) Scr->TitleBarFont.name = s; return 1; case kws_IconManagerFont: if (!Scr->HaveFonts) Scr->IconManagerFont.name = s; return 1; case kws_UnknownIcon: if (Scr->FirstTime) GetUnknownIcon (s); return 1; case kws_IconDirectory: if (Scr->FirstTime) Scr->IconDirectory = ExpandFilename (s); return 1; case kws_MaxWindowSize: JunkMask = XParseGeometry (s, &JunkX, &JunkY, &JunkWidth, &JunkHeight); if ((JunkMask & (WidthValue | HeightValue)) != (WidthValue | HeightValue)) { twmrc_error_prefix(); fprintf (stderr, "bad MaxWindowSize \"%s\"\n", s); return 0; } if (JunkWidth <= 0 || JunkHeight <= 0) { twmrc_error_prefix(); fprintf (stderr, "MaxWindowSize \"%s\" must be positive\n", s); return 0; } Scr->MaxWindowWidth = JunkWidth; Scr->MaxWindowHeight = JunkHeight; return 1; } return 0; }
Image * FindImage(char *name, Pixel color) { char *bigname; Image *newimage; /* * Generate a full pathname if any special prefix characters (such as ~) * are used. If the bigname is different from name, bigname will need to * be freed. */ bigname = ExpandFilename(name); if (!bigname) return NULL; newimage = (Image *) calloc(1, sizeof(Image)); if (newimage == NULL) return NULL; else { newimage->pixmap = None; newimage->mask = None; newimage->type = IMAGE_TYPE_NONE; } LoadImage(bigname, newimage, color); /* * Do for pixmaps what XmuLocateBitmapFile() does for bitmaps, * because, apparently, XmuLocatePixmapFile() doesn't! */ /* This iterates through the bitmap search path */ if ((newimage->type == IMAGE_TYPE_NONE) && Scr->BitmapFilePath && (bigname[0] != '/')) { char *path = Scr->BitmapFilePath, *term; while (path && (newimage->type == IMAGE_TYPE_NONE)) { if ((term = strchr(path, ':'))) *term = 0; if (bigname != name) free(bigname); if (!(bigname = (char *)malloc(strlen(name) + strlen(path) + 2))) fprintf(stderr, "%s: unable to allocate memory for \"%s/%s\"\n", ProgramName, path, name); else { (void)sprintf(bigname, "%s/%s", path, name); LoadImage(bigname, newimage, color); } if (term) { *term = ':'; path = term + 1; } else path = NULL; } } if ((newimage->type == IMAGE_TYPE_NONE) && Scr->IconDirectory && bigname[0] != '/') { if (bigname != name) free(bigname); /* * Attempt to find icon pixmap in old IconDirectory (now obsolete) */ bigname = (char *)malloc(strlen(name) + strlen(Scr->IconDirectory) + 2); if (!bigname) { fprintf(stderr, "%s: unable to allocate memory for \"%s/%s\"\n", ProgramName, Scr->IconDirectory, name); return None; } (void)sprintf(bigname, "%s/%s", Scr->IconDirectory, name); LoadImage(bigname, newimage, color); } if (newimage->type != IMAGE_TYPE_NONE) { } else { fprintf(stderr, "%s: unable to find image \"%s\"\n", ProgramName, name); free(newimage); newimage = NULL; } if (bigname != name) free(bigname); return newimage; }