GNOME Bugzilla – Bug 398403
Add a "tabs-alignment" style property
Last modified: 2013-04-24 23:49:45 UTC
Hi!, I'm going to attach a patch to add to GtkNotebook a "tabs-alignment" style property to draw tabs in other places than aligned to the right/left. The style property range is between 0.0 (aligned to borders) and 1.0 (centered). The default value is 0.0. Maybe it should be better a boolean style property to switch between these two modes? it seems to me that intermediate values will be pretty rare.
Created attachment 80709 [details] [review] patch to implement the feature
Created attachment 81436 [details] [review] better approach codewise
I don't think this makes a lot of sense as a style property. I think applications usually want and need to have control over tab positioning.
The fact that is centered as a style property doesn't steal any control over the application it just adds more flexibility to engine designers. If you delegate that to the developer, you can't follow HIG standards on other platforms while writting an engine. As an example, the Apple HIG stands that the tabs should be centered, and no apps have control over that. I'm right now implementing a patch to draw the native mac tabs on rhult's mac engine, and the lack of this style property makes impossible from the engine point of view to do the right thing. If an application developer really wants to tweak that, he can use his own rc file for the app. But this behaviour should be in control of the theme/engine designer IMHO.
Ok, here is what I said on irc earlier: <mclasen> arc: well, I basically think that notebooks are already well beyond the point of over-configurability <mclasen> maybe we should add this anyway if this is essential for good os x theming and yes, I think that a boolean "center-tabs" is probably better
"center-tabs" sounds fine. Right/left alignment sounds more of a RTL/LTR based behaviour rather than style.
All right! I'll work on it soon
Created attachment 139587 [details] [review] Use a boolean, center-tabs for the alignment
+ if (tabs_centered && !*show_arrows) + { + remaining_space = *max - *min - tab_overlap - *tab_space; + padding = (remaining_space / 2); + + *min += padding; + *max -= padding; This looks a little fishy to me. Does that mean that tabs will suddenly jump from the middle when scroll arrows are needed ? Or does this work out ok, because arrows are only needed in cases where the remaining_space is 0 anyway ? If so, why is the !*show_arrows condition needed in the first place ?
When scroll arrows are needed, it means that the tabs occupy the whole horizontal area, so being centered or not is sort of irrelevant, in that regard, there's no need to calculate anything there, there's no difference at all. It works okay for me. In any case I just adapted Carlos work here, I can change it if you really think it should be changed but IMHO I think it's alright.
I think GtkStack with its separate stack switcher is the way to go if you want this kind of appearance.