[gtk/wip/baedert/for-master: 24/33] style context: Remove parent relationship
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master: 24/33] style context: Remove parent relationship
- Date: Tue, 4 Feb 2020 11:30:22 +0000 (UTC)
commit 6291aff892617c7413b1a49b4b1b72588ec84e67
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 ++--
testsuite/gtk/stylecontext.c | 2 -
6 files changed, 6 insertions(+), 120 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index cd0d628942..3b57b72412 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -116,7 +116,6 @@ struct _GtkStyleContextPrivate
guint cascade_changed_id;
GtkStyleCascade *cascade;
- GtkStyleContext *parent;
GtkCssNode *cssnode;
GSList *saved_nodes;
@@ -127,7 +126,6 @@ typedef struct _GtkStyleContextPrivate GtkStyleContextPrivate;
enum {
PROP_0,
PROP_DISPLAY,
- PROP_PARENT,
LAST_PROP
};
@@ -206,19 +204,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);
}
@@ -288,15 +273,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)
{
@@ -306,7 +282,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)
@@ -328,9 +303,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;
@@ -351,9 +323,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;
@@ -744,70 +713,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 331241d78a..ce06109a75 100644
--- a/gtk/gtkstylecontext.h
+++ b/gtk/gtkstylecontext.h
@@ -886,9 +886,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 a810a89f87..c5c3d7ec65 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -2646,8 +2646,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);
@@ -6145,10 +6143,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)
@@ -11267,10 +11261,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 18242de6e3..0187cbbf25 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -3242,7 +3242,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));
@@ -3261,11 +3260,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]);
}
diff --git a/testsuite/gtk/stylecontext.c b/testsuite/gtk/stylecontext.c
index a4d4d44435..84971b6a2c 100644
--- a/testsuite/gtk/stylecontext.c
+++ b/testsuite/gtk/stylecontext.c
@@ -72,8 +72,6 @@ test_widget_path_parent (void)
parent = gtk_style_context_new ();
context = gtk_style_context_new ();
- gtk_style_context_set_parent (context, parent);
-
g_object_unref (parent);
g_object_unref (context);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]