[gtk/otte/for-master: 1/5] widget: Initialize cssnode name asap
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/otte/for-master: 1/5] widget: Initialize cssnode name asap
- Date: Tue, 21 Jan 2020 11:48:02 +0000 (UTC)
commit b9c81b1b946523240a68e37887d130e907b42738
Author: Benjamin Otte <otte redhat com>
Date: Tue Jan 21 02:50:07 2020 +0100
widget: Initialize cssnode name asap
That way, it's correct in subclass's init functions.
gtk/gtkradiobutton.c | 15 +++++++++------
gtk/gtkwidget.c | 5 ++---
tests/testgtk.c | 3 ---
3 files changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index 344cde3b89..712c49010e 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -234,18 +234,21 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class)
}
static void
-gtk_radio_button_init (GtkRadioButton *radio_button)
+gtk_radio_button_init (GtkRadioButton *self)
{
- GtkRadioButtonPrivate *priv = gtk_radio_button_get_instance_private (radio_button);
+ GtkRadioButtonPrivate *priv = gtk_radio_button_get_instance_private (self);
+ GtkWidget *widget = GTK_WIDGET (self);
GtkCssNode *css_node;
- gtk_widget_set_receives_default (GTK_WIDGET (radio_button), FALSE);
+ gtk_widget_set_receives_default (widget, FALSE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_button), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self), TRUE);
- priv->group = g_slist_prepend (NULL, radio_button);
+ priv->group = g_slist_prepend (NULL, self);
- css_node = gtk_check_button_get_indicator_node (GTK_CHECK_BUTTON (radio_button));
+ css_node = gtk_widget_get_css_node (widget);
+ gtk_css_node_set_name (css_node, I_("radiobutton"));
+ css_node = gtk_check_button_get_indicator_node (GTK_CHECK_BUTTON (self));
gtk_css_node_set_name (css_node, I_("radio"));
}
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 7a36eecde5..ccdf26d6d4 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -1910,8 +1910,6 @@ gtk_widget_set_property (GObject *object,
case PROP_CSS_NAME:
if (g_value_get_string (value) != NULL)
gtk_css_node_set_name (priv->cssnode, g_intern_string (g_value_get_string (value)));
- else
- gtk_css_node_set_name (priv->cssnode, GTK_WIDGET_GET_CLASS (widget)->priv->css_name);
break;
case PROP_LAYOUT_MANAGER:
gtk_widget_set_layout_manager (widget, g_value_dup_object (value));
@@ -2445,7 +2443,8 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
priv->cssnode = gtk_css_widget_node_new (widget);
gtk_css_node_set_state (priv->cssnode, priv->state_flags);
gtk_css_node_set_visible (priv->cssnode, priv->visible);
- /* need to set correct type here, and only class has the correct type here */
+ /* need to set correct name here, and only class has the correct type here */
+ gtk_css_node_set_name (priv->cssnode, GTK_WIDGET_CLASS (g_class)->priv->css_name);
gtk_css_node_set_widget_type (priv->cssnode, G_TYPE_FROM_CLASS (g_class));
if (g_type_is_a (G_TYPE_FROM_CLASS (g_class), GTK_TYPE_ROOT))
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 96b80f8d94..998a13d218 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -566,20 +566,17 @@ create_radio_buttons (GtkWidget *widget)
gtk_container_add (GTK_CONTAINER (box1), box2);
button = gtk_radio_button_new_with_label (NULL, "button4");
- gtk_check_button_set_draw_indicator (GTK_CHECK_BUTTON (button), FALSE);
gtk_container_add (GTK_CONTAINER (box2), button);
button = gtk_radio_button_new_with_label (
gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
"button5");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
- gtk_check_button_set_draw_indicator (GTK_CHECK_BUTTON (button), FALSE);
gtk_container_add (GTK_CONTAINER (box2), button);
button = gtk_radio_button_new_with_label (
gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
"button6");
- gtk_check_button_set_draw_indicator (GTK_CHECK_BUTTON (button), FALSE);
gtk_container_add (GTK_CONTAINER (box2), button);
separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]