Example #1
0
PyObject *py_ped_constraint_new_from_max(PyObject *s, PyObject *args) {
    PyObject *in_max = NULL;
    PedGeometry *out_max = NULL;
    PedConstraint *constraint = NULL;
    _ped_Constraint *ret = NULL;

    if (!PyArg_ParseTuple(args, "O!", &_ped_Geometry_Type_obj, &in_max)) {
        return NULL;
    }

    out_max = _ped_Geometry2PedGeometry(in_max);
    if (out_max == NULL) {
        return NULL;
    }

    constraint = ped_constraint_new_from_max(out_max);
    if (constraint) {
        ret = PedConstraint2_ped_Constraint(constraint);
    }
    else {
        PyErr_SetString(CreateException, "Could not create new constraint from max");
        return NULL;
    }

    ped_constraint_destroy(constraint);

    return (PyObject *) ret;
}
Example #2
0
static PedConstraint*
_get_primary_constraint (PedDisk* disk)
{
        PedGeometry     max_geom;
	if (!ped_geometry_init (&max_geom, disk->dev, 1, disk->dev->length - 1))
		return NULL;
        return ped_constraint_new_from_max (&max_geom);
}
Example #3
0
static PedConstraint*
_get_constraint (const PedDevice* dev)
{
	PedGeometry	max;

	ped_geometry_init (&max, dev, 1, dev->length - 1);
	return ped_constraint_new_from_max (&max);
}
Example #4
0
PedPartition* create_and_add_partition(PedDisk* disk, PedPartitionType type,
                                       const PedFileSystemType* fs,
                                       PedSector start, PedSector end)
{
    PedPartition* part = ped_partition_new (disk, type, fs, start, end);
    g_return_val_if_fail(part != NULL, FALSE);
    PedGeometry* geom = ped_geometry_new (disk->dev, start, end - start + 1);
    g_assert(geom != NULL);
    PedConstraint* constraint = ped_constraint_new_from_max (geom);
    g_assert(constraint != NULL);
    ped_disk_add_partition(disk, part, constraint);
    ped_constraint_destroy (constraint);
    ped_geometry_destroy (geom);
    return part;
}