API: Add gtk_style_context_get_section()

This API allows querying the location where style properties were
defined. An example implementation will be committed soon.
This commit is contained in:
Benjamin Otte 2012-01-11 05:17:35 +01:00
parent 6962b49a99
commit a815f10299
4 changed files with 47 additions and 0 deletions

View File

@ -5689,6 +5689,7 @@ gtk_style_context_get_style
gtk_style_context_get_style_property
gtk_style_context_get_style_valist
gtk_style_context_get_valist
gtk_style_context_get_section
gtk_style_context_get_color
gtk_style_context_get_background_color
gtk_style_context_get_border_color

View File

@ -2551,6 +2551,7 @@ gtk_style_context_get_parent
gtk_style_context_get_path
gtk_style_context_get_property
gtk_style_context_get_screen
gtk_style_context_get_section
gtk_style_context_get_state
gtk_style_context_get_style
gtk_style_context_get_style_property

View File

@ -1399,6 +1399,48 @@ gtk_style_context_remove_provider_for_screen (GdkScreen *screen,
}
}
/**
* gtk_style_context_get_section:
* @context: a #GtkStyleContext
* @property: style property name
*
* Queries the location in the CSS where @property was defined for the
* current @context. Note that the state to be queried is taken from
* gtk_style_context_get_state().
*
* If the location is not available, %NULL will be returned. The
* location might not be available for various reasons, such as the
* property being overridden, @property not naming a supported CSS
* property or tracking of definitions being disabled for performance
* reasons.
*
* Shorthand CSS properties cannot be queried for a location and will
* always return %NULL.
*
* Returns: %NULL or the section where value was defined
**/
GtkCssSection *
gtk_style_context_get_section (GtkStyleContext *context,
const gchar *property)
{
GtkStyleContextPrivate *priv;
GtkStyleProperty *prop;
StyleData *data;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
g_return_val_if_fail (property != NULL, NULL);
priv = context->priv;
g_return_val_if_fail (priv->widget_path != NULL, NULL);
prop = _gtk_style_property_lookup (property);
if (!GTK_IS_CSS_STYLE_PROPERTY (prop))
return NULL;
data = style_data_lookup (context, gtk_style_context_get_state (context));
return _gtk_css_computed_values_get_section (data->store, _gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (prop)));
}
static const GValue *
gtk_style_context_query_func (guint id,
gpointer values)

View File

@ -25,6 +25,7 @@
#define __GTK_STYLE_CONTEXT_H__
#include <glib-object.h>
#include <gtk/gtkcsssection.h>
#include <gtk/gtkstyleprovider.h>
#include <gtk/gtkwidgetpath.h>
#include <gtk/gtkborder.h>
@ -717,6 +718,8 @@ void gtk_style_context_remove_provider (GtkStyleContext *context,
void gtk_style_context_save (GtkStyleContext *context);
void gtk_style_context_restore (GtkStyleContext *context);
GtkCssSection * gtk_style_context_get_section (GtkStyleContext *context,
const gchar *property);
void gtk_style_context_get_property (GtkStyleContext *context,
const gchar *property,
GtkStateFlags state,