After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 709491 - dark theme setting not propagated to vertical spinbutton buttons
dark theme setting not propagated to vertical spinbutton buttons
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 702418 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-10-05 23:05 UTC by Matthias Clasen
Modified: 2013-12-17 23:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
testcase (3.33 KB, text/plain)
2013-12-16 14:59 UTC, Volker Sobek (weld)
  Details
GtkStyleContext: Invalidate contexts with a path (1.06 KB, patch)
2013-12-17 23:07 UTC, Volker Sobek (weld)
committed Details | Review

Description Matthias Clasen 2013-10-05 23:05:21 UTC
This can be seen in gtk3-widget-factory, on the second page
Comment 1 Volker Sobek (weld) 2013-12-16 14:44:13 UTC
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
Comment 2 Volker Sobek (weld) 2013-12-16 14:59:50 UTC
Created attachment 264289 [details]
testcase

Oh well.
Comment 3 Volker Sobek (weld) 2013-12-17 13:55:08 UTC
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.
Comment 4 Volker Sobek (weld) 2013-12-17 14:04:02 UTC
(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.
Comment 5 Volker Sobek (weld) 2013-12-17 20:51:17 UTC
*** Bug 702418 has been marked as a duplicate of this bug. ***
Comment 6 Volker Sobek (weld) 2013-12-17 20:55:32 UTC
Bug 702418 has a patch that works, but it's not obvious why it works or should work, I think.
Comment 7 Volker Sobek (weld) 2013-12-17 23:07:19 UTC
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
Comment 8 Benjamin Otte (Company) 2013-12-17 23:27:00 UTC
Attachment 264455 [details] pushed as 94e0f1c - GtkStyleContext: Invalidate contexts with a path