本文整理汇总了C++中G_PARAM_SPEC_VALUE_TYPE函数的典型用法代码示例。如果您正苦于以下问题:C++ G_PARAM_SPEC_VALUE_TYPE函数的具体用法?C++ G_PARAM_SPEC_VALUE_TYPE怎么用?C++ G_PARAM_SPEC_VALUE_TYPE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_PARAM_SPEC_VALUE_TYPE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GOM_ASTRING_TO_GSTRING_RETURN
/* void setAttribute (in nsIAtom name, in AString newValue); */
NS_IMETHODIMP
xgGtkElement::SetAttribute (nsIAtom *name, const nsAString &newValue)
{
GOM_ASTRING_TO_GSTRING_RETURN (value, newValue, NS_ERROR_INVALID_ARG);
GParamSpec *spec;
guint signal_id;
if (!Resolve (name, &spec, &signal_id)) {
return NS_ERROR_FAILURE;
}
if (!spec) {
return NS_ERROR_FAILURE;
}
GError *error = NULL;
GValue gval = { 0 };
if (G_TYPE_FUNDAMENTAL (G_PARAM_SPEC_VALUE_TYPE (spec)) == G_TYPE_OBJECT) {
g_warning (GOM_LOC ("Attribute %s.%s is a %s, which a string cannot be converted to"),
G_OBJECT_TYPE_NAME (mObject), spec->name,
g_type_name (G_PARAM_SPEC_VALUE_TYPE (spec)));
return NS_ERROR_FAILURE;
} else if (gtk_builder_value_from_string (NULL, spec, value, &gval, &error)) {
g_object_set_property (mObject, spec->name, &gval);
g_value_unset (&gval);
} else {
g_warning (GOM_LOC ("Could not get value from string: '%s'"), value);
return NS_ERROR_FAILURE;
}
return NS_OK;
}
示例2: e_bind_properties_transfer
static void
e_bind_properties_transfer (GObject *src_object,
GParamSpec *src_pspec,
GObject *dst_object,
GParamSpec *dst_pspec,
GlideBindingTransform transform,
gpointer user_data)
{
const gchar *src_name;
const gchar *dst_name;
gboolean result;
GValue src_value = { 0, };
GValue dst_value = { 0, };
src_name = g_param_spec_get_name (src_pspec);
dst_name = g_param_spec_get_name (dst_pspec);
g_value_init (&src_value, G_PARAM_SPEC_VALUE_TYPE (src_pspec));
g_object_get_property (src_object, src_name, &src_value);
g_value_init (&dst_value, G_PARAM_SPEC_VALUE_TYPE (dst_pspec));
result = (*transform) (&src_value, &dst_value, user_data);
g_value_unset (&src_value);
g_return_if_fail (result);
g_param_value_validate (dst_pspec, &dst_value);
g_object_set_property (dst_object, dst_name, &dst_value);
g_value_unset (&dst_value);
}
示例3: rg_set_child_property
static VALUE
rg_set_child_property(VALUE self, VALUE child,
VALUE prop_name, VALUE val)
{
GParamSpec* pspec;
const char* name;
if (SYMBOL_P(prop_name)) {
name = rb_id2name(SYM2ID(prop_name));
} else {
StringValue(prop_name);
name = StringValuePtr(prop_name);
}
pspec = goo_canvas_item_class_find_child_property(G_OBJECT_GET_CLASS(RVAL2GOBJ(self)), name);
if (!pspec)
rb_raise(rb_eRuntimeError, "No such child property: %s", name);
#define _SET_PROP_FOR_TYPE(gtype, ctype, val) \
case gtype: \
goo_canvas_item_set_child_properties(SELF(self), SELF(child), name, (ctype)(val), NULL); \
break;
switch (G_TYPE_FUNDAMENTAL(G_PARAM_SPEC_VALUE_TYPE(pspec))) {
_SET_PROP_FOR_TYPE(G_TYPE_CHAR, gchar, NUM2INT(val));
_SET_PROP_FOR_TYPE(G_TYPE_UCHAR, guchar, NUM2INT(val));
_SET_PROP_FOR_TYPE(G_TYPE_BOOLEAN, gboolean, RTEST(val));
_SET_PROP_FOR_TYPE(G_TYPE_INT, gint, NUM2INT(val));
_SET_PROP_FOR_TYPE(G_TYPE_UINT, guint, NUM2UINT(val));
_SET_PROP_FOR_TYPE(G_TYPE_LONG, glong, NUM2LONG(val));
_SET_PROP_FOR_TYPE(G_TYPE_ULONG, gulong, NUM2ULONG(val));
_SET_PROP_FOR_TYPE(G_TYPE_INT64, gint64, rbglib_num_to_int64(val));
_SET_PROP_FOR_TYPE(G_TYPE_UINT64, guint64, rbglib_num_to_uint64(val));
_SET_PROP_FOR_TYPE(G_TYPE_ENUM, gint, rbgobj_get_enum(val, G_PARAM_SPEC_VALUE_TYPE(pspec)));
_SET_PROP_FOR_TYPE(G_TYPE_FLAGS, guint, rbgobj_get_flags(val, G_PARAM_SPEC_VALUE_TYPE(pspec)));
_SET_PROP_FOR_TYPE(G_TYPE_FLOAT, gfloat, NUM2DBL(val));
_SET_PROP_FOR_TYPE(G_TYPE_DOUBLE, gdouble, NUM2DBL(val));
case G_TYPE_STRING:
{
if (SYMBOL_P(val))
val = rb_funcall(val, rb_intern("to_s"), 0);
goo_canvas_item_set_child_properties(SELF(self), SELF(child), name, StringValuePtr(val), NULL);
break;
}
default:
g_warning("rb_goo_canvas_item_set_child_property: unsupported type: %s\n", g_type_name(G_PARAM_SPEC_VALUE_TYPE(pspec)));
return Qnil;
}
#undef _SET_PROP_FOR_TYPE
G_CHILD_ADD(child, val);
return self;
}
示例4: set_sysfs_uint
static void
set_sysfs_uint (const char *iface,
GObject *obj,
const char *obj_prop,
const char *dir,
const char *sysfs_prop,
gboolean default_if_zero,
gboolean user_hz_compensate)
{
char *path, *s;
GParamSpec *pspec;
GValue val = { 0 };
guint32 uval = 0;
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (obj), obj_prop);
g_return_if_fail (pspec != NULL);
/* Get the property's value */
g_value_init (&val, G_PARAM_SPEC_VALUE_TYPE (pspec));
g_object_get_property (obj, obj_prop, &val);
if (G_VALUE_HOLDS_BOOLEAN (&val))
uval = g_value_get_boolean (&val) ? 1 : 0;
else if (G_VALUE_HOLDS_UINT (&val)) {
uval = g_value_get_uint (&val);
/* zero means "unspecified" for some NM properties but isn't in the
* allowed kernel range, so reset the property to the default value.
*/
if (default_if_zero && uval == 0) {
g_value_unset (&val);
g_value_init (&val, G_PARAM_SPEC_VALUE_TYPE (pspec));
g_param_value_set_default (pspec, &val);
uval = g_value_get_uint (&val);
}
} else
g_assert_not_reached ();
g_value_unset (&val);
/* Linux kernel bridge interfaces use 'centiseconds' for time-based values.
* In reality it's not centiseconds, but depends on HZ and USER_HZ, which
* is almost always works out to be a multiplier of 100, so we can assume
* centiseconds. See clock_t_to_jiffies().
*/
if (user_hz_compensate)
uval *= 100;
path = g_strdup_printf ("/sys/class/net/%s/%s/%s", iface, dir, sysfs_prop);
s = g_strdup_printf ("%u", uval);
/* FIXME: how should failure be handled? */
nm_utils_do_sysctl (path, s);
g_free (path);
g_free (s);
}
示例5: tidy_stylable_set_property_internal
static inline void
tidy_stylable_set_property_internal (TidyStylable *stylable,
GParamSpec *pspec,
const GValue *value,
GObjectNotifyQueue *nqueue)
{
GValue tmp_value = { 0, };
g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
if (!g_value_transform (value, &tmp_value))
g_warning ("unable to set property `%s' of type `%s' from value of type `%s'",
pspec->name,
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
G_VALUE_TYPE_NAME (value));
else if (g_param_value_validate (pspec, &tmp_value) &&
!(pspec->flags & G_PARAM_LAX_VALIDATION))
{
gchar *contents = g_strdup_value_contents (value);
g_warning ("value \"%s\" of type `%s' is invalid or out of range for property `%s' of type `%s'",
contents,
G_VALUE_TYPE_NAME (value),
pspec->name,
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
g_free (contents);
}
else
{
TidyStyle *style = tidy_stylable_get_style (stylable);
gchar *real_name;
real_name = g_strconcat (g_param_spec_get_qdata (pspec, quark_real_owner),
"::",
pspec->name,
NULL);
if (!tidy_style_has_property (style, real_name))
tidy_style_add_property (style, real_name,
G_PARAM_SPEC_VALUE_TYPE (pspec));
tidy_style_set_property (style, real_name, &tmp_value);
g_object_notify_queue_add (G_OBJECT (stylable), nqueue, pspec);
g_free (real_name);
}
g_value_unset (&tmp_value);
}
示例6: gitg_data_binding_create
static GitgDataBinding *
gitg_data_binding_create(gpointer source, gchar const *source_property,
gpointer dest, gchar const *dest_property,
GitgDataBindingConversion source_to_dest,
GitgDataBindingConversion dest_to_source,
gpointer userdata,
GitgDataBindingFlags flags)
{
g_return_val_if_fail(G_IS_OBJECT(source), NULL);
g_return_val_if_fail(G_IS_OBJECT(dest), NULL);
GObjectClass *sclass = G_OBJECT_GET_CLASS(source);
GObjectClass *dclass = G_OBJECT_GET_CLASS(dest);
GParamSpec *sspec = g_object_class_find_property(sclass, source_property);
if (!sspec)
{
g_warning("No such source property found: %s", source_property);
return NULL;
}
GParamSpec *dspec = g_object_class_find_property(dclass, dest_property);
if (!dspec)
{
g_warning("No such dest property found: %s", dest_property);
return NULL;
}
GitgDataBinding *binding = g_slice_new0(GitgDataBinding);
binding->flags = flags;
binding_fill(&binding->source, source, source_property, G_PARAM_SPEC_VALUE_TYPE(sspec), source_to_dest, userdata);
binding_fill(&binding->dest, dest, dest_property, G_PARAM_SPEC_VALUE_TYPE(dspec), dest_to_source, userdata);
binding_connect(binding, &binding->source);
if (flags & GITG_DATA_BINDING_MUTUAL)
binding_connect(binding, &binding->dest);
g_object_weak_ref(binding->source.object, (GWeakNotify)on_data_binding_destroy, binding);
g_object_weak_ref(binding->dest.object, (GWeakNotify)on_data_binding_destroy, binding);
/* initial value */
on_data_binding_changed(binding->source.object, NULL, binding);
return binding;
}
示例7: commit_option
static void
commit_option (NMDevice *device, NMSetting *setting, const Option *option, gboolean slave)
{
int ifindex = nm_device_get_ifindex (device);
GParamSpec *pspec;
GValue val = G_VALUE_INIT;
guint32 uval = 0;
gs_free char *value = NULL;
g_assert (setting);
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), option->name);
g_assert (pspec);
/* Get the property's value */
g_value_init (&val, G_PARAM_SPEC_VALUE_TYPE (pspec));
g_object_get_property ((GObject *) setting, option->name, &val);
if (G_VALUE_HOLDS_BOOLEAN (&val))
uval = g_value_get_boolean (&val) ? 1 : 0;
else if (G_VALUE_HOLDS_UINT (&val)) {
uval = g_value_get_uint (&val);
/* zero means "unspecified" for some NM properties but isn't in the
* allowed kernel range, so reset the property to the default value.
*/
if (option->default_if_zero && uval == 0) {
g_value_unset (&val);
g_value_init (&val, G_PARAM_SPEC_VALUE_TYPE (pspec));
g_param_value_set_default (pspec, &val);
uval = g_value_get_uint (&val);
}
/* Linux kernel bridge interfaces use 'centiseconds' for time-based values.
* In reality it's not centiseconds, but depends on HZ and USER_HZ, which
* is almost always works out to be a multiplier of 100, so we can assume
* centiseconds. See clock_t_to_jiffies().
*/
if (option->user_hz_compensate)
uval *= 100;
} else
g_assert_not_reached ();
g_value_unset (&val);
value = g_strdup_printf ("%u", uval);
if (slave)
nm_platform_slave_set_option (ifindex, option->sysname, value);
else
nm_platform_master_set_option (ifindex, option->sysname, value);
}
示例8: create_payloader_for_caps
static GstElement *
create_payloader_for_caps (const GstCaps * caps)
{
GList *payloader_list, *filtered_list, *l;
GstElementFactory *payloader_factory = NULL;
GstElement *payloader = NULL;
payloader_list =
gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_PAYLOADER,
GST_RANK_NONE);
filtered_list =
gst_element_factory_list_filter (payloader_list, caps, GST_PAD_SRC,
FALSE);
for (l = filtered_list; l != NULL && payloader_factory == NULL; l = l->next) {
payloader_factory = GST_ELEMENT_FACTORY (l->data);
if (gst_element_factory_get_num_pad_templates (payloader_factory) != 2)
payloader_factory = NULL;
}
if (payloader_factory != NULL) {
payloader = gst_element_factory_create (payloader_factory, NULL);
}
if (payloader) {
GParamSpec *pspec;
pspec =
g_object_class_find_property (G_OBJECT_GET_CLASS (payloader),
"config-interval");
if (pspec != NULL && G_PARAM_SPEC_VALUE_TYPE (pspec) == G_TYPE_UINT) {
g_object_set (payloader, "config-interval", 1, NULL);
}
pspec =
g_object_class_find_property (G_OBJECT_GET_CLASS (payloader),
"picture-id-mode");
if (pspec != NULL && G_TYPE_IS_ENUM (G_PARAM_SPEC_VALUE_TYPE (pspec))) {
/* Set picture id so that remote peer can determine continuity if */
/* there are lost FEC packets and if it has to NACK them */
g_object_set (payloader, "picture-id-mode", PICTURE_ID_15_BIT, NULL);
}
}
gst_plugin_feature_list_free (filtered_list);
gst_plugin_feature_list_free (payloader_list);
return payloader;
}
示例9: _params_setup
static VALUE
_params_setup(VALUE arg, struct param_setup_arg *param_setup_arg)
{
guint index;
VALUE name, val;
GParamSpec* pspec;
index = param_setup_arg->index;
if (index >= param_setup_arg->param_size)
rb_raise(rb_eArgError, "too many parameters");
name = rb_ary_entry(arg, 0);
val = rb_ary_entry(arg, 1);
if (SYMBOL_P(name))
param_setup_arg->params[index].name = rb_id2name(SYM2ID(name));
else
param_setup_arg->params[index].name = StringValuePtr(name);
pspec = g_object_class_find_property(
param_setup_arg->gclass,
param_setup_arg->params[index].name);
if (!pspec)
rb_raise(rb_eArgError, "No such property: %s",
param_setup_arg->params[index].name);
g_value_init(&(param_setup_arg->params[index].value),
G_PARAM_SPEC_VALUE_TYPE(pspec));
rbgobj_rvalue_to_gvalue(val, &(param_setup_arg->params[index].value));
param_setup_arg->index++;
return Qnil;
}
示例10: vo_get_optional_arg
/* Looking for construct-time optional output args. Append them to out.
*/
static void *
vo_get_optional_arg( const char *name, PElement *value, Vo *vo, PElement *out )
{
GParamSpec *pspec;
VipsArgumentClass *argument_class;
VipsArgumentInstance *argument_instance;
if( vips_object_get_argument( vo->object, name,
&pspec, &argument_class, &argument_instance ) )
return( NULL );
if( !(argument_class->flags & VIPS_ARGUMENT_REQUIRED) &&
(argument_class->flags & VIPS_ARGUMENT_OUTPUT) &&
argument_instance->assigned ) {
GType type = G_PARAM_SPEC_VALUE_TYPE( pspec );
GValue gvalue = { 0 };
PElement lhs;
if( !heap_list_add( vo->rc->heap, out, &lhs ) )
return( value );
g_value_init( &gvalue, type );
g_object_get_property( G_OBJECT( vo->object ), name, &gvalue );
if( !heap_gvalue_to_ip( &gvalue, &lhs ) ) {
g_value_unset( &gvalue );
return( value );
}
g_value_unset( &gvalue );
(void) heap_list_next( out );
}
return( NULL );
}
示例11: vo_get_required_output
/* Looking for required output args ... append to out.
*/
static void *
vo_get_required_output( VipsObject *object, GParamSpec *pspec,
VipsArgumentClass *argument_class,
VipsArgumentInstance *argument_instance, Vo *vo, PElement *out )
{
if( (argument_class->flags & VIPS_ARGUMENT_REQUIRED) &&
(argument_class->flags & VIPS_ARGUMENT_OUTPUT) &&
argument_instance->assigned ) {
const char *name = g_param_spec_get_name( pspec );
GType type = G_PARAM_SPEC_VALUE_TYPE( pspec );
PElement lhs;
GValue value = { 0 };
if( !heap_list_add( vo->rc->heap, out, &lhs ) )
return( object );
g_value_init( &value, type );
g_object_get_property( G_OBJECT( object ), name, &value );
if( !heap_gvalue_to_ip( &value, &lhs ) ) {
g_value_unset( &value );
return( object );
}
g_value_unset( &value );
(void) heap_list_next( out );
}
return( NULL );
}
示例12: rg_style_get_property
static VALUE
rg_style_get_property(VALUE self, VALUE prop_name)
{
GParamSpec* pspec = NULL;
const char* name;
if (SYMBOL_P(prop_name)) {
name = rb_id2name(SYM2ID(prop_name));
} else {
name = RVAL2CSTR(prop_name);
}
pspec = gtk_widget_class_find_style_property((GtkWidgetClass*)g_type_class_ref(RVAL2GTYPE(self)), name);
if (!pspec)
rb_raise(rb_eval_string("GLib::NoPropertyError"), "No such property: %s", name);
else {
// FIXME: use rb_ensure to call g_value_unset()
GValue gval = G_VALUE_INIT;
VALUE ret;
g_value_init(&gval, G_PARAM_SPEC_VALUE_TYPE(pspec));
gtk_widget_style_get_property(GTK_WIDGET(RVAL2GOBJ(self)), name, &gval);
ret = GVAL2RVAL(&gval);
g_value_unset(&gval);
return ret;
}
}
示例13: gst_controlled_property_new
/*
* gst_controlled_property_new:
* @object: for which object the controlled property should be set up
* @name: the name of the property to be controlled
*
* Private method which initializes the fields of a new controlled property
* structure.
*
* Returns: a freshly allocated structure or %NULL
*/
static GstControlledProperty *
gst_controlled_property_new (GObject * object, const gchar * name)
{
GstControlledProperty *prop = NULL;
GParamSpec *pspec;
GST_INFO ("trying to put property '%s' under control", name);
/* check if the object has a property of that name */
if ((pspec =
g_object_class_find_property (G_OBJECT_GET_CLASS (object), name))) {
GST_DEBUG (" psec->flags : 0x%08x", pspec->flags);
/* check if this param is witable && controlable && !construct-only */
g_return_val_if_fail ((pspec->flags & (G_PARAM_WRITABLE |
GST_PARAM_CONTROLLABLE | G_PARAM_CONSTRUCT_ONLY)) ==
(G_PARAM_WRITABLE | GST_PARAM_CONTROLLABLE), NULL);
if ((prop = g_slice_new (GstControlledProperty))) {
prop->pspec = pspec;
prop->name = pspec->name;
prop->csource = NULL;
prop->disabled = FALSE;
memset (&prop->last_value, 0, sizeof (GValue));
g_value_init (&prop->last_value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
}
} else {
GST_WARNING ("class '%s' has no property '%s'", G_OBJECT_TYPE_NAME (object),
name);
}
return prop;
}
示例14: tidy_stylable_set_valist
static void
tidy_stylable_set_valist (TidyStylable *stylable,
const gchar *first_property_name,
va_list varargs)
{
GObjectNotifyQueue *nqueue;
const gchar *name;
g_object_ref (stylable);
nqueue = g_object_notify_queue_freeze (G_OBJECT (stylable),
&property_notify_context);
name = first_property_name;
while (name)
{
GParamSpec *pspec;
GValue value = { 0, };
gchar *error;
pspec = tidy_stylable_find_property (stylable, name);
if (!pspec)
{
g_warning ("%s: no style property named `%s' found for class `%s'",
G_STRLOC,
name,
g_type_name (G_OBJECT_TYPE (stylable)));
break;
}
if (!(pspec->flags & G_PARAM_WRITABLE) ||
(pspec->flags & G_PARAM_CONSTRUCT_ONLY))
{
g_warning ("Style property `%s' of class `%s' is not writable",
pspec->name,
g_type_name (G_OBJECT_TYPE (stylable)));
break;
}
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
G_VALUE_COLLECT (&value, varargs, 0, &error);
if (error)
{
g_warning ("%s: %s", G_STRLOC, error);
g_free (error);
g_value_unset (&value);
break;
}
tidy_stylable_set_property_internal (stylable, pspec, &value, nqueue);
g_value_unset (&value);
name = va_arg (varargs, gchar*);
}
g_object_notify_queue_thaw (G_OBJECT (stylable), nqueue);
g_object_unref (stylable);
}
示例15: gobj_mark
static void
gobj_mark(gpointer ptr)
{
GObject* gobj = ptr;
guint n_properties;
GParamSpec** properties;
GValue gval = {0,};
guint i;
properties = g_object_class_list_properties(G_OBJECT_GET_CLASS(gobj), &n_properties);
for (i = 0; i < n_properties; i++) {
GParamSpec* pspec = properties[i];
GType value_type = G_PARAM_SPEC_VALUE_TYPE(pspec);
if (G_TYPE_FUNDAMENTAL(value_type) != G_TYPE_OBJECT) continue;
if (!(pspec->flags & G_PARAM_READABLE)) continue;
/* FIXME: exclude types that doesn't have identity. */
{
g_value_init(&gval, value_type);
g_object_get_property(gobj, pspec->name, &gval);
rbgobj_gc_mark_gvalue(&gval);
g_value_unset(&gval);
}
}
g_free(properties);
}