[gtk+/wip/actor: 22/25] cssmatcher: Redo the fallback detection
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/actor: 22/25] cssmatcher: Redo the fallback detection
- Date: Fri, 21 Dec 2012 22:53:43 +0000 (UTC)
commit a96677d6400b8da28e33b897ef77d1d1f9fdec5a
Author: Benjamin Otte <otte redhat com>
Date: Tue Dec 18 12:37:58 2012 +0100
cssmatcher: Redo the fallback detection
We need to do the fallback detection when we initialize the matcher, not
when we first decide what matcher to create. This is necessary to be
able to switch from actor matching to widget path matching for
submatchers.
gtk/actors/gtkcssactor.c | 31 +-----------------------
gtk/gtkcssmatcher.c | 57 ++++++++++++++++++++++++++++++++++++++-----
gtk/gtkcssmatcherprivate.h | 4 +-
3 files changed, 53 insertions(+), 39 deletions(-)
---
diff --git a/gtk/actors/gtkcssactor.c b/gtk/actors/gtkcssactor.c
index 04953c6..09a8bb5 100644
--- a/gtk/actors/gtkcssactor.c
+++ b/gtk/actors/gtkcssactor.c
@@ -31,7 +31,6 @@
#include "gtkstylecontext.h"
#include "gtkstylecontextprivate.h"
#include "gtktypebuiltins.h"
-#include "gtkwidgetactorprivate.h"
#include "gtkwidgetprivate.h"
struct _GtkCssActorPrivate {
@@ -233,38 +232,10 @@ _gtk_css_actor_get_style_context (GtkCssActor *actor)
}
static gboolean
-actor_needs_to_use_widget_path (GtkActor *actor)
-{
- GtkWidget *widget, *parent;
-
- if (!GTK_IS_WIDGET_ACTOR (actor))
- return FALSE;
-
- widget = _gtk_actor_get_widget (actor);
- if (widget == NULL)
- return FALSE;
-
- parent = gtk_widget_get_parent (widget);
- if (parent == NULL)
- return FALSE;
-
- if (GTK_CONTAINER_GET_CLASS (parent)->get_path_for_child ==
- GTK_CONTAINER_CLASS(g_type_class_peek (GTK_TYPE_CONTAINER))->get_path_for_child)
- return FALSE;
-
- return TRUE;
-}
-
-static gboolean
gtk_css_actor_source_init_css_matcher (GtkCssMatcher *matcher,
gpointer actor)
{
- if (actor_needs_to_use_widget_path (actor))
- return FALSE;
-
- _gtk_css_matcher_actor_init (matcher, actor);
-
- return TRUE;
+ return _gtk_css_matcher_actor_init (matcher, actor);
}
static GtkWidgetPath *
diff --git a/gtk/gtkcssmatcher.c b/gtk/gtkcssmatcher.c
index 536e511..288b45f 100644
--- a/gtk/gtkcssmatcher.c
+++ b/gtk/gtkcssmatcher.c
@@ -19,7 +19,10 @@
#include "gtkcssmatcherprivate.h"
+#include "gtkcontainer.h"
+#include "gtkwidget.h"
#include "gtkwidgetpath.h"
+#include "actors/gtkwidgetactorprivate.h"
/* GTK_CSS_MATCHER_WIDGET_PATH */
@@ -436,8 +439,14 @@ gtk_css_matcher_actor_get_parent (GtkCssMatcher *matcher,
{
if (GTK_IS_CSS_BOX (parent))
{
- _gtk_css_matcher_actor_init (matcher, GTK_CSS_BOX (parent));
- return TRUE;
+ if (_gtk_css_matcher_actor_init (matcher, GTK_CSS_BOX (parent)))
+ return TRUE;
+ if (_gtk_css_matcher_init (matcher,
+ gtk_widget_get_path (_gtk_actor_get_widget (parent)),
+ 0))
+ return TRUE;
+
+ return FALSE;
}
}
@@ -456,8 +465,14 @@ gtk_css_matcher_actor_get_previous (GtkCssMatcher *matcher,
{
if (GTK_IS_CSS_BOX (prev))
{
- _gtk_css_matcher_actor_init (matcher, GTK_CSS_BOX (prev));
- return TRUE;
+ if (_gtk_css_matcher_actor_init (matcher, GTK_CSS_BOX (prev)))
+ return TRUE;
+ if (_gtk_css_matcher_init (matcher,
+ gtk_widget_get_path (_gtk_actor_get_widget (prev)),
+ 0))
+ return TRUE;
+
+ return FALSE;
}
}
@@ -573,13 +588,41 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_ACTOR = {
FALSE
};
-void
+static gboolean
+actor_needs_to_use_widget_path (GtkActor *actor)
+{
+ GtkWidget *widget, *parent;
+
+ if (!GTK_IS_WIDGET_ACTOR (actor))
+ return FALSE;
+
+ widget = _gtk_actor_get_widget (actor);
+ if (widget == NULL)
+ return FALSE;
+
+ parent = gtk_widget_get_parent (widget);
+ if (parent == NULL)
+ return FALSE;
+
+ if (GTK_CONTAINER_GET_CLASS (parent)->get_path_for_child ==
+ GTK_CONTAINER_CLASS(g_type_class_peek (GTK_TYPE_CONTAINER))->get_path_for_child)
+ return FALSE;
+
+ return TRUE;
+}
+
+gboolean
_gtk_css_matcher_actor_init (GtkCssMatcher *matcher,
GtkCssBox *box)
{
- g_return_if_fail (matcher != NULL);
- g_return_if_fail (GTK_IS_CSS_BOX (box));
+ g_return_val_if_fail (matcher != NULL, FALSE);
+ g_return_val_if_fail (GTK_IS_CSS_BOX (box), FALSE);
+
+ if (actor_needs_to_use_widget_path (GTK_ACTOR (box)))
+ return FALSE;
matcher->actor.klass = >K_CSS_MATCHER_ACTOR;
matcher->actor.actor = GTK_ACTOR (box);
+
+ return TRUE;
}
diff --git a/gtk/gtkcssmatcherprivate.h b/gtk/gtkcssmatcherprivate.h
index 2d99eb8..1bb3f88 100644
--- a/gtk/gtkcssmatcherprivate.h
+++ b/gtk/gtkcssmatcherprivate.h
@@ -88,8 +88,8 @@ void _gtk_css_matcher_any_init (GtkCssMatcher *match
void _gtk_css_matcher_superset_init (GtkCssMatcher *matcher,
const GtkCssMatcher *subset,
GtkCssChange relevant);
-void _gtk_css_matcher_actor_init (GtkCssMatcher *matcher,
- GtkCssBox *box);
+gboolean _gtk_css_matcher_actor_init (GtkCssMatcher *matcher,
+ GtkCssBox *box) G_GNUC_WARN_UNUSED_RESULT;
static inline gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]