mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-09-21 14:24:19 +00:00
window: Add gtk_widget_class_set_css_name()
This is to replace using class names as CSS names.
This commit is contained in:
parent
244d9ffeee
commit
408920d438
@ -5602,6 +5602,8 @@ gtk_widget_get_action_group
|
|||||||
gtk_widget_get_path
|
gtk_widget_get_path
|
||||||
gtk_widget_get_style_context
|
gtk_widget_get_style_context
|
||||||
gtk_widget_reset_style
|
gtk_widget_reset_style
|
||||||
|
gtk_widget_class_get_css_name
|
||||||
|
gtk_widget_class_set_css_name
|
||||||
|
|
||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
gtk_requisition_new
|
gtk_requisition_new
|
||||||
|
@ -487,6 +487,7 @@ struct _GtkWidgetClassPrivate
|
|||||||
GtkWidgetTemplate *template;
|
GtkWidgetTemplate *template;
|
||||||
GType accessible_type;
|
GType accessible_type;
|
||||||
AtkRole accessible_role;
|
AtkRole accessible_role;
|
||||||
|
const char *css_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -4365,6 +4366,9 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
|
|||||||
priv->cssnode = gtk_css_widget_node_new (widget);
|
priv->cssnode = gtk_css_widget_node_new (widget);
|
||||||
gtk_css_node_set_state (priv->cssnode, GTK_STATE_FLAG_DIR_LTR);
|
gtk_css_node_set_state (priv->cssnode, GTK_STATE_FLAG_DIR_LTR);
|
||||||
/* need to set correct type here, and only class has the correct type here */
|
/* need to set correct type here, and only class has the correct type here */
|
||||||
|
if (GTK_WIDGET_GET_CLASS (widget)->priv->css_name)
|
||||||
|
gtk_css_node_set_name (priv->cssnode, GTK_WIDGET_GET_CLASS (widget)->priv->css_name);
|
||||||
|
else
|
||||||
gtk_css_node_set_widget_type (priv->cssnode, G_TYPE_FROM_CLASS (g_class));
|
gtk_css_node_set_widget_type (priv->cssnode, G_TYPE_FROM_CLASS (g_class));
|
||||||
|
|
||||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
|
||||||
@ -16312,6 +16316,47 @@ gtk_widget_clear_path (GtkWidget *widget)
|
|||||||
g_object_set_qdata (G_OBJECT (widget), quark_widget_path, NULL);
|
g_object_set_qdata (G_OBJECT (widget), quark_widget_path, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_widget_class_set_css_name:
|
||||||
|
* @widget_class: class to set the name on
|
||||||
|
* @name: name to use
|
||||||
|
*
|
||||||
|
* Sets the name to be used for CSS matching of widgets.
|
||||||
|
*
|
||||||
|
* If this function is not calles for a given class, the name
|
||||||
|
* of the parent class is used.
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gtk_widget_class_set_css_name (GtkWidgetClass *widget_class,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
GtkWidgetClassPrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (GTK_IS_WIDGET_CLASS (widget_class));
|
||||||
|
g_return_if_fail (name != NULL);
|
||||||
|
|
||||||
|
priv = widget_class->priv;
|
||||||
|
|
||||||
|
priv->css_name = g_intern_string (name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_widget_class_get_css_name:
|
||||||
|
* @widget_class: class to set the name on
|
||||||
|
*
|
||||||
|
* Gets the name used by this class for matching in CSS code. See
|
||||||
|
* gtk_widget_class_set_css_name() for details.
|
||||||
|
*
|
||||||
|
* Returns: the CSS name of the given class.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
gtk_widget_class_get_css_name (GtkWidgetClass *widget_class)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GTK_IS_WIDGET_CLASS (widget_class), NULL);
|
||||||
|
|
||||||
|
return widget_class->priv->css_name;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_gtk_widget_style_context_invalidated (GtkWidget *widget)
|
_gtk_widget_style_context_invalidated (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
|
@ -1302,6 +1302,12 @@ GtkStyleContext * gtk_widget_get_style_context (GtkWidget *widget);
|
|||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GtkWidgetPath * gtk_widget_get_path (GtkWidget *widget);
|
GtkWidgetPath * gtk_widget_get_path (GtkWidget *widget);
|
||||||
|
|
||||||
|
/*GDK_AVAILABLE_IN_3_20*/
|
||||||
|
void gtk_widget_class_set_css_name (GtkWidgetClass *widget_class,
|
||||||
|
const char *name);
|
||||||
|
/*GDK_AVAILABLE_IN_3_20*/
|
||||||
|
const char * gtk_widget_class_get_css_name (GtkWidgetClass *widget_class);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_3_4
|
GDK_AVAILABLE_IN_3_4
|
||||||
GdkModifierType gtk_widget_get_modifier_mask (GtkWidget *widget,
|
GdkModifierType gtk_widget_get_modifier_mask (GtkWidget *widget,
|
||||||
GdkModifierIntent intent);
|
GdkModifierIntent intent);
|
||||||
|
Loading…
Reference in New Issue
Block a user