[gtk+/wip/actor: 17/42] stylecontext: Change css matcher initialization
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/actor: 17/42] stylecontext: Change css matcher initialization
- Date: Tue, 18 Dec 2012 13:27:28 +0000 (UTC)
commit b07f928005279d05147274d44e58d16b52e575e6
Author: Benjamin Otte <otte redhat com>
Date: Wed Dec 12 19:00:06 2012 +0100
stylecontext: Change css matcher initialization
2 changes:
(1) Add an optional css_matcher_init vfunc
(2) Allow create_query_path vfunc to fail
Both of these are required for the actors work.
gtk/gtkstylecontext.c | 45 +++++++++++++++++++++++++++++++++--------
gtk/gtkstylecontextprivate.h | 2 +
gtk/gtkwidget.c | 8 +++++++
3 files changed, 46 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index d3f9e74..8a3655c 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -700,10 +700,17 @@ gtk_style_context_set_cascade (GtkStyleContext *context,
gtk_style_context_cascade_changed (cascade, context);
}
+static gboolean
+default_init_css_matcher (GtkCssMatcher *matcher,
+ gpointer data)
+{
+ return FALSE;
+}
+
static GtkWidgetPath *
default_create_query_path (gpointer data)
{
- return gtk_widget_path_new ();
+ return NULL;
}
static const GtkWidgetPath *
@@ -733,6 +740,7 @@ default_get_widget_type (gpointer data)
static const GtkStyleContextSource default_source = {
FALSE,
TRUE,
+ default_init_css_matcher,
default_create_query_path,
default_get_path,
default_do_nothing,
@@ -975,6 +983,9 @@ create_query_path (GtkStyleContext *context,
priv = context->priv;
path = priv->source->create_query_path (priv->source_data);
+ if (path == NULL)
+ return NULL;
+
pos = gtk_widget_path_length (path) - 1;
/* Set widget regions */
@@ -1014,13 +1025,27 @@ build_properties (GtkStyleContext *context,
priv = context->priv;
- path = create_query_path (context, info);
lookup = _gtk_css_lookup_new (relevant_changes);
+ if (priv->source->css_matcher_init (&matcher, priv->source_data))
+ {
+ _gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
+ &matcher,
+ lookup);
+ }
+ else
+ {
+ path = create_query_path (context, info);
- if (_gtk_css_matcher_init (&matcher, path, info->state_flags))
- _gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
- &matcher,
- lookup);
+ if (path)
+ {
+ if (_gtk_css_matcher_init (&matcher, path, info->state_flags))
+ _gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
+ &matcher,
+ lookup);
+
+ gtk_widget_path_free (path);
+ }
+ }
_gtk_css_lookup_resolve (lookup,
GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
@@ -1028,7 +1053,6 @@ build_properties (GtkStyleContext *context,
priv->parent ? style_data_lookup (priv->parent)->store : NULL);
_gtk_css_lookup_free (lookup);
- gtk_widget_path_free (path);
}
static StyleData *
@@ -1602,6 +1626,7 @@ widget_path_get_widget_type (gpointer data)
static const GtkStyleContextSource widget_path_source = {
FALSE,
TRUE,
+ default_init_css_matcher,
widget_path_create_query_path,
widget_path_get_path,
default_do_nothing,
@@ -2331,7 +2356,8 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context,
{
GtkWidgetPath *widget_path = priv->source->create_query_path (priv->source_data);
- if (gtk_style_provider_get_style_property (GTK_STYLE_PROVIDER (priv->cascade),
+ if (widget_path &&
+ gtk_style_provider_get_style_property (GTK_STYLE_PROVIDER (priv->cascade),
widget_path,
state, pspec, &pcache->value))
{
@@ -2380,7 +2406,8 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context,
return &pcache->value;
}
- gtk_widget_path_free (widget_path);
+ if (widget_path)
+ gtk_widget_path_free (widget_path);
}
/* not supplied by any provider, revert to default */
diff --git a/gtk/gtkstylecontextprivate.h b/gtk/gtkstylecontextprivate.h
index 2f846d4..9227323 100644
--- a/gtk/gtkstylecontextprivate.h
+++ b/gtk/gtkstylecontextprivate.h
@@ -31,6 +31,8 @@ struct _GtkStyleContextSource {
guint internal_to_gtk :1;
guint instant_invalidate :1;
+ gboolean (* css_matcher_init) (GtkCssMatcher *matcher,
+ gpointer data);
GtkWidgetPath * (* create_query_path) (gpointer data);
const GtkWidgetPath * (* get_path) (gpointer data);
void (* invalidate) (gpointer data);
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 46e3fae..342e78a 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -13945,6 +13945,13 @@ gtk_widget_get_path (GtkWidget *widget)
return widget->priv->path;
}
+static gboolean
+gtk_widget_source_init_css_matcher (GtkCssMatcher *matcher,
+ gpointer data)
+{
+ return FALSE;
+}
+
static GtkWidgetPath *
gtk_widget_source_create_query_path (gpointer widget)
{
@@ -14022,6 +14029,7 @@ gtk_widget_source_no_destroy (gpointer data)
static const GtkStyleContextSource gtk_widget_source = {
TRUE,
FALSE,
+ gtk_widget_source_init_css_matcher,
gtk_widget_source_create_query_path,
gtk_widget_source_get_path,
gtk_widget_source_invalidate,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]