static void dock_do_set(WDock *dock, ExtlTab conftab, bool resize) { char *s; bool b; bool growset=FALSE; bool posset=FALSE; bool save=FALSE; if(extl_table_gets_s(conftab, dock_param_name.key, &s)){ if(!region_set_name((WRegion*)dock, s)){ warn_obj(modname, "Can't set name to \"%s\"", s); } free(s); } if(extl_table_gets_b(conftab, "save", &save)) dock->save=save; if(dock_param_extl_table_set(&dock_param_pos, conftab, &dock->pos)) posset=TRUE; if(dock_param_extl_table_set(&dock_param_grow, conftab, &dock->grow)) growset=TRUE; if(extl_table_gets_b(conftab, dock_param_is_auto.key, &b)) dock->is_auto=b; if(resize && (growset || posset)){ WMPlex *par=OBJ_CAST(REGION_PARENT(dock), WMPlex); WRegion *stdisp=NULL; WMPlexSTDispInfo din; if(par!=NULL){ mplex_get_stdisp(par, &stdisp, &din); din.fullsize=FALSE; /* not supported. */ if(stdisp==(WRegion*)dock){ if(posset) mplexpos(dock->pos, &din.pos); if(growset){ /* Update min/max first */ dock_managed_rqgeom_(dock, NULL, 0, NULL, NULL, TRUE); } mplex_set_stdisp(par, (WRegion*)dock, &din); }else if((WRegion*)par==REGION_MANAGER(dock)){ WSizePolicy szplcy; mplexszplcy(dock->pos, &szplcy); mplex_set_szplcy(par, (WRegion*)dock, szplcy); } } dock_resize(dock); } }
void region_basic() { header(); struct region region; region_create(®ion, &cache); fail_unless(region_used(®ion) == 0); void *ptr = region_alloc(®ion, 10); fail_unless(ptr); fail_unless(region_used(®ion) == 10); ptr = region_alloc(®ion, 10000000); fail_unless(ptr); fail_unless(region_used(®ion) == 10000010); region_free(®ion); fail_unless(region_used(®ion) == 0); printf("name of a new region: %s.\n", region_name(®ion)); region_set_name(®ion, "region"); printf("set new region name: %s.\n", region_name(®ion)); region_set_name(®ion, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); printf("region name is truncated: %s.\n", region_name(®ion)); footer(); }