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 781158 - gtk_style_context_invalidate deprecated but required? Automatic style context invalidation does not work
gtk_style_context_invalidate deprecated but required? Automatic style context...
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Class: GtkStyleContext
3.22.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2017-04-10 21:55 UTC by Robert Timm
Modified: 2018-05-02 18:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
minimal example program to present the problem (2.18 KB, text/x-csrc)
2017-04-10 21:55 UTC, Robert Timm
Details
Makefile to build the example (172 bytes, text/plain)
2017-04-10 21:57 UTC, Robert Timm
Details
example program using Timm Bäder's suggestions (2.18 KB, text/x-csrc)
2017-06-08 21:58 UTC, Robert Timm
Details

Description Robert Timm 2017-04-10 21:55:06 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
Comment 1 Robert Timm 2017-04-10 21:57:31 UTC
Created attachment 349633 [details]
Makefile to build the example
Comment 2 Robert Timm 2017-04-10 21:59:45 UTC
Forgot to mention: I tested it on ARCH linux with extra/gtk3 3.22.10-1.
Comment 3 Sébastien Wilmet 2017-04-11 18:40:45 UTC
See bug #708583, GtkSourceView still calls gtk_style_context_invalidate(), I never understood why it has been deprecated.
Comment 4 Matthias Clasen 2017-04-11 19:12:48 UTC
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.
Comment 5 Timm Bäder 2017-04-24 18:09:06 UTC
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.
Comment 6 Robert Timm 2017-06-08 21:58:38 UTC
Created attachment 353433 [details]
example program using Timm Bäder's suggestions
Comment 7 Robert Timm 2017-06-08 22:01:03 UTC
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).
Comment 8 GNOME Infrastructure Team 2018-05-02 18:22:55 UTC
-- 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.