GNOME Bugzilla – Bug 709491
dark theme setting not propagated to vertical spinbutton buttons
Last modified: 2013-12-17 23:27:03 UTC
This can be seen in gtk3-widget-factory, on the second page
It's not just the dark theme issue. Since the style context for the spin buttons got caching [0], the spin button up/down buttons also don't change on hover or click any more. [0] https://git.gnome.org/browse/gtk+/commit/?id=0032b2dc5ad4c5faffb58565a3e4589335005c9e
Created attachment 264289 [details] testcase Oh well.
Setting the parent class for the cached style context fixes this (applying orientation style class and dark theme change), and makes the testcase work: diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index 694d59b..f40c457 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -865,9 +865,14 @@ gtk_spin_button_panel_get_context (GtkSpinButton *spin_button, if (*contextp == NULL) { + GtkWidget *parent; *contextp = gtk_style_context_new (); gtk_spin_button_panel_nthchildize_context (spin_button, *contextp, panel == priv->down_panel); + + parent = gtk_widget_get_parent (GTK_WIDGET (spin_button)); + gtk_style_context_set_parent (*contextp, + gtk_widget_get_style_context (parent)); } return *contextp; But I still don't know why the state flags don't affect the drawing. In gtk_spin_button_panel_draw state = gtk_spin_button_panel_get_state (spin_button, panel); is returned correctly, but still gtk_spin_button_panel_draw draws only the same state most of the time ... As reminder: When disabling the caching with s/if (*contextp == NULL)/if (1)/ everything works correctly, even without applying the above diff.
(In reply to comment #3) Oops, that was the wrong diff, sorry! The correct one is: diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index 694d59b..003f517 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -868,6 +868,9 @@ gtk_spin_button_panel_get_context (GtkSpinButton *spin_button, *contextp = gtk_style_context_new (); gtk_spin_button_panel_nthchildize_context (spin_button, *contextp, panel == priv->down_panel); + + gtk_style_context_set_parent (*contextp, + gtk_widget_get_style_context (GTK_WIDGET (spin_button))); } return *contextp; And it doesn't fix both issues, it only applies the correct orientation style.
*** Bug 702418 has been marked as a duplicate of this bug. ***
Bug 702418 has a patch that works, but it's not obvious why it works or should work, I think.
Created attachment 264455 [details] [review] GtkStyleContext: Invalidate contexts with a path Fixes a tiny typo in commit f51c9d4154ba1ce4f20f7c4b7f705fe2756cb8ab which manifested itself in GtkSpinButton's panels being drawn with an incorrect, not updated state. This patch took me more hours than you might think! :P
Attachment 264455 [details] pushed as 94e0f1c - GtkStyleContext: Invalidate contexts with a path