/* * Copyright © 2011 Red Hat Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * Authors: Benjamin Otte */ #include "config.h" #include "gtkcssstylepropertyprivate.h" #include "gtkintl.h" enum { PROP_0, PROP_ID, }; G_DEFINE_TYPE (GtkCssStyleProperty, _gtk_css_style_property, GTK_TYPE_STYLE_PROPERTY) static void gtk_css_style_property_constructed (GObject *object) { GtkCssStyleProperty *property = GTK_CSS_STYLE_PROPERTY (object); GtkCssStylePropertyClass *klass = GTK_CSS_STYLE_PROPERTY_GET_CLASS (property); property->id = klass->style_properties->len; g_ptr_array_add (klass->style_properties, property); G_OBJECT_CLASS (_gtk_css_style_property_parent_class)->constructed (object); } static void gtk_css_style_property_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { GtkCssStyleProperty *property = GTK_CSS_STYLE_PROPERTY (object); switch (prop_id) { case PROP_ID: g_value_set_boolean (value, property->id); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } static void _gtk_css_style_property_class_init (GtkCssStylePropertyClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->constructed = gtk_css_style_property_constructed; object_class->get_property = gtk_css_style_property_get_property; g_object_class_install_property (object_class, PROP_ID, g_param_spec_uint ("id", P_("ID"), P_("The numeric id for quick access"), 0, G_MAXUINT, 0, G_PARAM_READABLE)); klass->style_properties = g_ptr_array_new (); } static void _gtk_css_style_property_init (GtkCssStyleProperty *style_property) { } /** * _gtk_css_style_property_get_n_properties: * * Gets the number of style properties. This number can increase when new * theme engines are loaded. Shorthand properties are not included here. * * Returns: The number of style properties. **/ guint _gtk_css_style_property_get_n_properties (void) { GtkCssStylePropertyClass *klass; klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY); return klass->style_properties->len; } /** * _gtk_css_style_property_lookup_by_id: * @id: the id of the property * * Gets the style property with the given id. All style properties (but not * shorthand properties) are indexable by id so that it's easy to use arrays * when doing style lookups. * * Returns: (transfer none): The style property with the given id **/ GtkCssStyleProperty * _gtk_css_style_property_lookup_by_id (guint id) { GtkCssStylePropertyClass *klass; klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY); return g_ptr_array_index (klass->style_properties, id); } /** * _gtk_css_style_property_get_id: * @property: the property * * Gets the id for the given property. IDs are used to allow using arrays * for style lookups. * * Returns: The id of the property **/ guint _gtk_css_style_property_get_id (GtkCssStyleProperty *property) { g_return_val_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property), 0); return property->id; } gboolean _gtk_css_style_property_is_inherit (GtkCssStyleProperty *property) { g_return_val_if_fail (property != NULL, FALSE); return GTK_STYLE_PROPERTY (property)->flags & GTK_STYLE_PROPERTY_INHERIT ? TRUE : FALSE; } const GValue * _gtk_css_style_property_get_initial_value (GtkCssStyleProperty *property) { g_return_val_if_fail (property != NULL, NULL); return >K_STYLE_PROPERTY (property)->initial_value; }