GNOME Bugzilla – Bug 769047
GtkWidget <-> GtkStyleContext API not clear
Last modified: 2016-07-25 13:27:45 UTC
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?
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
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?
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.
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
Review of attachment 332035 [details] [review]:
Review of attachment 332037 [details] [review]:
Not sure this really clarifies that much, but ok
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