[gtk/wip/otte/css: 4/7] style context: Remove parent relationship
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/css: 4/7] style context: Remove parent relationship
- Date: Wed, 5 Feb 2020 03:05:22 +0000 (UTC)
commit 416182a20d062d5865916f86909354ec85d00dd1
Author: Timm Bäder <mail baedert org>
Date: Mon Feb 3 10:59:21 2020 +0100
style context: Remove parent relationship
We don't have foreign drawing anymore, so we don't need this.
gtk/gtkstylecontext.c | 95 ---------------------------------------------------
gtk/gtkstylecontext.h | 3 --
gtk/gtktexthandle.c | 9 ++---
gtk/gtkwidget.c | 10 ------
gtk/gtkwindow.c | 7 ++--
5 files changed, 6 insertions(+), 118 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 47e96f7ea5..d9415723cf 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -111,7 +111,6 @@ struct _GtkStyleContextPrivate
guint cascade_changed_id;
GtkStyleCascade *cascade;
- GtkStyleContext *parent;
GtkCssNode *cssnode;
GSList *saved_nodes;
};
@@ -120,7 +119,6 @@ typedef struct _GtkStyleContextPrivate GtkStyleContextPrivate;
enum {
PROP_0,
PROP_DISPLAY,
- PROP_PARENT,
LAST_PROP
};
@@ -157,19 +155,6 @@ gtk_style_context_class_init (GtkStyleContextClass *klass)
GDK_TYPE_DISPLAY,
GTK_PARAM_READWRITE);
- /**
- * GtkStyleContext:parent:
- *
- * Sets or gets the style context’s parent. See gtk_style_context_set_parent()
- * for details.
- */
- properties[PROP_PARENT] =
- g_param_spec_object ("parent",
- P_("Parent"),
- P_("The parent style context"),
- GTK_TYPE_STYLE_CONTEXT,
- GTK_PARAM_READWRITE);
-
g_object_class_install_properties (object_class, LAST_PROP, properties);
}
@@ -239,15 +224,6 @@ gtk_style_context_init (GtkStyleContext *context)
_gtk_settings_get_style_cascade (gtk_settings_get_for_display
(priv->display), 1));
}
-static void
-gtk_style_context_clear_parent (GtkStyleContext *context)
-{
- GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
-
- if (priv->parent)
- g_object_unref (priv->parent);
-}
-
static void
gtk_style_context_finalize (GObject *object)
{
@@ -257,7 +233,6 @@ gtk_style_context_finalize (GObject *object)
while (priv->saved_nodes)
gtk_style_context_pop_style_node (context);
- gtk_style_context_clear_parent (context);
gtk_style_context_set_cascade (context, NULL);
if (priv->cssnode)
@@ -279,9 +254,6 @@ gtk_style_context_impl_set_property (GObject *object,
case PROP_DISPLAY:
gtk_style_context_set_display (context, g_value_get_object (value));
break;
- case PROP_PARENT:
- gtk_style_context_set_parent (context, g_value_get_object (value));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -302,9 +274,6 @@ gtk_style_context_impl_get_property (GObject *object,
case PROP_DISPLAY:
g_value_set_object (value, priv->display);
break;
- case PROP_PARENT:
- g_value_set_object (value, priv->parent);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -667,70 +636,6 @@ gtk_style_context_get_scale (GtkStyleContext *context)
return _gtk_style_cascade_get_scale (priv->cascade);
}
-/**
- * gtk_style_context_set_parent:
- * @context: a #GtkStyleContext
- * @parent: (allow-none): the new parent or %NULL
- *
- * Sets the parent style context for @context. The parent style
- * context is used to implement
- * [inheritance](http://www.w3.org/TR/css3-cascade/#inheritance)
- * of properties.
- *
- * If you are using a #GtkStyleContext returned from
- * gtk_widget_get_style_context(), the parent will be set for you.
- **/
-void
-gtk_style_context_set_parent (GtkStyleContext *context,
- GtkStyleContext *parent)
-{
- GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
-
- g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
- g_return_if_fail (parent == NULL || GTK_IS_STYLE_CONTEXT (parent));
-
- if (priv->parent == parent)
- return;
-
- if (parent)
- {
- GtkCssNode *root = gtk_style_context_get_root (context);
- g_object_ref (parent);
-
- if (gtk_css_node_get_parent (root) == NULL)
- gtk_css_node_set_parent (root, gtk_style_context_get_root (parent));
- }
- else
- {
- gtk_css_node_set_parent (gtk_style_context_get_root (context), NULL);
- }
-
- gtk_style_context_clear_parent (context);
-
- priv->parent = parent;
-
- g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_PARENT]);
-}
-
-/**
- * gtk_style_context_get_parent:
- * @context: a #GtkStyleContext
- *
- * Gets the parent context set via gtk_style_context_set_parent().
- * See that function for details.
- *
- * Returns: (nullable) (transfer none): the parent context or %NULL
- **/
-GtkStyleContext *
-gtk_style_context_get_parent (GtkStyleContext *context)
-{
- GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
-
- g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
-
- return priv->parent;
-}
-
/*
* gtk_style_context_save_to_node:
* @context: a #GtkStyleContext
diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h
index 991c7a5a3d..0c4c0c1ebb 100644
--- a/gtk/gtkstylecontext.h
+++ b/gtk/gtkstylecontext.h
@@ -883,9 +883,6 @@ void gtk_style_context_set_scale (GtkStyleContext *context,
GDK_AVAILABLE_IN_ALL
gint gtk_style_context_get_scale (GtkStyleContext *context);
-GDK_AVAILABLE_IN_ALL
-void gtk_style_context_set_parent (GtkStyleContext *context,
- GtkStyleContext *parent);
GDK_AVAILABLE_IN_ALL
GtkStyleContext *gtk_style_context_get_parent (GtkStyleContext *context);
diff --git a/gtk/gtktexthandle.c b/gtk/gtktexthandle.c
index 3f993920ba..a4d86bbe24 100644
--- a/gtk/gtktexthandle.c
+++ b/gtk/gtktexthandle.c
@@ -200,7 +200,6 @@ _gtk_text_handle_ensure_widget (GtkTextHandle *handle,
if (!priv->windows[pos].widget)
{
GtkWidget *widget, *window;
- GtkStyleContext *context;
GtkEventController *controller;
widget = gtk_gizmo_new (I_("cursor-handle"), NULL, NULL, snapshot_func, NULL);
@@ -220,16 +219,14 @@ _gtk_text_handle_ensure_widget (GtkTextHandle *handle,
priv->toplevel = window = gtk_widget_get_ancestor (priv->parent, GTK_TYPE_WINDOW);
_gtk_window_add_popover (GTK_WINDOW (window), widget, priv->parent, FALSE);
- context = gtk_widget_get_style_context (widget);
- gtk_style_context_set_parent (context, gtk_widget_get_style_context (priv->parent));
if (pos == GTK_TEXT_HANDLE_POSITION_SELECTION_END)
{
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
+ gtk_widget_add_style_class (widget, GTK_STYLE_CLASS_BOTTOM);
if (priv->mode == GTK_TEXT_HANDLE_MODE_CURSOR)
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_INSERTION_CURSOR);
+ gtk_widget_add_style_class (widget, GTK_STYLE_CLASS_INSERTION_CURSOR);
}
else
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
+ gtk_widget_add_style_class (widget, GTK_STYLE_CLASS_TOP);
}
return priv->windows[pos].widget;
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 503208e17f..1121753f6e 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -2630,8 +2630,6 @@ gtk_widget_unparent (GtkWidget *widget)
/* Unset BACKDROP since we are no longer inside a toplevel window */
gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_BACKDROP);
- if (priv->context)
- gtk_style_context_set_parent (priv->context, NULL);
gtk_css_node_set_parent (priv->cssnode, NULL);
_gtk_widget_update_parent_muxer (widget);
@@ -6129,10 +6127,6 @@ gtk_widget_reposition_after (GtkWidget *widget,
previous_sibling ? previous_sibling->priv->cssnode : NULL);
}
- if (priv->context)
- gtk_style_context_set_parent (priv->context,
- _gtk_widget_get_style_context (parent));
-
_gtk_widget_update_parent_muxer (widget);
if (parent->priv->children_observer)
@@ -11255,10 +11249,6 @@ gtk_widget_get_style_context (GtkWidget *widget)
display = _gtk_widget_get_display (widget);
if (display)
gtk_style_context_set_display (priv->context, display);
-
- if (priv->parent)
- gtk_style_context_set_parent (priv->context,
- _gtk_widget_get_style_context (priv->parent));
}
return priv->context;
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index bb251e3205..c4e4446728 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -3243,7 +3243,6 @@ void
gtk_window_set_attached_to (GtkWindow *window,
GtkWidget *attach_widget)
{
- GtkStyleContext *context;
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
g_return_if_fail (GTK_IS_WINDOW (window));
@@ -3262,11 +3261,11 @@ gtk_window_set_attached_to (GtkWindow *window,
}
/* Update the style, as the widget path might change. */
- context = gtk_widget_get_style_context (GTK_WIDGET (window));
if (priv->attach_widget)
- gtk_style_context_set_parent (context, gtk_widget_get_style_context (priv->attach_widget));
+ gtk_css_node_set_parent (gtk_widget_get_css_node (GTK_WIDGET (window)),
+ gtk_widget_get_css_node (priv->attach_widget));
else
- gtk_style_context_set_parent (context, NULL);
+ gtk_css_node_set_parent (gtk_widget_get_css_node (GTK_WIDGET (window)), NULL);
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_ATTACHED_TO]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]