VALUE shoes_app_alloc(VALUE klass) { shoes_app *app = SHOE_ALLOC(shoes_app); SHOE_MEMZERO(app, shoes_app, 1); app->slot = SHOE_ALLOC(SHOES_SLOT_OS); SHOE_MEMZERO(app->slot, SHOES_SLOT_OS, 1); app->slot->owner = app; app->started = FALSE; app->owner = Qnil; app->location = Qnil; app->canvas = shoes_canvas_new(cShoes, app); app->nestslot = Qnil; app->nesting = rb_ary_new(); app->extras = rb_ary_new(); app->groups = Qnil; app->styles = Qnil; app->title = Qnil; app->width = SHOES_APP_WIDTH; app->height = SHOES_APP_HEIGHT; app->resizable = TRUE; app->cursor = s_arrow; app->scratch = cairo_create(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1)); app->self = Data_Wrap_Struct(klass, shoes_app_mark, shoes_app_free, app); return app->self; }
size_t shoes_curl_header_funk(char *ptr, size_t size, size_t nmemb, void *user) { shoes_curl_data *data = (shoes_curl_data *)user; size_t realsize = size * nmemb; if (data->status == 0 && data->handler != NULL) { curl_easy_getinfo(data->curl, CURLINFO_RESPONSE_CODE, (long *)&data->status); if (data->handler != NULL) { shoes_http_event *event = SHOE_ALLOC(shoes_http_event); SHOE_MEMZERO(event, shoes_http_event, 1); event->stage = SHOES_HTTP_STATUS; event->status = data->status; data->handler(event, data->data); SHOE_FREE(event); } } HTTP_HEADER(ptr, realsize, data->handler, data->data); if ((data->mem != NULL || data->fp != NULL) && strncmp(ptr, content_len_str, strlen(content_len_str)) == 0) { data->total = strtoull(ptr + strlen(content_len_str), NULL, 10); if (data->mem != NULL && data->total > data->memlen) { data->memlen = data->total; SHOE_REALLOC_N(data->mem, char, data->memlen); if (data->mem == NULL) return -1; }
VALUE shoes_systray_alloc(VALUE klass) { VALUE obj; shoes_systray *handle = SHOE_ALLOC(shoes_systray); SHOE_MEMZERO(handle, shoes_systray, 1); obj = Data_Wrap_Struct(klass, NULL, shoes_systray_free, handle); handle->icon_path = NULL; handle->title = NULL; handle->message = NULL; return obj; }
VALUE shoes_event_alloc(VALUE klass) { VALUE obj; shoes_event *event = SHOE_ALLOC(shoes_event); SHOE_MEMZERO(event, shoes_event, 1); obj = Data_Wrap_Struct(klass, shoes_event_mark, shoes_event_free, event); event->type = Qnil; event->object = Qnil; return obj; }
shoes_transform *shoes_transform_new(shoes_transform *o) { shoes_transform *n = SHOE_ALLOC(shoes_transform); n->mode = s_center; n->refs = 1; cairo_matrix_init_identity(&n->tf); if (o != NULL) { cairo_matrix_multiply(&n->tf, &n->tf, &o->tf); n->mode = o->mode; } return n; }
VALUE shoes_canvas_alloc(VALUE klass) { shoes_canvas *canvas = SHOE_ALLOC(shoes_canvas); SHOE_MEMZERO(canvas, shoes_canvas, 1); canvas->app = NULL; canvas->stage = CANVAS_NADA; canvas->contents = Qnil; canvas->shape = NULL; canvas->insertion = -2; VALUE rb_canvas = Data_Wrap_Struct(klass, shoes_canvas_mark, shoes_canvas_free, canvas); return rb_canvas; }
shoes_world_t * shoes_world_alloc() { shoes_world_t *world = SHOE_ALLOC(shoes_world_t); SHOE_MEMZERO(world, shoes_world_t, 1); world->apps = rb_ary_new(); world->msgs = rb_ary_new(); world->mainloop = FALSE; rb_gc_register_address(&world->apps); rb_gc_register_address(&world->msgs); return world; }
lumi_world_t * lumi_world_alloc() { lumi_world_t *world = SHOE_ALLOC(lumi_world_t); SHOE_MEMZERO(world, lumi_world_t, 1); world->apps = rb_ary_new(); world->msgs = rb_ary_new(); world->mainloop = FALSE; world->image_cache = st_init_strtable(); world->blank_image = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); world->blank_cache = SHOE_ALLOC(lumi_cached_image); world->blank_cache->surface = world->blank_image; world->blank_cache->pattern = NULL; world->blank_cache->width = 1; world->blank_cache->height = 1; world->blank_cache->mtime = 0; world->default_font = pango_font_description_new(); pango_font_description_set_family(world->default_font, "Arial"); pango_font_description_set_absolute_size(world->default_font, 14. * PANGO_SCALE * (96./72.)); rb_gc_register_address(&world->apps); rb_gc_register_address(&world->msgs); return world; }
VALUE shoes_menu_alloc(VALUE klass) { VALUE obj; shoes_menu *mn = SHOE_ALLOC(shoes_menu); SHOE_MEMZERO(mn, shoes_menu, 1); obj = Data_Wrap_Struct(klass, shoes_menu_mark, shoes_menu_free, mn); mn->native = NULL; mn->extra = NULL; mn->parent = NULL; mn->title = NULL; //mn->context = Qnil; mn->context = NULL; mn->items = rb_ary_new(); return obj; }
int shoes_throw_message(unsigned int name, VALUE obj, void *data) { int ret; shoes_gtk_msg *msg = SHOE_ALLOC(shoes_gtk_msg); msg->name = name; msg->obj = obj; msg->data = data; pthread_mutex_init(&msg->mutex, NULL); pthread_cond_init(&msg->cond, NULL); msg->ret = 0; pthread_mutex_lock(&msg->mutex); g_idle_add_full(G_PRIORITY_DEFAULT, shoes_gtk_catch_message, msg, NULL); pthread_cond_wait(&msg->cond, &msg->mutex); ret = msg->ret; pthread_mutex_unlock(&msg->mutex); free(msg); return ret; }