[gtk+] API: Add gtk_style_context_get_section()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] API: Add gtk_style_context_get_section()
- Date: Wed, 11 Jan 2012 14:53:58 +0000 (UTC)
commit a815f102993a6a6f12179f9a5bd666980855e8be
Author: Benjamin Otte <otte redhat com>
Date: Wed Jan 11 05:17:35 2012 +0100
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.
docs/reference/gtk/gtk3-sections.txt | 1 +
gtk/gtk.symbols | 1 +
gtk/gtkstylecontext.c | 42 ++++++++++++++++++++++++++++++++++
gtk/gtkstylecontext.h | 3 ++
4 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 6f04025..f614e68 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -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
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 8a83719..59df40c 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -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
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 2c1d8eb..a39cf5a 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -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)
diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h
index afdeb7b..9a76c54 100644
--- a/gtk/gtkstylecontext.h
+++ b/gtk/gtkstylecontext.h
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]