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 769047 - GtkWidget <-> GtkStyleContext API not clear
GtkWidget <-> GtkStyleContext API not clear
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Documentation
3.21.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-07-21 16:35 UTC by Sébastien Wilmet
Modified: 2016-07-25 13:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
docs: add missing info for gtk_widget_get_style_context() (1.09 KB, patch)
2016-07-24 11:23 UTC, Sébastien Wilmet
committed Details | Review
docs: GtkWidget::style-updated vs GtkStyleContext::changed (2.26 KB, patch)
2016-07-24 15:58 UTC, Sébastien Wilmet
committed Details | Review

Description Sébastien Wilmet 2016-07-21 16:35:23 UTC
Some questions:

Does gtk_widget_get_style_context() return always the same object for a certain widget?

What is the difference between the GtkWidget::style-updated and GtkStyleContext::changed signals? When we want to execute some code when the style of a widget changes, which signal should be used?
Comment 1 Sébastien Wilmet 2016-07-24 11:23:49 UTC
Created attachment 332035 [details] [review]
docs: add missing info for gtk_widget_get_style_context()

It is important to know whether the returned object can or cannot
change, for a certain widget. For example to connect to the
GtkStyleContext::changed signal.
Comment 2 Sébastien Wilmet 2016-07-24 11:26:49 UTC
I got an answer on IRC to the first question, hence the above patch.

But I'm still waiting an answer to the second question: what is the difference between the GtkWidget::style-updated and GtkStyleContext::changed signals?
Comment 3 Sébastien Wilmet 2016-07-24 12:32:16 UTC
Got an explanation for the second question, on IRC:

<ebassi> swilmet: GtkStyleContext::changed causes GtkWidget::style-updated to be emitted
<ebassi> Assuming there's a widget attached to the style context
<ebassi> GtkWidget::style-updated predates GtkStyleContext::changed; style context can exist without widgets, though
<ebassi> So you need GtkStyleContext::changed for people using style-context-without-widgets
<swilmet> ok I see
<ebassi> And, for convenience, you also get a signal/vfunc for people with widgets
<ebassi> Though the code did change around that, since 3.0 was released
<swilmet> so if we have a GtkWidget, we can use either ::style-updated or ::changed interchangeably
<ebassi> Well, if you're doing something in your own widget when the style changed, it's easier to override GtkWidgetClass.style_updated() instead of getting the style context and connecting to the ::changed signal
<ebassi> But, yes: in principle it's the same


Now this needs to be turned into a patch.
Comment 4 Sébastien Wilmet 2016-07-24 15:58:46 UTC
Created attachment 332037 [details] [review]
docs: GtkWidget::style-updated vs GtkStyleContext::changed

Explain the difference between those two signals.

Add "Since: 3.0" for GtkStyleContext::changed, since that signal has
been added in commit 9f84e101bf150a85f82e15c56130b1f98b8fdbf0, present
since 2.91.6.
Comment 5 Matthias Clasen 2016-07-25 12:20:16 UTC
Review of attachment 332035 [details] [review]:

ok
Comment 6 Matthias Clasen 2016-07-25 12:21:34 UTC
Review of attachment 332037 [details] [review]:

Not sure this really clarifies that much, but ok
Comment 7 Matthias Clasen 2016-07-25 13:27:38 UTC
Attachment 332035 [details] pushed as 3432587 - docs: add missing info for gtk_widget_get_style_context()
Attachment 332037 [details] pushed as af5ef15 - docs: GtkWidget::style-updated vs GtkStyleContext::changed