Esempio n. 1
0
static void
demoapp_destroy(struct demoapp *app)
{
	if (app->triangle)
		triangle_destroy(app->triangle);

	if (app->egl)
		egl_state_destroy(app->egl);

	widget_destroy(app->subsurface);
	widget_destroy(app->widget);
	window_destroy(app->window);
	free(app);
}
Esempio n. 2
0
static void
gears_destroy(struct gears *gears)
{
	widget_destroy(gears->widget);
	window_destroy(gears->window);
	free(gears);
}
Esempio n. 3
0
/** Destroy a screen.
 * \param s    Screen to destroy.
 * \retval <0  Error; no screen given.
 * \retval  0  Success.
 */
int
screen_destroy(Screen *s)
{
	Widget *w;

	debug(RPT_DEBUG, "%s(s=[%.40s])", __FUNCTION__, s->id);

	menuscreen_remove_screen(s);

	screenlist_remove(s);

	for (w = LL_GetFirst(s->widgetlist); w; w = LL_GetNext(s->widgetlist)) {
		/* Free a widget...*/
		widget_destroy(w);
	}
	LL_Destroy(s->widgetlist);
	s->widgetlist = NULL;

	if (s->id != NULL) {
		free(s->id);
		s->id = NULL;
	}
	if (s->name != NULL) {
		free(s->name);
		s->name = NULL;
	}

	free(s);
	s = NULL;

	return 0;
}
Esempio n. 4
0
static void
calibrator_destroy(struct calibrator *calibrator)
{
	widget_destroy(calibrator->widget);
	window_destroy(calibrator->window);
	free(calibrator);
}
Esempio n. 5
0
void open_voxel(widget *w)
{
	if(!w)return;
	if(!w->parent)return;
	widget *p = w->parent;
	if(!p->child)return;
	widget *f = p->child;		// file dialog
	if(-1 == f->selected)return;			// is a file selected?
	if(!f->data)return;
	char **names = (char**)f->data;
	char *path = (char*)p->data2;
	char buf[1000];
	sprintf(buf, "%s/%s", path, names[f->selected]);
	int len = strlen(buf);
	switch(buf[len-3]) {
	case 'o':
	case 'O':
		switch(buf[len-2]) {
		case 'b':
		case 'B':	// obj - Wavefront OBJ
			spawn_voxobj(buf);
			widget_destroy(p);
			break;
		}
		break;

	default:
		break;
	}
}
Esempio n. 6
0
static void
cliptest_destroy(struct cliptest *cliptest)
{
	widget_destroy(cliptest->widget);
	window_destroy(cliptest->window);
	free(cliptest);
}
Esempio n. 7
0
static void
text_entry_destroy(struct text_entry *entry)
{
	widget_destroy(entry->widget);
	wl_text_input_destroy(entry->text_input);
	g_clear_object(&entry->layout);
	free(entry->text);
	free(entry);
}
Esempio n. 8
0
static void
clickdot_destroy(struct clickdot *clickdot)
{
	if (clickdot->buffer)
		cairo_surface_destroy(clickdot->buffer);
	widget_destroy(clickdot->widget);
	window_destroy(clickdot->window);
	free(clickdot);
}
Esempio n. 9
0
static void
text_entry_destroy(struct text_entry *entry)
{
	widget_destroy(entry->widget);
	text_model_destroy(entry->model);
	text_layout_destroy(entry->layout);
	free(entry->text);
	free(entry);
}
Esempio n. 10
0
static void
resizor_destroy(struct resizor *resizor)
{
	if (resizor->frame_callback)
		wl_callback_destroy(resizor->frame_callback);

	widget_destroy(resizor->widget);
	window_destroy(resizor->window);
	free(resizor);
}
Esempio n. 11
0
static void
clickdot_destroy(struct clickdot *clickdot)
{
	display_unwatch_fd(window_get_display(clickdot->window),
			   clickdot->cursor_timeout_fd);
	close(clickdot->cursor_timeout_fd);
	if (clickdot->buffer)
		cairo_surface_destroy(clickdot->buffer);
	widget_destroy(clickdot->widget);
	window_destroy(clickdot->window);
	free(clickdot);
}
Esempio n. 12
0
static void
triangle_destroy(struct triangle *tri)
{
	if (tri->egl_surface)
		eglDestroySurface(tri->egl->dpy, tri->egl_surface);

	if (tri->egl_window)
		wl_egl_window_destroy(tri->egl_window);

	widget_destroy(tri->widget);
	free(tri);
}
Esempio n. 13
0
int main(int argc, char *argv[])
{
	struct timespec ts;
	struct smoke smoke;
	struct display *d;
	int size;

	d = display_create(&argc, argv);
	if (d == NULL) {
		fprintf(stderr, "failed to create display: %m\n");
		return -1;
	}

	smoke.width = 200;
	smoke.height = 200;
	smoke.display = d;
	smoke.window = window_create(d);
	smoke.widget = window_add_widget(smoke.window, &smoke);
	window_set_title(smoke.window, "smoke");

	window_set_buffer_type(smoke.window, WINDOW_BUFFER_TYPE_SHM);
	clock_gettime(CLOCK_MONOTONIC, &ts);
	srandom(ts.tv_nsec);

	smoke.current = 0;
	size = smoke.height * smoke.width;
	smoke.b[0].d = calloc(size, sizeof(float));
	smoke.b[0].u = calloc(size, sizeof(float));
	smoke.b[0].v = calloc(size, sizeof(float));
	smoke.b[1].d = calloc(size, sizeof(float));
	smoke.b[1].u = calloc(size, sizeof(float));
	smoke.b[1].v = calloc(size, sizeof(float));

	widget_set_motion_handler(smoke.widget, mouse_motion_handler);
	widget_set_touch_motion_handler(smoke.widget, touch_motion_handler);
	widget_set_resize_handler(smoke.widget, resize_handler);
	widget_set_redraw_handler(smoke.widget, redraw_handler);

	window_set_user_data(smoke.window, &smoke);

	widget_schedule_resize(smoke.widget, smoke.width, smoke.height);

	display_run(d);

	widget_destroy(smoke.widget);
	window_destroy(smoke.window);
	display_destroy(d);

	return 0;
}
Esempio n. 14
0
static void
close_handler(struct window *window, void *data)
{
	struct image *image = data;

	*image->image_counter -= 1;

	if (*image->image_counter == 0)
		display_exit(image->display);

	widget_destroy(image->widget);
	window_destroy(image->window);

	free(image);
}
Esempio n. 15
0
void widget_window_release(widget *w)
{
	w->delta.x = mouse_x - w->pos.x;
	w->delta.y = mouse_y - w->pos.y;
	if(3 != w->clicked)return;
	if(w->delta.y > 5)
	if(w->delta.y < 30)
	if(w->delta.x > (w->size.x - 50) )
	if(w->delta.x < w->size.x )
	{
		// end button clicked
		widget_destroy(w);
	}

}
Esempio n. 16
0
static void
close_handler(struct window *window, void *data)
{
	struct view *view = data;

	*view->view_counter -= 1;
	if (*view->view_counter == 0)
		display_exit(view->display);

	widget_destroy(view->widget);
	window_destroy(view->window);
	if (view->document)
		g_object_unref(view->document);

	free(view);
}
Esempio n. 17
0
static int notepad_remove_category(widget_list* UNUSED(w),
	int UNUSED(mx), int UNUSED(my), Uint32 flags)
{
	static Uint32 last_click = 0;
	int i, id = -1, cur_tab, t;

	// only handle mouse button clicks, not scroll wheels moves
	if ( (flags & ELW_MOUSE_BUTTON) == 0) return 0;

	if (!safe_button_click(&last_click))
		return 1;

	t = tab_collection_get_tab_id (notepad_win, note_tabcollection_id);
	cur_tab = tab_collection_get_tab (notepad_win, note_tabcollection_id);

	for (i = 0; i < nr_notes; i++)
	{
		if (t == note_list[i].window)
		{
			id = i;
			break;
		}
	}
	if (id >= nr_notes || id == -1)
	{
		return 0;
	}

	tab_collection_close_tab (notepad_win, note_tabcollection_id, cur_tab);
	widget_destroy (main_note_tab_id, note_list[id].button_id);
	free_text_message_data (&(note_list[id].text));

	// shift all notes after the deleted note one up
	if (id < nr_notes-1)
	{
		memmove (&(note_list[id]), &(note_list[id+1]), (nr_notes-id-1) * sizeof (note));
		for ( ; id < nr_notes-1; id++)
			note_button_set_pos (id);
	}
	nr_notes--;

	update_note_button_scrollbar(0);

	return 1;
}
void menuitem_rebuild_screen(MenuItem *item, Screen *s)
{
	Widget *w;
	void (*build_screen) (MenuItem *item, Screen *s);

	debug(RPT_DEBUG, "%s(item=[%s], screen=[%s])", __FUNCTION__,
			((item != NULL) ? item->id : "(null)"),
			((s != NULL) ? s->id : "(null)"));

	if (!display_props) {
		/* Nothing to build if no display size is known */
		report(RPT_ERR, "%s: display size unknown", __FUNCTION__);
		return;
	}

	if (s != NULL) {
		/* First remove all widgets from the screen */
		while ((w = screen_getfirst_widget(s)) != NULL) {
			/* We know these widgets don't have subwidgets, so we can
			 * easily remove them
			 */
			screen_remove_widget(s, w);
			widget_destroy(w);
		}

		if (item != NULL) {
			/* Call type specific screen building function */
			build_screen = build_screen_table [item->type];
			if (build_screen) {
				build_screen(item, s);
			} else {
				report(RPT_ERR, "%s: given menuitem cannot be active", __FUNCTION__);
				return;
			}

			/* Also always call update_screen */
			menuitem_update_screen(item, s);
		}
	}
}
Esempio n. 19
0
int main(int argc, char *argv[])
{
	struct flower flower;
	struct display *d;
	struct timeval tv;

	d = display_create(&argc, argv);
	if (d == NULL) {
		fprintf(stderr, "failed to create display: %m\n");
		return -1;
	}

	gettimeofday(&tv, NULL);
	srandom(tv.tv_usec);

	flower.width = 200;
	flower.height = 200;
	flower.display = d;
	flower.window = window_create(d);
	flower.widget = window_add_widget(flower.window, &flower);
	window_set_title(flower.window, "Flower");

	widget_set_resize_handler(flower.widget, resize_handler);
	widget_set_redraw_handler(flower.widget, redraw_handler);
	widget_set_button_handler(flower.widget, button_handler);
	widget_set_default_cursor(flower.widget, CURSOR_HAND1);
	widget_set_touch_down_handler(flower.widget, touch_down_handler);

	window_schedule_resize(flower.window, flower.width, flower.height);

	display_run(d);

	widget_destroy(flower.widget);
	window_destroy(flower.window);
	display_destroy(d);

	return 0;
}
Esempio n. 20
0
widget_t*
listbox_create(widget_t* parent, rect_t rect, int item_height)
{
  listbox_t* l = calloc(1, sizeof(listbox_t));

  widget_t* lb = widget_create(parent, NULL, l, rect);

  l->pos = 0;
  l->item_height = item_height;

  rect_t container_rect = {
      .x = 0,
      .y = 0,
      .width = rect.width - 52,
      .height = rect.height
  };
  l->item_container = widget_create(lb, &listbox_widget_class, l, container_rect);

  int button_pad = (rect.height - (2 * 52)) / 3;
  rect_t button_rect = {
      .x = rect.width - 52,
      .y = button_pad,
      .width = 52,
      .height = 52
  };
  l->up_button = button_create(lb, button_rect, img_up, WHITE, BLACK, up_button_event);
  button_set_up_bg_color(l->up_button, BLACK);
  button_set_up_icon_color(l->up_button, WHITE);
  button_set_down_bg_color(l->up_button, BLACK);
  button_set_down_icon_color(l->up_button, LIGHT_GRAY);
  button_set_disabled_bg_color(l->up_button, BLACK);
  button_set_disabled_icon_color(l->up_button, DARK_GRAY);

  button_rect.y += 52 + button_pad;
  l->dn_button = button_create(lb, button_rect, img_down, WHITE, BLACK, down_button_event);
  button_set_up_bg_color(l->dn_button, BLACK);
  button_set_up_icon_color(l->dn_button, WHITE);
  button_set_down_bg_color(l->dn_button, BLACK);
  button_set_down_icon_color(l->dn_button, LIGHT_GRAY);
  button_set_disabled_bg_color(l->dn_button, BLACK);
  button_set_disabled_icon_color(l->dn_button, DARK_GRAY);

  return lb;
}

