Example #1
0
int w_clistbox_init (w_window_t *window, w_clistbox_t **listbox, w_object_t *parent)
{
	w_clistbox_t *lb;
	lb = (w_clistbox_t *) s_malloc(sizeof(w_clistbox_t));
	w_frame_init(window, &(lb->frame), FRAME_PANEL | FRAME_SUNKEN, parent);
	s_list_init(&(lb->items));
	s_list_init(&(lb->item_images));
	lb->height = 0;
	lb->yoffset = 0;
	lb->active = 0;
	lb->pactive = -1;
	lb->itemheight = 24;
	lb->changed = NULL;
	lb->activeshape = FRAME_PANEL;
	lb->activeshadow = FRAME_SUNKEN;
	lb->inactiveshape = FRAME_NOFRAME;
	lb->inactiveshadow = FRAME_RAISED;
	lb->scrollbuffer = NULL;
	lb->object = lb->frame->object;
	lb->object->type = OBJECT_CLISTBOX;
	lb->object->draw = w_clistbox_draw;
	lb->object->event = w_clistbox_event;
	lb->object->geometry = w_clistbox_geometry;
	lb->object->destroy = w_clistbox_uninit;
	lb->object->data[OBJECT_CLISTBOX] = lb;
	*listbox = lb;
	return 0;
}
Example #2
0
int w_frame_image_init (w_frame_image_t **fimg)
{
	*fimg = s_malloc(sizeof(w_frame_image_t));
	memset(*fimg, 0, sizeof(w_frame_image_t));
	s_list_init(&((*fimg)->images));
	s_list_init(&((*fimg)->names));
	return 0;
}
Example #3
0
int s_config_init (s_config_t **cfg)
{
	(*cfg) = (s_config_t *) s_malloc(sizeof(s_config_t));
	if (s_list_init(&((*cfg)->category))) {
		goto err0;
	}
	return 0;
err0:	s_free(*cfg);
	return -1;
}
Example #4
0
int s_config_category_init (s_config_cat_t **cat, char *name)
{
	(*cat) = (s_config_cat_t *) s_malloc(sizeof(s_config_cat_t));
	(*cat)->name = strdup(name);
	if (s_list_init(&((*cat)->variable))) {
		goto err0;
	}
	return 0;
err0:	s_free((*cat)->name);
	s_free(*cat);
	return -1;
}
Example #5
0
static unsigned char * lxynth_init_driver (unsigned char *param, unsigned char *display)
{
        int bpp;
        int Bpp;

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

	lxynth_root = (lxynth_root_t *) s_malloc(sizeof(lxynth_root_t));
	lxynth_root->eventq = (lxynth_eventq_t *) s_malloc(sizeof(lxynth_eventq_t));
	s_list_init(&(lxynth_root->eventq->list));
	s_thread_mutex_init(&(lxynth_root->eventq->mut));
	lxynth_root->gd = (lxynth_gd_t *) s_malloc(sizeof(lxynth_gd_t));
	s_list_init(&(lxynth_root->gd->list));
	s_thread_mutex_init(&(lxynth_root->gd->mut));
	lxynth_root->gd->active = NULL;

	s_window_init(&(lxynth_root->window));
	s_window_new(lxynth_root->window, WINDOW_MAIN, NULL);
	s_window_set_coor(lxynth_root->window, WINDOW_NOFORM, 50, 50,
	                                                      (lxynth_root->window->surface->width * 2) / 3,
	                                                      (lxynth_root->window->surface->height * 2) / 3);
        bpp = lxynth_root->window->surface->bitsperpixel;
        Bpp = lxynth_root->window->surface->bytesperpixel;

        if (bpp ==  32) {
		bpp = 24;
	}
	xynth_driver.depth = (bpp << 3) | Bpp;

	s_window_show(lxynth_root->window);
	lxynth_root->tid = s_thread_create(s_window_main, lxynth_root->window);
	s_window_atevent(lxynth_root->window, lxynth_atevent);
	s_window_atexit(lxynth_root->window, lxynth_atexit);
	lxynth_root->running = 1;

	install_timer(20, lxynth_timer, NULL);

	return NULL;
}
Example #6
0
int s_handlers_init (s_window_t *window)
{
	window->handlers = (s_handlers_t *) s_malloc(sizeof(s_handlers_t));
	if (s_list_init(&(window->handlers->list))) {
		goto err0;
	}
	if (s_thread_mutex_init(&(window->handlers->mut))) {
		goto err1;
	}
	return 0;
err1:	s_list_uninit(window->handlers->list);
err0:	s_free(window->handlers);
	return 1;
}
Example #7
0
int s_pollfds_init (s_window_t *window)
{
	window->pollfds = (s_pollfds_t *) s_calloc(1, sizeof(s_pollfds_t));
	if (s_list_init(&(window->pollfds->list))) {
		goto err0;
	}
	if (s_thread_mutex_init(&(window->pollfds->mut))) {
		goto err1;
	}
	return 0;
err1:	s_list_uninit(window->pollfds->list);
err0:	s_free(window->pollfds);
	return -1;
}
Example #8
0
int w_frame_init (w_window_t *window, w_frame_t **frame, unsigned int style, w_object_t *parent)
{
	(*frame) = (w_frame_t *) s_malloc(sizeof(w_frame_t));
	(*frame)->style = style;
	(*frame)->linewidth = 1;
	(*frame)->midlinewidth = 0;
	if (w_object_init(window, &((*frame)->object), w_frame_draw, parent)) {
		goto err0;
	}
	(*frame)->object->type = OBJECT_FRAME;
	(*frame)->object->data[OBJECT_FRAME] = *frame;
	(*frame)->object->geometry = w_frame_geometry;
	(*frame)->object->destroy = w_frame_uninit;
	s_list_init(&((*frame)->images));
	return 0;
err0:	s_free(*frame);
	return -1;
}
Example #9
0
int s_event_init (s_event_t **event)
{
	(*event) = (s_event_t *) s_calloc(1, sizeof(s_event_t));
	(*event)->mouse = (s_mouse_t *) s_calloc(1, sizeof(s_mouse_t));
	(*event)->keybd = (s_keybd_t *) s_calloc(1, sizeof(s_keybd_t));
	(*event)->expose = (s_expose_t *) s_calloc(1, sizeof(s_expose_t));
	(*event)->expose->rect = (s_rect_t *) s_calloc(1, sizeof(s_rect_t));
	(*event)->desktop = (s_desktop_t *) s_calloc(1, sizeof(s_desktop_t));
	if (s_list_init(&((*event)->desktop->clients))) {
		goto err0;
	}
	return 0;
err0:	s_free((*event)->desktop);
	s_free((*event)->expose);
	s_free((*event)->keybd);
	s_free((*event)->mouse);
	s_free(*event);
	return -1;
}
Example #10
0
void *read_trd_fn(void *trd_data)
{
    // A new thread has been created, only one of its kind.
    // It was created in p2_actions
    // trd_data points to a struct r_trd_data which contains
    // (1) a linked list of all the lines from the input file
    // (2) a struct foo iterator of all the -m options supplied by the command line.
    struct r_trd_dat *infile_m_lines = (struct r_trd_dat *)trd_data;

    printf("Initting semaphore variable\n");
/*    sem_init(&search_sem, 0, 1); // Initial value of search_sem set to 1
    sem_init(&n_sem, 0, 0);      // n_sem for producer/consumer, init to 0
    sem_init(&more_data_sem, 0, 0);

    sem_init(&empty, 0, 1);
    sem_init(&full, 0, 0);*/
    pthread_mutex_init(&mutex, NULL);

    struct foo *m = infile_m_lines->m_list;
    l_list *infile_list = infile_m_lines->infile_list;

    // Create list of search threads
    s_list *search_threads = s_list_init();

    // initialize p3_data:
    p3_data = l_list_init();

    int s_count = 0;

    for(; m != NULL; m = m->next)
        s_count++;


    int i = 0;
    // create each search thread:
    for(m = infile_m_lines->m_list; m != NULL; m = m->next)
    {
        s_node *s = (s_node *)malloc(sizeof(s_node));
        if(s == NULL)
            err_sys("malloc (read_trd_fn)");
    
        s->next = NULL;
        s->_m = strdup(m->string);
        if(s->_m == NULL)
            err_sys("strdup (read_trd_fn)");

        // Copy input file buffer over to this s node:
        s->infile_list = l_list_init();
        node *copy_iter = infile_list->head;
        for(; copy_iter != NULL; copy_iter = copy_iter->next)
        {
            l_list_append(s->infile_list, copy_iter->data);
        }

        // Append the newly created s_node to the list.
        if(s_list_append(search_threads, s) != 0)
            exit(0);

        pthread_create(&s->tid, NULL, search_trd_fn, (void *)s);

        pthread_join(s->tid, NULL);

        i++;
    }

    printf("s_count = %d\n", s_count);

    // Now all the search threads have been created (for 3 -m options supplied, there should be 3 threads)
    // Now put each line from the input file into each (search_thread's) s_node's _protected char*.

    node *end;
    for(end = p3_data->head; end != NULL; end = end->next)
        fprintf(infile_m_lines->fp, "%s", end->data);

    pthread_exit(NULL);
    return NULL;
}
Example #11
0
int s_image_layers_init (s_image_t *img)
{
	return s_list_init(&(img->layers));
}
Example #12
0
File: menu.c Project: d33tah/whitix
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);
				}
			}
		}
	}
}
Example #13
0
int s_dirs_init (s_list_t **dirs)
{
	int r;
	r = s_list_init(dirs);
	return r;
}
Example #14
0
int s_files_init (s_list_t **files)
{
	int r;
	r = s_list_init(files);
	return r;
}
Example #15
0
void taskbar_start (s_window_t *window, s_config_t *cfg)
{
        int x;
	s_timer_t *timer;
	s_handler_t *hndl;
        tbar_data_t *tbar_data;

	s_window_set_coor(window, WINDOW_TYPE_NOFORM, 0, window->surface->height - 30, window->surface->width, 30);
	s_window_set_alwaysontop(window, 1);
	s_window_set_resizeable(window, 0);
	s_window_atevent(window, taskbar_atevent);
	s_window_atexit(window, taskbar_atexit);

	s_free(window->surface->vbuf);
	window->surface->width = window->surface->buf->w;
	window->surface->height = window->surface->buf->h;
	window->surface->vbuf = (unsigned char *) s_malloc(window->surface->width * window->surface->height * window->surface->bytesperpixel);

        tbar_data = (tbar_data_t *) s_malloc(sizeof(tbar_data_t));
        tbar_data->tbar_clock = (tbar_clock_t *) s_malloc(sizeof(tbar_clock_t));
        tbar_data->tbar_smenu = (tbar_smenu_t *) s_malloc(sizeof(tbar_smenu_t));
	s_list_init(&(tbar_data->tbar_smenu->progs));
	s_image_init(&(tbar_data->tbar_smenu->img));
	s_image_img(DESKTOPDIR "/img/icons/xynth.png", tbar_data->tbar_smenu->img);
	s_image_get_handler(tbar_data->tbar_smenu->img);
	tbar_data->tbar_smenu->running = 0;

        tbar_data->tbar_progs = (tbar_progs_t *) s_malloc(sizeof(tbar_progs_t));
	tbar_data->tbar_progs->desktop = (s_desktop_t *) s_malloc(sizeof(s_desktop_t));
	s_list_init(&(tbar_data->tbar_progs->desktop->clients));

	s_font_init(&(tbar_data->tbar_progs->prog_font), "arial.ttf");

	s_image_init(&(tbar_data->tbar_progs->tbar_img));
	s_image_img(DESKTOPDIR "/img/widget/taskbar.png", tbar_data->tbar_progs->tbar_img);
	s_image_get_buf(window->surface, tbar_data->tbar_progs->tbar_img);

	s_image_init(&(tbar_data->tbar_progs->prog_img[0]));
	s_image_img(DESKTOPDIR "/img/widget/button4.png", tbar_data->tbar_progs->prog_img[0]);
	s_image_get_buf(window->surface, tbar_data->tbar_progs->prog_img[0]);

	s_image_init(&(tbar_data->tbar_progs->prog_img[1]));
	s_image_img(DESKTOPDIR "/img/widget/button3.png", tbar_data->tbar_progs->prog_img[1]);
	s_image_get_buf(window->surface, tbar_data->tbar_progs->prog_img[1]);

	window->data = (void *) tbar_data;

	s_fillbox(window->surface, 0, 0, window->surface->buf->w, window->surface->buf->h, s_rgbcolor(window->surface, 255, 255, 255));
	s_fillbox(window->surface, 1, 1, window->surface->buf->w - 1, window->surface->buf->h - 1, s_rgbcolor(window->surface, 115, 117, 115));

	for (x = 1; x <= window->surface->buf->w; x++) {
		s_putboxpart(window->surface, x, 1, 1, window->surface->buf->h - 2, 1, 30, tbar_data->tbar_progs->tbar_img->buf, 0, 1);
	}

	tbar_data->tbar_clock->clock = NULL;
        tbar_data->tbar_clock->rect.x = window->surface->width - 3 - 75;
        tbar_data->tbar_clock->rect.y = 3;
        tbar_data->tbar_clock->rect.w = 75;
        tbar_data->tbar_clock->rect.h = window->surface->height - 6;
	s_font_init(&(tbar_data->tbar_clock->font), "veramono.ttf");
	s_font_set_size(tbar_data->tbar_clock->font, tbar_data->tbar_clock->rect.h);

        tbar_data->tbar_smenu->rect.x = 3;
        tbar_data->tbar_smenu->rect.y = 3;
        tbar_data->tbar_smenu->rect.w = window->surface->height - 6;
        tbar_data->tbar_smenu->rect.h = window->surface->height - 6;

	tbar_data->tbar_progs->rect.x = 3 + tbar_data->tbar_smenu->rect.w + 3;
	tbar_data->tbar_progs->rect.y = 3;
	tbar_data->tbar_progs->rect.w = window->surface->width - 3 - tbar_data->tbar_smenu->rect.w - 3 - 3 - tbar_data->tbar_clock->rect.w - 3;
	tbar_data->tbar_progs->rect.h = window->surface->height - 6;

	s_handler_init(&hndl);
	hndl->type = MOUSE_HANDLER;
	hndl->mouse.x = tbar_data->tbar_progs->rect.x;
	hndl->mouse.y = tbar_data->tbar_progs->rect.y;
	hndl->mouse.w = tbar_data->tbar_progs->rect.w;
	hndl->mouse.h = tbar_data->tbar_progs->rect.h;
	hndl->mouse.r = taskbar_progs_handler_r;
	hndl->mouse.button = MOUSE_BUTTON_LEFT;
	s_handler_add(window, hndl);

	s_handler_init(&hndl);
	hndl->type = MOUSE_HANDLER;
	hndl->mouse.x = tbar_data->tbar_smenu->rect.x;
	hndl->mouse.y = tbar_data->tbar_smenu->rect.y;
	hndl->mouse.w = tbar_data->tbar_smenu->rect.w;
	hndl->mouse.h = tbar_data->tbar_smenu->rect.h;
	hndl->mouse.p = taskbar_start_menu_handler_p;
	hndl->mouse.button = MOUSE_BUTTON_LEFT;
	s_handler_add(window, hndl);
	taskbar_start_menu_icon(window);

	s_handler_init(&hndl);
	hndl->type = MOUSE_HANDLER;
	hndl->mouse.x = tbar_data->tbar_clock->rect.x;
	hndl->mouse.y = tbar_data->tbar_clock->rect.y;
	hndl->mouse.w = tbar_data->tbar_clock->rect.w;
	hndl->mouse.h = tbar_data->tbar_clock->rect.h;
	hndl->mouse.o = taskbar_clock_handler_o;
	hndl->mouse.oh = taskbar_clock_handler_oh;
	hndl->data = NULL;
	s_handler_add(window, hndl);
	
	start_menu_setup(window, cfg);

	s_timer_init(&timer);
	timer->timeval = 1000;
	timer->cb = taskbar_clock_draw;
	s_timer_add(window, timer);
	taskbar_clock_draw(window, timer);
	
	s_window_show(window);
	s_window_main(window);
}