Ejemplo n.º 1
0
Archivo: app.c Proyecto: gensym/shoes
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;
}
Ejemplo n.º 2
0
Archivo: curl.c Proyecto: Shoes3/shoes3
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;
    }
Ejemplo n.º 3
0
SHOES_DOWNLOAD_HEADERS
shoes_http_headers(VALUE hsh)
{
    long i;
    LPWSTR hdrs = NULL;
    VALUE keys = rb_funcall(hsh, s_keys, 0);
    if (RARRAY_LEN(keys) > 0)
    {
        VALUE headers = rb_str_new2("");
        //for (i = 0; i < RARRAY(keys)->as.heap.len; i++ )
        for (i = 0; i < RARRAY_LEN(keys); i++ )
        {
            VALUE key = rb_ary_entry(keys, i);
            rb_str_append(headers, key);
            rb_str_cat2(headers, ": ");
            rb_str_append(headers, rb_hash_aref(hsh, key));
            rb_str_cat2(headers, "\n");
        }

        hdrs = SHOE_ALLOC_N(WCHAR, RSTRING_LEN(headers) + 1);
        SHOE_MEMZERO(hdrs, WCHAR, RSTRING_LEN(headers) + 1);
        MultiByteToWideChar(CP_UTF8, 0, RSTRING_PTR(headers), -1, hdrs, RSTRING_LEN(headers) + 1);
    }
    return hdrs;
}
Ejemplo n.º 4
0
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;
}
Ejemplo n.º 5
0
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;
}
Ejemplo n.º 6
0
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;
}
Ejemplo n.º 7
0
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;
}
Ejemplo n.º 8
0
Archivo: menu.c Proyecto: Shoes3/shoes3
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;
}
Ejemplo n.º 9
0
Archivo: world.c Proyecto: Klokka/Lumi
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;
}