static gboolean _adg_cell_set_title(AdgTableCell *table_cell, AdgEntity *title) { AdgEntity *alignment; if (table_cell->title == title) return FALSE; if (table_cell->title) { alignment = adg_entity_get_parent(table_cell->title); g_object_unref(alignment); } table_cell->title = title; if (title) { AdgEntity *table = (AdgEntity *) adg_table_cell_get_table(table_cell); alignment = (AdgEntity *) adg_alignment_new_explicit(0, -1); g_object_ref_sink(alignment); adg_entity_set_parent(alignment, table); adg_container_add((AdgContainer *) alignment, title); } return TRUE; }
static gboolean _adg_cell_set_value(AdgTableCell *table_cell, AdgEntity *value) { AdgEntity *alignment; if (table_cell->value == value) return FALSE; if (value) { AdgEntity *table = (AdgEntity *) adg_table_cell_get_table(table_cell); alignment = (AdgEntity *) adg_alignment_new_explicit(0.5, 0); g_object_ref_sink(alignment); adg_entity_set_parent(alignment, table); adg_container_add((AdgContainer *) alignment, value); } if (table_cell->value) { alignment = adg_entity_get_parent(table_cell->value); adg_container_remove((AdgContainer *) alignment, table_cell->value); g_object_unref(alignment); } table_cell->value = value; return TRUE; }
int main(int argc, char *argv[]) { AdgAlignment *alignment; adg_test_init(&argc, &argv); adg_test_add_object_checks("/adg/alignment/type/object", ADG_TYPE_ALIGNMENT); adg_test_add_entity_checks("/adg/alignment/type/entity", ADG_TYPE_ALIGNMENT); adg_test_add_container_checks("/adg/alignment/type/container", ADG_TYPE_ALIGNMENT); alignment = adg_alignment_new_explicit(0.5, 0.5); adg_container_add(ADG_CONTAINER(alignment), ADG_ENTITY(adg_logo_new())); adg_test_add_global_space_checks("/adg/alignment/behavior/global-space", alignment); alignment = adg_alignment_new_explicit(0.5, 0.5); adg_container_add(ADG_CONTAINER(alignment), ADG_ENTITY(adg_logo_new())); adg_test_add_local_space_checks("/adg/alignment/behavior/local-space", alignment); g_test_add_func("/adg/alignment/property/factor", _adg_property_factor); return g_test_run(); }