Human theme makes bad GTK widget class assumptions

Bug #237261 reported by Aaron Bockover
8
Affects Status Importance Assigned to Milestone
human-theme (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: human-theme

I'm the Banshee maintainer, and we've had a few bugs filed against our new 1.0 code base regarding theme issues specifically with Ubuntu's Human theme.

It appears that the gtkrc for Human does some pretty nasty things by making assumptions that all widgets in an application will derive from the small set of standard GTK widgets.

For instance, our primary interface element in Banshee is a custom list view widget that is drawn 100% in Cairo. To the user it feels and mostly looks like a GtkTreeView, but it has nothing to do with the GtkTreeView. In fact it derives directly from GtkWidget and we handle all internal windowing, widgetry, events, drawing, and so on. So what's the problem?

Human applies a special style for GtkTreeView based widgets:

...
style "clearlooks-treeview"
{
    bg[SELECTED] = @selected_bg_color

    engine "clearlooks" {
        hint = "treeview"
    }
}
...
widget_class "*.<GtkTreeView>*" style "clearlooks-treeview"
...

There are a number of other similar special-case assumptions, but this is the one that affects us the most.

As can be seen in the screenshot on the bug for this against Banshee (filed by a poor unsuspecting user), it's rather confusing. On the left, our source view, is a standard GtkTreeView so it has the correct selection background color [1], but on the right is our custom list view which gets an improper selection background color:

http://bugzilla.gnome.org/attachment.cgi?id=112103&action=view

Because our list view is not derived from GtkTreeView, the style is not applied through the widget_class match, so the "treeview" hint is never passed to Clearlooks for our widget.

I won't go into the details here about why this is horrible for ISVs and so on (which I consider Banshee to be in many cases) as I hope my findings are obvious and also I've already detailed this overall problem with GTK themes about a year ago in a blog post [2]. If it needs further clarifying, I'd be glad to do so in followup comments.

I consider this to be a critical issue because Human is Ubuntu's default theme and thus there are a huge number of users using it, and as somewhat of a function of this, users will default to filing bugs against Banshee, the upstream application, and not Ubuntu, where the bug exists.

Thanks for the consideration!

--

[1] Due to other somewhat unrelated GTK theme issues, we do some color shading of the selection background to create a selection background gradient that is at least appealing if not 100% theme compatible. It is at least very theme derived, barring this specific bug or similar bugs with other themes.

[2] http://abock.org/2007/07/02/suboptimal-theming-in-gtk/ -- I highly recommend reading this, though I don't want to sound too pretentious.

Revision history for this message
Aaron Bockover (abockover) wrote :

Here's the most relevant upstream bug on this issue:

http://bugzilla.gnome.org/show_bug.cgi?id=534731

Revision history for this message
Matthias Rosenkranz (rose) wrote :

Maybe this is related: I use the Ubuntustudio theme (colours and controls) and banshee 0.99.3 (from the ppa mentioned on the website). When I move the cursor over an item in the left hand side list of playlists, the item disappears. It reappears again when I remove the mouse cursor from it. I guess this is related to theming as well, the foreground colour is probably changed to white on mouseover. Since my banshee version is not in Ubuntu yet, I'm not sure if my report is appropriate here.

Revision history for this message
Kenneth Wimer (kwwii) wrote :

As the app is using a non-standard class widget how can we create a theme which works? Firefox, gnome-control-center, and vlc all have these problems (it has become apparent when switching to the dark theme). The only way I know how to work around this is to apply the correct theme info to these special subclasses but that is really a hack. The correct way to do this would be to ask apps to follow the rules and don't hack together widgets from classes which were not intended to be hacked thusly.

Revision history for this message
Aaron Bockover (abockover) wrote :

Kenneth:

You create a theme which works by not special casing colors to certain widget classes. While it might be nice to do, unfortunately the GTK 2 theme system is extremely limited and is a layer of hacks.

The argument that no one should write widgets not derived from standard GTK widgets is amusing, and assuming they are "hacked together" is more so. GTK provides a framework for writing widgets and it's perfectly acceptable and reasonable to do so. As a theme writer, you have to respect that the GTK theme system is very limited and fragile to play nice with other applications.

Pretend I was an ISV and I have a large application that I am actively working on porting to Linux and we have a number of custom widgets. Say we're a medial company and we have lots of medial related widgets - something GTK would rightly never provide. When we find that our application is inconsistent and possibly unusable in these subtle theme related ways, it can easily give a bad impression of the platform we're trying to target and could instill doubt about the choice.

At the application level the best thing a widget developer can do is respect how color pairs are to be used. For instance, foreground + background, text + base, and so on. If a theme breaks these pairs or introduces inconsistencies, there's no way we can really address that.

For the Clearlooks specifically, they at least appear to support somewhat standard "hints", which is what Human sets in this case. One possible, but not likely, workaround at our level would be to force apply this hint on our widget. But that's a dangerous game - for one it assumes the theme engine will always be Clearlooks, and the right version of Clearlooks at that.

There are also other hacks we can attempt to apply on the widget, but again there is no guarantee that they'll be respected or work for a specific theme. Going down this path means the widget should be aware of and cater to every possible theme out there.

Steven Harms (sharms)
Changed in human-theme:
status: New → Confirmed
Revision history for this message
Kenneth Wimer (kwwii) wrote :

No, it means that if the app used normal gtk classes this problem would not occur :-) In your example of "bad" theme code we set the bg[SELECTED] color to the color value of @selected_bg_color which only makes sense, really. The fact that one has to explicitly set it is bad but that is not a problem with the theme itself.

