/** * clutter_container_class_find_child_property: * @klass: a #GObjectClass implementing the #ClutterContainer interface. * @property_name: a property name. * * Looks up the #GParamSpec for a child property of @klass. * * Return value: (transfer none): The #GParamSpec for the property or %NULL * if no such property exist. * * Since: 0.8 */ GParamSpec * clutter_container_class_find_child_property (GObjectClass *klass, const gchar *property_name) { ClutterContainerIface *iface; GObjectClass *child_class; GParamSpec *pspec; g_return_val_if_fail (G_IS_OBJECT_CLASS (klass), NULL); g_return_val_if_fail (property_name != NULL, NULL); g_return_val_if_fail (g_type_is_a (G_TYPE_FROM_CLASS (klass), CLUTTER_TYPE_CONTAINER), NULL); iface = g_type_interface_peek (klass, CLUTTER_TYPE_CONTAINER); g_return_val_if_fail (iface != NULL, NULL); if (iface->child_meta_type == G_TYPE_INVALID) return NULL; child_class = g_type_class_ref (iface->child_meta_type); pspec = g_object_class_find_property (child_class, property_name); g_type_class_unref (child_class); return pspec; }
/** * goo_canvas_item_model_class_find_child_property: * @mclass: a #GObjectClass * @property_name: the name of the child property to find * * This function is only intended to be used when implementing new canvas * item models, specifically layout container item models such as * #GooCanvasTableModel. * * It finds a child property of a canvas item class by name. * * Returns: (type GObject.ParamSpec) (transfer none): The #GParamSpec of the child * property or %NULL if @class has no child property with that name. */ GParamSpec* goo_canvas_item_model_class_find_child_property (GObjectClass *mclass, const gchar *property_name) { g_return_val_if_fail (G_IS_OBJECT_CLASS (mclass), NULL); g_return_val_if_fail (property_name != NULL, NULL); return g_param_spec_pool_lookup (_goo_canvas_item_model_child_property_pool, property_name, G_OBJECT_CLASS_TYPE (mclass), TRUE); }
void tp_contacts_mixin_class_init (GObjectClass *obj_cls, glong offset) { g_assert (G_IS_OBJECT_CLASS (obj_cls)); g_type_set_qdata (G_OBJECT_CLASS_TYPE (obj_cls), TP_CONTACTS_MIXIN_CLASS_OFFSET_QUARK, GINT_TO_POINTER (offset)); tp_dbus_properties_mixin_implement_interface (obj_cls, TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACTS, tp_presence_mixin_get_contacts_dbus_property, NULL, known_contacts_props); }
/** * clutter_binding_pool_get_for_class: * @klass: a #GObjectClass pointer * * Retrieves the #ClutterBindingPool for the given #GObject class * and, eventually, creates it. This function is a wrapper around * clutter_binding_pool_new() and uses the class type name as the * unique name for the binding pool. * * Calling this function multiple times will return the same * #ClutterBindingPool. * * A binding pool for a class can also be retrieved using * clutter_binding_pool_find() with the class type name: * * |[ * pool = clutter_binding_pool_find (G_OBJECT_TYPE_NAME (instance)); * ]| * * Return value: (transfer none): the binding pool for the given class. * The returned #ClutterBindingPool is owned by Clutter and should not * be freed directly * * Since: 1.0 */ ClutterBindingPool * clutter_binding_pool_get_for_class (gpointer klass) { ClutterBindingPool *pool; g_return_val_if_fail (G_IS_OBJECT_CLASS (klass), NULL); if (G_UNLIKELY (key_class_bindings == 0)) key_class_bindings = g_quark_from_static_string ("clutter-bindings-set"); pool = g_dataset_id_get_data (klass, key_class_bindings); if (pool) return pool; pool = clutter_binding_pool_new (G_OBJECT_CLASS_NAME (klass)); g_dataset_id_set_data_full (klass, key_class_bindings, pool, g_object_unref); return pool; }
void tp_properties_mixin_class_init (GObjectClass *obj_cls, glong offset, const TpPropertySignature *signatures, guint num_properties, TpPropertiesSetFunc set_func) { TpPropertiesMixinClass *mixin_cls; g_assert (G_IS_OBJECT_CLASS (obj_cls)); g_type_set_qdata (G_OBJECT_CLASS_TYPE (obj_cls), TP_PROPERTIES_MIXIN_CLASS_OFFSET_QUARK, GINT_TO_POINTER (offset)); mixin_cls = TP_PROPERTIES_MIXIN_CLASS (obj_cls); mixin_cls->signatures = signatures; mixin_cls->num_props = num_properties; mixin_cls->set_properties = set_func; }
/** * goo_canvas_item_model_class_install_child_property: * @mclass: a #GObjectClass * @property_id: the id for the property * @pspec: the #GParamSpec for the property * * This function is only intended to be used when implementing new canvas * item models, specifically layout container item models such as * #GooCanvasTableModel. * * It installs a child property on a canvas item class. **/ void goo_canvas_item_model_class_install_child_property (GObjectClass *mclass, guint property_id, GParamSpec *pspec) { g_return_if_fail (G_IS_OBJECT_CLASS (mclass)); g_return_if_fail (G_IS_PARAM_SPEC (pspec)); g_return_if_fail (property_id > 0); if (g_param_spec_pool_lookup (_goo_canvas_item_model_child_property_pool, pspec->name, G_OBJECT_CLASS_TYPE (mclass), FALSE)) { g_warning (G_STRLOC ": class `%s' already contains a child property named `%s'", G_OBJECT_CLASS_NAME (mclass), pspec->name); return; } g_param_spec_ref (pspec); g_param_spec_sink (pspec); pspec->param_id = property_id; g_param_spec_pool_insert (_goo_canvas_item_model_child_property_pool, pspec, G_OBJECT_CLASS_TYPE (mclass)); }
static void _midgard_query_select_validable_iface_validate (MidgardValidable *iface, GError **error) { g_return_if_fail (iface != NULL); MidgardQuerySelect *self = MIDGARD_QUERY_SELECT (iface); MIDGARD_QUERY_EXECUTOR (self)->priv->is_valid = FALSE; GError *err = NULL; MidgardQueryStorage *storage = MIDGARD_QUERY_EXECUTOR (self)->priv->storage; GObjectClass *klass = (GObjectClass *) storage->priv->klass; if (klass == NULL || (!G_IS_OBJECT_CLASS(klass))) { g_set_error (error, MIDGARD_VALIDATION_ERROR, MIDGARD_VALIDATION_ERROR_TYPE_INVALID, "Invalid '%s' classname associated with QueryStorage", storage->priv->classname); return; } const gchar *table = midgard_core_class_get_table (MIDGARD_DBOBJECT_CLASS (klass)); /* Class table */ if (!table) { g_set_error (error, MIDGARD_VALIDATION_ERROR, MIDGARD_VALIDATION_ERROR_LOCATION_INVALID, "No SQL table defined for '%s' class", G_OBJECT_CLASS_NAME (klass)); return; } /* Storage */ if (!storage) { g_set_error (error, MIDGARD_VALIDATION_ERROR, MIDGARD_VALIDATION_ERROR_LOCATION_INVALID, "No QueryStorage associated with QuerySelect"); return; } if (storage->priv->klass && !storage->priv->klass->dbpriv->add_fields_to_select_statement) { g_set_error (error, MIDGARD_VALIDATION_ERROR, MIDGARD_VALIDATION_ERROR_INTERNAL, "'%s' DBObjectClass doesn't provide select statement.", G_OBJECT_CLASS_NAME (storage->priv->klass)); return; } /* Limit */ if (MIDGARD_QUERY_EXECUTOR (self)->priv->limit == 0) { g_set_error (error, MIDGARD_VALIDATION_ERROR, MIDGARD_VALIDATION_ERROR_VALUE_INVALID, "Invalid limit value (0). Expected > 0"); return; } /* Orders */ GSList *l = NULL; for (l = MIDGARD_QUERY_EXECUTOR (self)->priv->orders; l != NULL; l = l->next) { qso *_so = (qso*) l->data; gboolean asc = FALSE; gchar *lorder = g_ascii_strdown (_so->order_type, -1); if (g_str_equal (lorder, "asc")) { _so->asc = TRUE; } else if (g_str_equal (lorder, "desc")) { _so->asc = FALSE; } else { g_set_error (error, MIDGARD_VALIDATION_ERROR, MIDGARD_VALIDATION_ERROR_VALUE_INVALID, "Invalid order type '%s'. Expected ASC or DESC", _so->order_type); g_free (lorder); return; } g_free (lorder); } /* Gather all objects required for execution */ GSList *o_list = NULL; o_list = g_slist_prepend (o_list, storage); _get_all_constraints (self, NULL, &o_list); for (l = o_list; l != NULL; l = l->next) { if (!midgard_validable_is_valid (MIDGARD_VALIDABLE (l->data))) { midgard_validable_validate (MIDGARD_VALIDABLE (l->data), &err); if (err) { g_propagate_error (error, err); g_slist_free (o_list); return; } } } if (o_list) g_slist_free (o_list); MIDGARD_QUERY_EXECUTOR (self)->priv->is_valid = TRUE; return; }