Пример #1
0
static VALUE
rbgio_ginitable_new_body(struct rbgio_ginitable_new_data *data)
{
        rb_iterate(rb_each,
                   data->rbparameters,
                   rbgio_ginitiable_new_parameters_initialize,
                   (VALUE)data);

        return (VALUE)g_initable_newv(G_TYPE_FROM_CLASS(data->gclass),
                                      data->n_parameters,
                                      data->parameters,
                                      data->cancellable,
                                      &data->error);
}
Пример #2
0
GObject *
rbgio_ginitable_new(GType type, VALUE parameters, VALUE cancellable)
{
        static ID s_id_length;
        GError *error = NULL;
        GObject *object;
        struct rbgio_ginitable_new_data data;

        if (s_id_length == 0)
                s_id_length = rb_intern("length");

        if (!g_type_is_a(type, G_TYPE_OBJECT))
                rb_raise(rb_eArgError,
                         "%s is not a descendant of GObject",
                         g_type_name(type));

        if (NIL_P(parameters)) {
                object = g_initable_newv(type,
                                         0,
                                         NULL,
                                         RVAL2GCANCELLABLE(cancellable),
                                         &error);
                if (object == NULL)
                        rbgio_raise_error(error);

                return object;
        } else {
                parameters = rb_convert_type(parameters,
                                             T_HASH,
                                             "Hash",
                                             "to_hash");
        }

        data.gclass = G_OBJECT_CLASS(g_type_class_ref(type));
        data.cancellable = RVAL2GCANCELLABLE(cancellable);
        data.rbparameters = parameters;
        data.index = 0;
        data.n_parameters = RVAL2GUINT(rb_funcall(parameters, s_id_length, 0));
        data.parameters = g_new(GParameter, data.n_parameters);
        data.error = NULL;

        object = (GObject *)rb_ensure(rbgio_ginitable_new_body, (VALUE)&data,
                                      rbgio_ginitable_new_ensure, (VALUE)&data);
        if (object == NULL)
                rbgio_raise_error(data.error);

        return object;
}
Пример #3
0
/**
 * uca_plugin_manager_get_camerav:
 * @manager: A #UcaPluginManager
 * @name: Name of the camera module, that maps to libuca<name>.so
 * @n_parameters: number of parameters in @parameters
 * @parameters: (array length=n_parameters): the parameters to use to construct
 *      the camera
 * @error: Location for a #GError or %NULL
 *
 * Create a new camera instance with camera @name.
 *
 * Returns: (transfer full): A new #UcaCamera object.
 * Since: 1.2
 */
UcaCamera *
uca_plugin_manager_get_camerav (UcaPluginManager *manager,
                                const gchar *name,
                                guint n_parameters,
                                GParameter *parameters,
                                GError **error)
{
    UcaPluginManagerPrivate *priv;
    UcaCamera *camera;
    GType type;

    g_return_val_if_fail (UCA_IS_PLUGIN_MANAGER (manager) && (name != NULL), NULL);

    priv = manager->priv;
    type = get_camera_type (priv, name, error);

    if (type == G_TYPE_NONE)
        return NULL;

    camera = (UcaCamera *) g_initable_newv (type, n_parameters, parameters,
                                            NULL, error);

    return camera;
}