forked from AuroraMiddleware/gtk
API: Add GtkStyleContext::parent
We need this for proper support of CSS inherit.
This commit is contained in:
parent
aa4925480d
commit
b50d2b74d7
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
* <ulink url="http://www.w3.org/TR/css3-cascade/#inheritance>
|
||||
* inheritance</ulink> of properties.
|
||||
*
|
||||
* If you are using a #GtkStyleContext returned from
|
||||
* gtk_widget_get_style_context(), the parent will be set for you.
|
||||
*
|
||||
* Since: 3.4
|
||||
**/
|
||||
void
|
||||
gtk_style_context_set_parent (GtkStyleContext *context,
|
||||
GtkStyleContext *parent)
|
||||
{
|
||||
GtkStyleContextPrivate *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
g_return_if_fail (parent == NULL || GTK_IS_STYLE_CONTEXT (parent));
|
||||
|
||||
priv = context->priv;
|
||||
|
||||
if (priv->parent == parent)
|
||||
return;
|
||||
|
||||
if (parent)
|
||||
g_object_ref (parent);
|
||||
|
||||
if (priv->parent)
|
||||
g_object_unref (priv->parent);
|
||||
|
||||
priv->parent = parent;
|
||||
|
||||
g_object_notify (G_OBJECT (context), "parent");
|
||||
gtk_style_context_invalidate (context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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: (transfer none): the parent context or %NULL
|
||||
*
|
||||
* Since: 3.4
|
||||
**/
|
||||
GtkStyleContext *
|
||||
gtk_style_context_get_parent (GtkStyleContext *context)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
|
||||
|
||||
return context->priv->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_style_context_save:
|
||||
* @context: a #GtkStyleContext
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user