In any case, we are going to use murrine instead of ubuntulooks/clearlooks but my guess is that the same problems will occur.

Revision history for this message
Alan (alan-mcgovern) wrote :

"The correct way to do this would be to ask apps to follow the rules and don't hack together widgets from classes which were not intended to be hacked thusly."

I'm sorry, but what? Are you saying that it's wrong to write custom widgets? Are you saying that everything you could ever want to accomplish can be accomplished using only the built in classes? I'm a bit surprised that a custom widget derived from GtkWidget would illicit that comment.

Revision history for this message
Aaron Bockover (abockover) wrote :

My example of "bad" is not setting bg[SELECTED], which just sets it to the defined color constant, it's setting the "treeview" hint on the Clearlooks engine. This causes Clearlooks to do something special with the bg[SELECTED] color (make it lighter).

Because of this hint, two separate background selection colors will be evident in GTK applications, which is not good.

Why not just make selected_bg_color lighter?

Revision history for this message
Kenneth Wimer (kwwii) wrote :

My point is that the only apps which have these problems are ones that create their own custom widgets. Trying to play around with the few colors that we can define just makes things unbelievably hard for the theme developer to do something different than the norm (light grey bg with dark text). I have nothing against custom widgets, I just want them to follow the rules on using colors so that the custom widget doesn't make themeing in general impossible. Finally, the best idea would probably be to include a couple more colors (KDE did this in the switch from 3 to 4)

Revision history for this message
Aaron Bockover (abockover) wrote :

My point is that there could be 1000 custom apps out there doing similar things. Your solution is to ignore them. You have to realize that there are some extremely serious issues regarding GTK theming, and as a theme designer, you need to respect that. Just because you want something to look a fancy certain way doesn't mean that's a good idea because you obviously run into issues like this.

Everyone wants GTK to be prettier, easier to theme, etc., but we'll never get that with GTK 2.0, and that needs to be kept in mind, respected, and never abused, *especially* in the default theme shipping with such a popular distribution. At the end of the day, this selfish decision hurts the upstream applications that provide value to your downstream distribution.

We do the /exact/ same thing for using theme colors in our widget as the GtkTreeView, but we get different results because the /theme/ gives us different colors for the /same/ "query" because our GObject class hierarchies are different (and there is _nothing_ wrong with this, it's a central idea of the /framework/ that is GTK and OOP in general). It seems that this is hard for you to understand, so I have introduced an insane but manageable hack in our application so at least users won't be blaming us upstream for downstream deficiencies. But this only works for /our/ application. Try to imagine the issue in the larger scope of potential ISV and other third party applications out there.

Other themes seem to understand the limitations here, I would think Ubuntu would follow suit for its default themes.

I also want to point out that I feel so strongly about this issue not from a purely cosmetic point of view, but from a usability/accessibility point of view. We've had a few users complain that because of this bug, the background selection color was too dark and caused contrast issues with the text color, making our custom view hard or stressful to read. That's not cool.

Close this if you want, we at least shouldn't hear complaints upstream now (http://svn.gnome.org/viewvc/banshee?view=revision&revision=4112), but I'm sure there are many other apps out there you don't and won't know about that will suffer the same or similar problems.

jtl999 (jtl999)
Changed in human-theme:
status: Confirmed → In Progress
Revision history for this message
Kenneth Wimer (kwwii) wrote :

gtkrc change fixes this bug

Changed in human-theme:
status: In Progress → Fix Committed
Przemek K. (azrael)
Changed in human-theme (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.