GNOME Bugzilla – Bug 781158
gtk_style_context_invalidate deprecated but required? Automatic style context invalidation does not work
Last modified: 2018-05-02 18:22:55 UTC
Created attachment 349631 [details] minimal example program to present the problem Hello, The attached code presents a situation where a manual call to gtk_style_context_invalidate is required to apply the style defined font size on a GtkTextView. Without the call, the font size is updated on first user input, leading to a sudden unpleasant widget size and layout change. According to the docs, this call should not be required as style context invalidation is automatic. "gtk_style_context_invalidate has been deprecated since version 3.12 and should not be used in newly-written code. Style contexts are invalidated automatically." https://developer.gnome.org/gtk3/stable/GtkStyleContext.html#gtk-style-context-invalidate Am I missing something? Any help on this is highly appreciated. Thanks a lot, Best regards, Robert
Created attachment 349633 [details] Makefile to build the example
Forgot to mention: I tested it on ARCH linux with extra/gtk3 3.22.10-1.
See bug #708583, GtkSourceView still calls gtk_style_context_invalidate(), I never understood why it has been deprecated.
It has been deprecated because the application is not in a position to know when styles need to be invalidated. It is all a function of the css that is in effect.
If I compile this in 3.24, I get the bigger font size right on startup However, that example looks *very* bogus. You just reuse the default css provider (and re-add it to the style context of the widgets with PRIORITY_APPLICATION), then load_from_data on it? Why are you not just using another css provider? That would be the proper way of adding application CSS.
Created attachment 353433 [details] example program using Timm Bäder's suggestions
I just patched the example program to include Timm Bäder's suggestions. Unfortunately, the problem persists on 3.22 (arch linux extra/gtk3 3.22.15-1).
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/802.