Example #1
0
File: dock.c Project: dkogan/notion
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);
    }
}
Example #2
0
void
region_basic()
{
	header();

	struct region region;

	region_create(&region, &cache);

	fail_unless(region_used(&region) == 0);

	void *ptr = region_alloc(&region, 10);

	fail_unless(ptr);

	fail_unless(region_used(&region) == 10);

	ptr = region_alloc(&region, 10000000);
	fail_unless(ptr);

	fail_unless(region_used(&region) == 10000010);

	region_free(&region);

	fail_unless(region_used(&region) == 0);

	printf("name of a new region: %s.\n", region_name(&region));

	region_set_name(&region, "region");

	printf("set new region name: %s.\n", region_name(&region));

	region_set_name(&region, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

	printf("region name is truncated: %s.\n", region_name(&region));

	footer();
}