Beispiel #1
0
int s_dir_file (char *path, s_dir_t *dir)
{
        s_dir_t *s_dir;
        s_file_t *s_file;
	struct stat stbuf;

	if (stat(path, &stbuf)) {
		printf("Cannot access %s\n", path);
		goto err;
	}
	if (S_ISDIR(stbuf.st_mode & S_IFMT)) {
		s_dir_init(&s_dir);
		s_dir->path = strdup(path);
		s_dir_path2dir_name(path, &s_dir->base, &s_dir->name);
		s_dir->up = dir;
		s_list_add(dir->dirs, s_dir, -1);
		s_dir_walk(path, s_dir);
	}
	if (S_ISREG(stbuf.st_mode & S_IFMT)) {
		s_file_init(&s_file);
		s_file->path = strdup(path);
		s_dir_path2dir_name(path, &s_file->base, &s_file->name);
		s_list_add(dir->files, s_file, -1);
	}
	
	return 0;

err:	return -1;
}
Beispiel #2
0
int w_frame_set_image (w_object_t *object, unsigned int style, unsigned int rotation, unsigned int nimgs, char **imgs)
{
	int pos;
	char *file;
        w_frame_t *frame;
	w_frame_image_t *fimg;
        frame = (w_frame_t *) object->data[OBJECT_FRAME];
	for (pos = 0; !s_list_eol(frame->images, pos); pos++) {
		fimg = (w_frame_image_t *) s_list_get(frame->images, pos);
		if (fimg->style == style) {
			s_list_remove(frame->images, pos);
			w_frame_image_uninit(fimg);
			break;
		}
	}
	for (pos = 0; pos < nimgs; pos++) {
		if (access(imgs[pos], R_OK)) {
			return -1;
		}
	}
	w_frame_image_init(&fimg);
	fimg->style = style;
	fimg->rotation = rotation;
	for (pos = 0; pos < nimgs; pos++) {
		file = imgs[pos];
#if defined(WIDGET_OPTIMIZE_MEMORY) && WIDGET_OPTIMIZE_MEMORY >= 1
#else
		w_window_image_add(object->window, file);
#endif
		s_list_add(fimg->names, strdup(file), -1);
	}
	s_list_add(frame->images, fimg, -1);
	return 0;
}
Beispiel #3
0
int s_pollfd_add (s_window_t *window, s_pollfd_t *pfd)
{
	int ret = 0;
	s_thread_mutex_lock(window->pollfds->mut);
	if (s_list_get_pos(window->pollfds->list, pfd) < 0) {
#if 1
		ret = s_list_add(window->pollfds->list, pfd, -1);
#else
		ret = s_list_add(window->pollfds->list, pfd, 2);
#endif
	}
	s_thread_mutex_unlock(window->pollfds->mut);
	s_window_wakeup(window);
	return ret;
}
Beispiel #4
0
static void lxynth_atevent (s_window_t *window, s_event_t *event)
{
        s_event_t *e;

        if (lxynth_root == NULL) {
		return;
	}
	switch (event->type & EVENT_MASK) {
		case QUIT_EVENT:
		case MOUSE_EVENT:
		case KEYBD_EVENT:
		case EXPOSE_EVENT:
		case CONFIG_EVENT:
		case FOCUS_EVENT:
			if (!s_event_init(&e)) {
				e->type = event->type;
				memcpy(e->mouse, event->mouse, sizeof(s_mouse_t));
				memcpy(e->keybd, event->keybd, sizeof(s_keybd_t));
				memcpy(e->expose->rect, event->expose->rect, sizeof(s_rect_t));
				s_thread_mutex_lock(lxynth_root->eventq->mut);
				s_list_add(lxynth_root->eventq->list, e, -1);
				s_thread_mutex_unlock(lxynth_root->eventq->mut);
			}
			break;
		default:
			break;
	}
}
Beispiel #5
0
void taskbar_atevent (s_window_t *window, s_event_t *event)
{
        int pos = 0;
        tbar_data_t *tbar_data;
        tbar_progs_t *tbar_progs;
        s_desktop_client_t *desktopc;
	
	if (event->type & EVENT_TYPE_MOUSE_EXIT) {
	}

	if (!(event->type & EVENT_TYPE_DESKTOP)) {
		return;
	}

        tbar_data = (tbar_data_t *) window->data;
        tbar_progs = (tbar_progs_t *) tbar_data->tbar_progs;

	while (!s_list_eol(tbar_progs->desktop->clients, 0)) {
		desktopc = (s_desktop_client_t *) s_list_get(tbar_progs->desktop->clients, 0);
		s_list_remove(tbar_progs->desktop->clients, 0);
		s_free(desktopc->title);
		s_free(desktopc);
	}
	while (!s_list_eol(event->desktop->clients, pos)) {
		desktopc = (s_desktop_client_t *) s_list_get(event->desktop->clients, pos);
		if ((desktopc->id != window->id) &&
		    (desktopc->id != window->parent->id)) {
			s_list_remove(event->desktop->clients, pos);
			s_list_add(tbar_progs->desktop->clients, desktopc, -1);
		} else {
			pos++;
		}
	}
	taskbar_progs_draw(window);
}
Beispiel #6
0
int w_clistbox_set_itemimage (w_object_t *object, unsigned int style, unsigned int rotation, unsigned int nimgs, char **imgs)
{
	w_clistbox_t *lb;
	w_clistbox_item_image_t *ii;
	lb = object->data[OBJECT_CLISTBOX];
	w_clistbox_item_image_init(&ii, style, rotation, nimgs, imgs);
	s_list_add(lb->item_images, ii, -1);
	return 0;
}
Beispiel #7
0
int s_handler_add (s_window_t *window, s_handler_t *handler)
{
	int ret = 0;
	s_thread_mutex_lock(window->handlers->mut);
	if (s_list_get_pos(window->handlers->list, handler) < 0) {
		ret = s_list_add(window->handlers->list, handler, -1);
	}
	s_thread_mutex_unlock(window->handlers->mut);
	return ret;
}
Beispiel #8
0
int s_eventq_add (s_window_t *window, s_event_t *event)
{
        int ret;
	s_thread_mutex_lock(window->eventq->mut);
	event->window = window;
	ret = s_list_add(window->eventq->queue, event, -1);
	s_thread_cond_signal(window->eventq->cond);
	s_thread_mutex_unlock(window->eventq->mut);
	return ret;
}
Beispiel #9
0
int s_dir_sort (s_dir_t *dir)
{
	int i;
	int j;

        s_dir_t *d;
	s_dir_t *di;
	s_dir_t *dj;

	s_file_t *fi;
	s_file_t *fj;

	for (i = 0; i < dir->dirs->nb_elt - 1; i++) {
		for (j = 0; j < dir->dirs->nb_elt - 1; j++) {
			di = (s_dir_t *) s_list_get(dir->dirs, j);
			dj = (s_dir_t *) s_list_get(dir->dirs, j + 1);
			if (strcmp(dj->path, di->path) < 0) {
				s_list_remove(dir->dirs, j);
				s_list_add(dir->dirs, di, j + 1);
			}
		}
	}

	for (i = 0; i < dir->files->nb_elt - 1; i++) {
		for (j = 0; j < dir->files->nb_elt - 1; j++) {
			fi = (s_file_t *) s_list_get(dir->files, j);
			fj = (s_file_t *) s_list_get(dir->files, j + 1);
			if (strcmp(fj->path, fi->path) < 0) {
				s_list_remove(dir->files, j);
				s_list_add(dir->files, fi, j + 1);
			}
		}
	}

	i = 0;
	while (!s_list_eol(dir->dirs, i)) {
		d = (s_dir_t *) s_list_get(dir->dirs, i);
		s_dir_sort(d);
		i++;
	}

	return 0;
}
Beispiel #10
0
int w_clistbox_item_add (w_object_t *object, w_clistbox_item_t *item)
{
	w_clistbox_t *lb;
	w_clistbox_item_t *active;
	lb = object->data[OBJECT_CLISTBOX];
	active = s_list_get(lb->items, lb->active);
	s_list_add(lb->items, item, -1);
	if (active == NULL) {
		lb->active = 0;
	} else {
		lb->active = s_list_get_pos(lb->items, active);
	}
//	w_object_draw(object);
	return 0;
}
Beispiel #11
0
void code_parse_element (s_xml_node_t *node, s_xml_node_t *style)
{
	int p;
	s_xml_node_t *tmp;
	s_xml_node_t *dmp;
	s_xml_node_t *chl;
	s_xml_node_attr_t *sid;
	s_xml_node_attr_t *stype;
	s_xml_node_attr_t *ntype;
	if (style == NULL) {
		return;
	}
	for (p = 0; !s_list_eol(node->nodes, p); p++) {
    		tmp = (s_xml_node_t *) s_list_get(node->nodes, p);
    		code_parse_element(tmp, style);
	}
	ntype = s_xml_node_get_attr(node, "type");
	if (strcmp(node->name, "element") == 0 && ntype && ntype->value != NULL) {
	    	for (p = 0; !s_list_eol(style->nodes, p); p++) {
	    		tmp = (s_xml_node_t *) s_list_get(style->nodes, p);
	    		sid = s_xml_node_get_attr(tmp, "id");
	    		stype = s_xml_node_get_attr(tmp, "type");
	    		if (strcmp(tmp->name, "element") == 0 && sid && strcmp(sid->value, ntype->value) == 0) {
	    		    	s_xml_node_dublicate(tmp, &dmp);
	    		    	s_free(node->name);
	    		    	s_free(ntype->value);
	    		    	node->name = strdup("object");
	    		    	ntype->value = (stype->value) ? strdup(stype->value) : NULL;
	    		    	while (!s_list_eol(dmp->nodes, 0)) {
	    		    		chl = (s_xml_node_t *) s_list_get(dmp->nodes, dmp->nodes->nb_elt - 1);
	    		    		chl->parent = node;
	    		    		s_list_add(node->nodes, chl, 0);
	    		    		s_list_remove(dmp->nodes, dmp->nodes->nb_elt - 1);
	    		    	}
	    		    	s_xml_node_uninit(dmp);
	    		}
	    	}
	}
}
Beispiel #12
0
static struct graphics_device * lxynth_init_device (void)
{
	lxynth_device_t *wd;
	struct graphics_device *gd;

	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);

	wd = (lxynth_device_t *) s_malloc(sizeof(lxynth_device_t));
	wd->update = (s_rect_t) {-1, -1, -1, -1};
	gd = (struct graphics_device *) s_malloc(sizeof(struct graphics_device));

	wd->title = NULL;
	if (s_surface_create(&wd->surface, lxynth_root->window->surface->buf->w , lxynth_root->window->surface->buf->h, lxynth_root->window->surface->bitsperpixel)) {
		s_free(gd);
		s_free(wd);
		return NULL;
	}

	gd->size.x1 = 0;
	gd->size.x2 = wd->surface->width;
	gd->size.y1 = 0;
	gd->size.y2 = wd->surface->height;
	gd->clip.x1 = 0;
	gd->clip.x2 = gd->size.x2;
	gd->clip.y1 = 0;
	gd->clip.y2 = gd->size.y2;

	gd->drv = &xynth_driver;
	gd->driver_data = wd;
	gd->user_data = NULL;

	s_thread_mutex_lock(lxynth_root->gd->mut);
	s_list_add(lxynth_root->gd->list, gd, -1);
	lxynth_root->gd->active = gd;
	s_thread_mutex_unlock(lxynth_root->gd->mut);

	return gd;
}
Beispiel #13
0
void start_menu_setup (s_window_t *twindow, s_config_t *cfg)
{
	int i;
	int j;
	char *str;
	char *ptr;
	char *tmp;
	s_config_cat_t *cat;
	s_config_var_t *var;
	smenu_prog_t *sprog;
        tbar_data_t *tbar_data;

        tbar_data = (tbar_data_t *) twindow->data;

	i = 0;
	while (!s_list_eol(cfg->category, i)) {
		cat = (s_config_cat_t *) s_list_get(cfg->category, i++);
		if (strcmp(cat->name, "taskbar_prog") == 0) {
			j = 0;
			while (!s_list_eol(cat->variable, j)) {
				sprog = (smenu_prog_t *) s_calloc(1, sizeof(smenu_prog_t));
				s_list_init(&(sprog->progs));

				var = (s_config_var_t *) s_list_get(cat->variable, j++);

				sprog->name = strdup(var->name);
				tmp = strdup(var->value);
				str = tmp;
				ptr = strchr(str, '|');
				*ptr = '\0';
				sprog->icon = strdup(str);
				str = ptr + 1;
				ptr = strchr(str, '|');
				*ptr = '\0';
				sprog->exec = strdup(str);
				str = ptr + 1;
				sprog->menu = strdup(str);
				s_free(tmp);

				if ((sprog->name != NULL) && (*(sprog->name) != '\0')) {
					if ((sprog->exec != NULL) && (*(sprog->exec) != '\0')) {
						sprog->type = SMENU_PROG;
					} else {
						sprog->type = SMENU_MENU;
					}
					if ((sprog->menu != NULL) && (*(sprog->menu) != '\0')) {
						smenu_prog_t *sp;
						if ((sp = start_menu_list_find_menu(sprog, tbar_data->tbar_smenu->progs)) != NULL) {
							s_list_add(sp->progs, sprog, -1);
						} else {
							goto add_top;
						}
					} else {
add_top:					s_list_add(tbar_data->tbar_smenu->progs, sprog, -1);
					}
				} else {
					s_free(sprog->name);
					s_free(sprog->icon);
					s_free(sprog->exec);
					s_free(sprog->menu);
					s_free(sprog->progs);
					s_free(sprog);
				}
			}
		}
	}
}
Beispiel #14
0
int s_config_parse (s_config_t *cfg, char *name)
{
        FILE *fp;
        char *buf;
        s_config_cat_t *category;
        s_config_var_t *variable;

	buf = (char *) s_malloc(sizeof(char) * (8192 + 1));
	
        fp = fopen(name, "r");
        if (fp == NULL) {
		debugf(DSYS, "Unable to open file : %s", name);
		goto err0;
	}

	while (!feof(fp)) {
		if (fgets(buf, 8192, fp)) {
			char *c;
			char *cur;

			/* strip comments */
			c = strchr(buf, ';');
			while (c) {
				if ((c == buf) || (*(c - 1) != '\\')) {
					*c = '\0';
				} else {
					*(c - 1) = ';';
					memmove(c, c + 1, strlen(c + 1));
				}
				c = strchr(c + 1, ';');
			}

			cur = s_config_strip(buf);
			if (*buf != '\0') {
				if (cur[0] == '[') {
					/* A category header */
					c = strchr(cur, ']');
					if (c) {
						*c = 0;
						if (!s_config_category_init(&category, cur + 1)) {
							s_list_add(cfg->category, category, -1);
						}
					} else {
						debugf(0, "parse error: no closing ']' for category %s of %s", cur + 1, name);
						goto err1;
					}
				} else if (cur[0] == '#') {
					/* A directive */
				} else {
					/* variable = value */
					category = (s_config_cat_t *) s_list_get(cfg->category, cfg->category->nb_elt - 1);
					if (category == NULL) {
						debugf(0, "parse error: There is no category context for %s", name);
						goto err1;
					}
					c = strchr(cur, '=');
					if (c) {
						*c = 0;
						c++;
						if (!s_config_variable_init(&variable, s_config_strip(cur), s_config_strip(c))) {
							s_list_add(category->variable, variable, -1);
						}
					} else {
						debugf(0, "parse error: No '=' (equal sign) in %s of %s", cur, name);
						goto err1;
					}
				}
			} else {
			}
		}
	}
	
	s_free(buf);
	fclose(fp);
	return 0;

err1:	fclose(fp);
err0:	s_free(buf);
	return -1;
}