Exemple #1
0
int
mvpw_set_screensaver(mvp_widget_t *widget, int seconds,
	void (*callback)(mvp_widget_t*, int))
{
	if (widget) {
		GrSetScreenSaverTimeout(seconds);
	} else {
		GrSetScreenSaverTimeout(0);
	}

	screensaver_widget = widget;
	screensaver_callback = callback;

	return 0;
}
Exemple #2
0
static void
GrSetScreenSaverTimeoutWrapper(void *r)
{
	nxSetScreenSaverTimeoutReq *req = r;

	GrSetScreenSaverTimeout(req->timeout);
}
Exemple #3
0
void parse_config_line(lstate *state, char *buf, int lineno)
{
	char *p, *pp, *name, *icon;
	int n;
	litem *new_litem, *li;
	ssitem *new_ssitem, *tmp_ssitem;
	stitem *new_stitem, *tmp_stitem;
	GR_IMAGE_INFO imageinfo;

	p = buf;

	if((!*p) || (*p == '#') || (*p == '\n')) return;

	while(isspace(*p)) p++;
	name = p;
	while(*p && (!isspace(*p))) p++;
	if(!*p) goto premature;
	*p++ = 0;

	if(!strcmp(name, "$screensaver")) {
		new_ssitem = my_malloc(sizeof(ssitem));
		if(!(new_ssitem->prog = make_prog_item(p, lineno))) {
			free(new_ssitem);
			return;
		}
		state->numssitems++;
		new_ssitem->next = NULL;
		if(!state->ssitems) state->ssitems = new_ssitem;
		else {
			tmp_ssitem = state->ssitems;
			while(tmp_ssitem->next) tmp_ssitem = tmp_ssitem->next;
			tmp_ssitem->next = new_ssitem;
		}
		return;
	} else if(!strcmp(name, "$startup")) {
		new_stitem = my_malloc(sizeof(stitem));
		if(!(new_stitem->prog = make_prog_item(p, lineno))) {
			free(new_stitem);
			return;
		}
		new_stitem->next = NULL;
		if(!state->stitems) state->stitems = new_stitem;
		else {
			tmp_stitem = state->stitems;
			while(tmp_stitem->next) tmp_stitem = tmp_stitem->next;
			tmp_stitem->next = new_stitem;
		}
		return;
	} else if(!strcmp(name, "$screensaver_timeout")) {
		n = strtol(p, NULL, 10);
		GrSetScreenSaverTimeout(n);
		return;
	} else if(!strcmp(name, "$screensaver_rotate_time")) {
		state->rotatess = strtol(p, NULL, 10);
		return;
	} else if(!strcmp(name, "$random_screensaver")) {
		srand(time(0));
		state->randomss = 1;
		return;
	} else if(!strcmp(name, "$window_background_image")) {
		while(isspace(*p)) p++;
		if(!*p) goto premature;
		pp = p;
		while(*p && (!isspace(*p))) p++;
		*p = 0;
		state->window_background_image = strdup(pp);
		return;
	} else if(!strcmp(name, "$window_background_mode")) {
		state->window_background_mode = (int) strtol(p, NULL, 10);
		return;
	} else if(!strcmp(name, "$window_background_colour")) {
		set_window_background_colour(p, lineno);
		return;
	}

	while(isspace(*p)) p++;
	if(!*p) goto premature;
	icon = p;
	while(*p && (!isspace(*p))) p++;
	if(!*p) goto premature;
	*p++ = 0;

	new_litem = my_malloc(sizeof(litem));
	if(!(new_litem->name = strdup(name))) {
		free(new_litem);
		goto nomem;
	}
	if(!(new_litem->icon = strdup(icon))) {
		free(new_litem->name);
		free(new_litem);
		goto nomem;
	}
	if(!(new_litem->prog = make_prog_item(p, lineno))) {
		free(new_litem->name);
		free(new_litem->icon);
		free(new_litem);
		return;
	}
	new_litem->iconid = 0;
	if(strcmp("-", icon)) {
		li = state->litems;
		while(li) {
			if(!(strcmp(icon, li->name))) {
				new_litem->iconid = li->iconid;
				break;
			}
			li = li->next;
		}
		if(!new_litem->iconid) {
			if(!(new_litem->iconid = GrLoadImageFromFile(icon, 0))){
				GrError("Couldn't load icon \"%s\"\n",
									icon);
			} else {
				GrGetImageInfo(new_litem->iconid, &imageinfo);
				if((imageinfo.width != ICON_WIDTH) ||
					(imageinfo.height != ICON_HEIGHT)) {
					GrError("Icon \"%s\" is the "
					"wrong size (%dx%d instead of %dx%d)"
					"\n", icon, imageinfo.width,
					imageinfo.height, ICON_WIDTH,
					ICON_HEIGHT);
					GrFreeImage(new_litem->iconid);
					new_litem->iconid = 0;
				}
			}
		}
	}

	new_litem->prev = NULL;
	new_litem->next = NULL;
	if(!state->litems) {
		state->lastlitem = new_litem;
		state->litems = new_litem;
	} else {
		new_litem->next = state->litems;
		state->litems->prev = new_litem;
		state->litems = new_litem;
	}

	state->numlitems++;

	return;

nomem:
	GrError("Out of memory\n");
	exit(1);

premature:
	GrError("Premature end of line on line %d of config file\n",
								lineno);
}