diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index 3bfde4faef..55049f7409 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -5680,6 +5680,7 @@ gtk_style_context_add_provider_for_screen gtk_style_context_get gtk_style_context_get_direction gtk_style_context_get_junction_sides +gtk_style_context_set_parent gtk_style_context_get_path gtk_style_context_get_property gtk_style_context_get_screen @@ -5712,6 +5713,7 @@ gtk_style_context_restore gtk_style_context_save gtk_style_context_set_direction gtk_style_context_set_junction_sides +gtk_style_context_set_parent gtk_style_context_set_path gtk_style_context_add_class gtk_style_context_remove_class diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index 7891d3cc53..f852ff29e1 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -2539,6 +2539,7 @@ gtk_style_context_get_font gtk_style_context_get_junction_sides gtk_style_context_get_margin gtk_style_context_get_padding +gtk_style_context_get_parent gtk_style_context_get_path gtk_style_context_get_property gtk_style_context_get_screen @@ -2570,6 +2571,7 @@ gtk_style_context_scroll_animations gtk_style_context_set_background gtk_style_context_set_direction gtk_style_context_set_junction_sides +gtk_style_context_set_parent gtk_style_context_set_path gtk_style_context_set_screen gtk_style_context_set_state diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index f4bd0d00f7..21205c3ee8 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -368,6 +368,7 @@ struct _GtkStyleContextPrivate GList *providers; GList *providers_last; + GtkStyleContext *parent; GtkWidgetPath *widget_path; GHashTable *style_data; GSList *info_stack; @@ -388,7 +389,8 @@ struct _GtkStyleContextPrivate enum { PROP_0, PROP_SCREEN, - PROP_DIRECTION + PROP_DIRECTION, + PROP_PARENT }; enum { @@ -450,6 +452,21 @@ gtk_style_context_class_init (GtkStyleContextClass *klass) GTK_TYPE_TEXT_DIRECTION, GTK_TEXT_DIR_LTR, GTK_PARAM_READWRITE)); + /** + * GtkStyleContext:parent: + * + * Sets or gets the style context's parent. See gtk_style_context_set_parent() + * for details. + * + * Since: 3.4 + */ + g_object_class_install_property (object_class, + PROP_PARENT, + g_param_spec_object ("parent", + P_("Parent"), + P_("The parent style context"), + GTK_TYPE_STYLE_CONTEXT, + GTK_PARAM_READWRITE)); g_type_class_add_private (object_class, sizeof (GtkStyleContextPrivate)); } @@ -807,6 +824,8 @@ gtk_style_context_finalize (GObject *object) style_context = GTK_STYLE_CONTEXT (object); priv = style_context->priv; + gtk_style_context_set_parent (style_context, NULL); + if (priv->widget_path) gtk_widget_path_free (priv->widget_path); @@ -849,6 +868,10 @@ gtk_style_context_impl_set_property (GObject *object, gtk_style_context_set_direction (style_context, g_value_get_enum (value)); break; + case PROP_PARENT: + gtk_style_context_set_parent (style_context, + g_value_get_object (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -875,6 +898,9 @@ gtk_style_context_impl_get_property (GObject *object, case PROP_DIRECTION: g_value_set_enum (value, priv->direction); break; + case PROP_PARENT: + g_value_set_object (value, priv->parent); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1661,6 +1687,66 @@ gtk_style_context_get_path (GtkStyleContext *context) return priv->widget_path; } +/** + * 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 + * priv->parent; +} + /** * gtk_style_context_save: * @context: a #GtkStyleContext diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 0dfb4769c6..afdeb7b686 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -740,6 +740,10 @@ void gtk_style_context_set_path (GtkStyleContext *context, GtkWidgetPath *path); const GtkWidgetPath * gtk_style_context_get_path (GtkStyleContext *context); +void gtk_style_context_set_parent (GtkStyleContext *context, + GtkStyleContext *parent); +GtkStyleContext *gtk_style_context_get_parent (GtkStyleContext *context); + GList * gtk_style_context_list_classes (GtkStyleContext *context); void gtk_style_context_add_class (GtkStyleContext *context,