/** * adg_dim_set_pos_from_pair: * @dim: an #AdgDim * @pos: the coordinates pair of the position point * * Convenient function to set the #AdgDim:pos property using a * pair instead of explicit coordinates. * * Since: 1.0 **/ void adg_dim_set_pos_from_pair(AdgDim *dim, const CpmlPair *pos) { g_return_if_fail(pos != NULL); adg_dim_set_pos_explicit(dim, pos->x, pos->y); }
static void _adg_property_pos(void) { AdgDim *dim; AdgModel *model; AdgPoint *origin, *explicit_point, *model_point; AdgPoint *pos; dim = ADG_DIM(adg_rdim_new()); model = ADG_MODEL(adg_path_new()); origin = adg_point_new(); explicit_point = adg_point_new(); model_point = adg_point_new(); adg_point_set_pair_explicit(origin, 0, 0); adg_point_set_pair_explicit(explicit_point, 123, 321); adg_model_set_named_pair(model, "named-pair", (CpmlPair *) explicit_point); adg_point_set_pair_from_model(model_point, model, "named-pair"); /* Ensure ADG does not consider an explicit point equals to * a point bound to a named pair with the same coordinates */ g_assert_false(adg_point_equal(explicit_point, model_point)); pos = adg_dim_get_pos(dim); g_assert_null(pos); /* Using the public APIs */ adg_dim_set_pos_explicit(dim, 0, 0); pos = adg_dim_get_pos(dim); g_assert_true(adg_point_equal(pos, origin)); adg_dim_set_pos(dim, NULL); pos = adg_dim_get_pos(dim); g_assert_null(pos); adg_dim_set_pos(dim, explicit_point); pos = adg_dim_get_pos(dim); g_assert_true(adg_point_equal(pos, explicit_point)); adg_dim_set_pos_from_model(dim, model, "dummy"); pos = adg_dim_get_pos(dim); g_assert_nonnull(pos); adg_dim_set_pos_from_model(dim, model, "named-pair"); pos = adg_dim_get_pos(dim); g_assert_true(adg_point_equal(pos, model_point)); /* Using GObject property methods */ g_object_set(dim, "pos", origin, NULL); g_object_get(dim, "pos", &pos, NULL); g_assert_true(adg_point_equal(pos, origin)); adg_point_destroy(pos); g_object_set(dim, "pos", NULL, NULL); g_object_get(dim, "pos", &pos, NULL); g_assert_null(pos); g_object_set(dim, "pos", explicit_point, NULL); g_object_get(dim, "pos", &pos, NULL); g_assert_true(adg_point_equal(pos, explicit_point)); adg_point_destroy(pos); adg_dim_set_pos_from_model(dim, model, "dummy"); g_object_get(dim, "pos", &pos, NULL); g_assert_nonnull(pos); adg_point_destroy(pos); g_object_set(dim, "pos", model_point, NULL); g_object_get(dim, "pos", &pos, NULL); g_assert_true(adg_point_equal(pos, model_point)); adg_point_destroy(pos); adg_point_destroy(origin); adg_point_destroy(explicit_point); adg_point_destroy(model_point); adg_entity_destroy(ADG_ENTITY(dim)); g_object_unref(model); }