void
listbox_clear(widget_t* lb)
{
  listbox_t* l = widget_get_instance_data(lb);
  while (1) {
    widget_t* w = widget_get_child(l->item_container, 0);
    if (w == NULL)
      break;

    widget_unparent(w);
    widget_destroy(w);
  }
  widget_invalidate(lb);
}

static void
listbox_destroy(widget_t* w)
{
  listbox_t* l = widget_get_instance_data(w);
  free(l);
}
Esempio n. 21
0
int
main(int argc, char *argv[])
{
	struct box box;
	struct display *d;
	struct timeval tv;
	int i;

	d = display_create(&argc, argv);
	if (d == NULL) {
		fprintf(stderr, "failed to create display: %m\n");
		return -1;
	}

	box.mode = MODE_SRC_DST;

	for (i = 1; i < argc; i++) {
		if (strcmp("-s", argv[i]) == 0)
			box.mode = MODE_SRC_ONLY;
		else if (strcmp("-d", argv[i]) == 0)
			box.mode = MODE_DST_ONLY;
		else if (strcmp("-b", argv[i]) == 0)
			box.mode = MODE_SRC_DST;
		else if (strcmp("-n", argv[i]) == 0)
			box.mode = MODE_NO_VIEWPORT;
		else {
			usage(argv[0]);
			exit(1);
		}
	}

	gettimeofday(&tv, NULL);
	srandom(tv.tv_usec);

	box.width = BUFFER_WIDTH / BUFFER_SCALE;
	box.height = BUFFER_HEIGHT / BUFFER_SCALE;
	box.display = d;
	box.window = window_create(d);
	box.widget = window_add_widget(box.window, &box);
	window_set_title(box.window, "Scaler Test Box");
	window_set_buffer_scale(box.window, BUFFER_SCALE);

	widget_set_resize_handler(box.widget, resize_handler);
	widget_set_redraw_handler(box.widget, redraw_handler);
	widget_set_button_handler(box.widget, button_handler);
	widget_set_default_cursor(box.widget, CURSOR_HAND1);
	widget_set_touch_down_handler(box.widget, touch_down_handler);

	window_schedule_resize(box.window, box.width, box.height);

	display_set_user_data(box.display, &box);
	display_set_global_handler(box.display, global_handler);

	display_run(d);

	widget_destroy(box.widget);
	window_destroy(box.window);
	display_destroy(d);

	return 0;
}
int main(int argc, char *argv[])
{
    struct transformed transformed;
    struct display *d;
    int i;

    transformed.width = 500;
    transformed.height = 250;
    transformed.fullscreen = 0;

    for (i = 1; i < argc; i++) {
        if (strcmp(argv[i], "-w") == 0) {
            if (++i >= argc)
                usage(EXIT_FAILURE);

            transformed.width = atol(argv[i]);
        } else if (strcmp(argv[i], "-h") == 0) {
            if (++i >= argc)
                usage(EXIT_FAILURE);

            transformed.height = atol(argv[i]);
        } else if (strcmp(argv[i], "--help") == 0)
            usage(EXIT_SUCCESS);
        else
            usage(EXIT_FAILURE);
    }

    d = display_create(&argc, argv);
    if (d == NULL) {
        fprintf(stderr, "failed to create display: %m\n");
        return -1;
    }

    transformed.display = d;
    transformed.window = window_create(d);
    transformed.widget =
        window_add_widget(transformed.window, &transformed);

    window_set_title(transformed.window, "Transformed");

    widget_set_transparent(transformed.widget, 0);
    widget_set_default_cursor(transformed.widget, CURSOR_BLANK);

    widget_set_redraw_handler(transformed.widget, redraw_handler);
    widget_set_button_handler(transformed.widget, button_handler);

    widget_set_touch_down_handler(transformed.widget, touch_handler);

    window_set_key_handler(transformed.window, key_handler);
    window_set_fullscreen_handler(transformed.window, fullscreen_handler);
    window_set_output_handler(transformed.window, output_handler);

    window_set_user_data(transformed.window, &transformed);
    window_schedule_resize(transformed.window,
                           transformed.width, transformed.height);

    display_run(d);
    widget_destroy(transformed.widget);
    window_destroy(transformed.window);
    display_destroy(d);

    return 0;
}
Esempio n. 23
0
/**
 * \brief Destroy eventdemo instance previously created by \c eventdemo_create().
 * \param eventdemo eventdemo instance to destroy
 */
static void eventdemo_destroy(struct eventdemo * eventdemo)
{
	widget_destroy(eventdemo->widget);
	window_destroy(eventdemo->window);
	free(eventdemo);
}
Esempio n. 24
0
File: gtk.c Progetto: Airr/Claro
/* destroy handler */
gint cgraphics_destroy_handler( widget_t *w )
{
	widget_destroy( OBJECT(w) );
 
	return 1;
}