1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
/*
* images.c
*
* (c) 1998-2002 Alexey Vyskubov <alexey@mawhrin.net>
*/
#include <stdio.h> /* puts() */
#include <stdlib.h>
#include <string.h>
/* Xpm fun */
#include <X11/xpm.h>
#include "fookb.h"
#include "params.h"
#include "images.h"
/* Let us make lint happy! */
#define lputs(x) (void)(puts(x))
static int get_one_image(name, index)
char *name;
int index;
{
int foo;
foo = XpmReadFileToImage(dpy, name, &stupid_picture[index],
NULL, NULL);
return (foo);
}
void read_images()
{
int i;
int res;
int status = 0;
for (i = 0; i < 5; i++) {
switch (i) {
case 0:
res = get_one_image(read_param("Icon1"), 0);
break;
case 1:
res = get_one_image(read_param("Icon2"), 1);
break;
case 2:
res = get_one_image(read_param("Icon3"), 2);
break;
case 3:
res = get_one_image(read_param("Icon4"), 3);
break;
default:
res = get_one_image(read_param("IconBoom"), 4);
break;
}
switch (res) {
case XpmOpenFailed:
lputs("Xpm file open failed:");
status = 1 << 5;
break;
case XpmFileInvalid:
lputs("Xpm file is invalid:");
status = 1 << 6;
break;
case XpmNoMemory:
lputs("No memory for open xpm file:");
status = 1 << 7;
break;
default:
break;
}
if (!(status == 0)) {
status += 1 << i;
switch (i) {
case 0:
lputs(read_param("Icon1"));
break;
case 1:
lputs(read_param("Icon2"));
break;
case 2:
lputs(read_param("Icon3"));
break;
case 3:
lputs(read_param("Icon4"));
break;
case 4:
lputs(read_param("IconBoom"));
break;
default:
lputs("UNKNOWN ERROR! PLEASE REPORT!!!");
exit(-2);
}
exit(status);
}
}
}
void update_window(win, gc, whattodo)
Window win;
GC gc;
unsigned int whattodo;
{
int err;
err = XPutImage(dpy, win, gc, stupid_picture[whattodo],
0, 0, 0, 0, 48, 48);
if (0 == err) return;
switch (err) {
case BadDrawable:
lputs("Fatal error, XPutImage returns BadDrawable. "
"Please report!");
break;
case BadGC:
lputs("Fatal error, XPutImage returns BadGC. "
"Please report!");
break;
case BadMatch:
lputs("Fatal error, XPutImage returns BadMatch. "
"Please report!");
break;
case BadValue:
lputs("Fatal error, XPutImage returns BadValue. "
"Please report!");
break;
default:
lputs("Fatal error, XPutImage returns unknown error. "
"Please report, but probably "
"it is a bug in X.");
break;
}
}
|