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 645458 - styleproperties: don't replace when merging if the source is GtkSettings
styleproperties: don't replace when merging if the source is GtkSettings
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2011-03-21 20:56 UTC by Cosimo Cecchi
Modified: 2011-05-19 21:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
styleproperties: don't replace when merging if the source is GtkSettings (2.29 KB, patch)
2011-03-21 20:56 UTC, Cosimo Cecchi
needs-work Details | Review
patch (1.99 KB, patch)
2011-03-22 16:45 UTC, Carlos Garnacho
none Details | Review
Revert "styleproperties: don't force replacing the font description" (1.28 KB, patch)
2011-03-22 18:56 UTC, Cosimo Cecchi
none Details | Review
gtksettings: unset attributes set to normal from font description (1.74 KB, patch)
2011-03-22 18:56 UTC, Cosimo Cecchi
none Details | Review
switch: hardcode 10 as font size for the switch label (1.92 KB, patch)
2011-03-22 18:56 UTC, Cosimo Cecchi
none Details | Review

Description Cosimo Cecchi 2011-03-21 20:56:09 UTC
This fixes a regression I introduced before 3.0.4. My bad; the rationale is in the commit message.
Comment 1 Cosimo Cecchi 2011-03-21 20:56:12 UTC
Created attachment 183999 [details] [review]
styleproperties: don't replace when merging if the source is GtkSettings

This fixes a regression introduced with commit
89c1d93b68aaaebeb5db0dc2a58895721c6665aa.
The rationale is the following
- GtkSettings have the last-fallback code for style properties
- always forcing replace to FALSE in pango_font_description_merge()
  causes application's CSS font settings to be ignored, as they are
  usually parsed after the global theme CSS
- there's no guarantee for the order in which the theme CSS and
  GtkSettings are parsed, so we have to special case GtkSettings not to
  replace style settings defined elsewhere.
Comment 2 Matthias Clasen 2011-03-22 12:16:34 UTC
Review of attachment 183999 [details] [review]:

::: gtk/gtkstylecontext.c
@@ +1046,3 @@
+           */
+          gtk_style_properties_merge (style_data->store, provider_style,
+                                      !GTK_IS_SETTINGS (data->provider));

Do we need to look more generally at priorities here ?
I guess we never want to override settings that have come from a higher priority provider ?
Comment 3 Cosimo Cecchi 2011-03-22 16:14:12 UTC
(In reply to comment #2)

> Do we need to look more generally at priorities here ?
> I guess we never want to override settings that have come from a higher
> priority provider ?

So, the problem here is actually with the priority of style providers:

- the theme provider has a priority of 200
- GtkSettings has a priority of 400
- application-installed CSS has a priority of 600

What we would like to support is:
- the default font setting should be taken from GtkSettings
- themes should override the default by setting e.g. "font: bold;" in a widget CSS section
- application CSS should be able to override both

This doesn't seem to play nice with style priorities at all, as currently, if we respect all the priorities when merging, what we get is:
- the theme sets the custom widget font style
- GtkSettings will always override it with the default
- application CSS override still works, as it has an higher priority, but it's currently broken in gtk-3-0 and master as a result of commit 89c1d93b68aaaebeb5db0dc2a58895721c6665aa
Comment 4 Carlos Garnacho 2011-03-22 16:45:31 UTC
Created attachment 184095 [details] [review]
patch

It feels to me like a better fix is to filter out the relevant fields from the GtkSettings' font description, so lower level styles get a say about the overall font style. I did oversight that pango_font_description_from_string() actually sets all fields.
Comment 5 Cosimo Cecchi 2011-03-22 18:56:47 UTC
Created attachment 184113 [details] [review]
Revert "styleproperties: don't force replacing the font description"

It turns out the bug is more complicated than I originally understood.
Not replacing the font description fields while merging here makes it
impossible for application's CSS to override fonts.

This reverts commit 89c1d93b68aaaebeb5db0dc2a58895721c6665aa.
Comment 6 Cosimo Cecchi 2011-03-22 18:56:49 UTC
Created attachment 184114 [details] [review]
gtksettings: unset attributes set to normal from font description

So that they do not override values coming from the theme.

Based on a patch by Carlos Garnacho.
Comment 7 Cosimo Cecchi 2011-03-22 18:56:52 UTC
Created attachment 184115 [details] [review]
switch: hardcode 10 as font size for the switch label

This should not really be done here, but we can't override font size
from the theme just yet.
Comment 8 Cosimo Cecchi 2011-03-22 18:59:58 UTC
This patchset should make things "good enough" for 3.0.
What still doesn't work is overriding font size and family from the theme CSS. We should fix that properly for 3.2, which would also include https://bugzilla.gnome.org/show_bug.cgi?id=325767
Comment 9 Cosimo Cecchi 2011-05-19 21:15:04 UTC
This can be closed, all the patches have been committed a while ago.
(Maybe we already closed it and it got reopened back with the pre-3.0 bugzilla outage, or I committed the patches during the outage and forgot to close).