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 768925 - gtk_widget_get_preferred_size() returns wrong requisition when called after gtk_style_context_add_provider()
gtk_widget_get_preferred_size() returns wrong requisition when called after g...
Status: RESOLVED DUPLICATE of bug 751409
Product: gtk+
Classification: Platform
Component: Widget: GtkButton
3.21.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-07-18 13:59 UTC by ipun
Modified: 2017-08-06 00:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Bug snippet that outputs the preferred size after clicking the "clear text" button (2.66 KB, text/plain)
2016-07-18 13:59 UTC, ipun
Details

Description ipun 2016-07-18 13:59:43 UTC
Created attachment 331713 [details]
Bug snippet that outputs the preferred size after clicking the "clear text" button

If you run the attached snippet and click the "clear text" button, the font size will change and increase in size to 50pt. It will also output in console the requisition size after calling gtk_widget_get_preferred_size() before loading the CSS and after.

My console displays that gtk_widget_get_preferred_size() does not get the updated size after loading into CSS.
Comment 1 Emmanuele Bassi (:ebassi) 2016-07-22 14:53:54 UTC
You're calling:

 GtkStyleContext * context = gtk_widget_get_style_context (clearButton);
 ...
 gtk_style_context_add_provider (context,
                                 GTK_STYLE_PROVIDER(provider),
                                 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

This will change the style context of the `clearButton` widget, but it won't change the style context of the children of `clearButton` — namely, the label.

You can:

 * create a global CSS style provider and attach it to the screen, define style classes to it, and the add the style class to the button
 * associate the style provider to the actual widget that needs to use the new font size, namely the GtkLabel child of `clearButton`.
Comment 2 Emmanuele Bassi (:ebassi) 2016-07-22 14:55:02 UTC
See bug 751409 where track the proposal of chaining style contexts down into children.
Comment 3 Daniel Boles 2017-08-06 00:43:52 UTC

*** This bug has been marked as a duplicate of bug 751409 ***