GNOME Bugzilla – Bug 591842
ellipsize titles when oversize
Last modified: 2010-04-13 18:11:52 UTC
We should ellipsize title strings when there isn't enough space to display them. Currently we clip them. See bug 491114.
Created attachment 140818 [details] [review] patch The most constrained layout (and maybe the most important) is the title layout that is positioned in the center of the titlebar box (as opposed to the title box). So we should calculate the maximum size for the pango layout from this. Other layouts such as centered wrt title-box and edge aligned will simply start ellipsizing a small bit early. The difference of the width of the left and right button boxes basically. The minimum half width for the title layout is the difference between the half width of the window and the width of the larger of the left and right button boxes. This patch should do this. It also hides the title when there isn't enough space to display any of it.
It's not too obvious from the above, but there really are two separate things going on here. The back-story is that Jon wanted to truly center the title in the whole frame, not center it in the space between the buttons. To do this he had to do a hack and put the title over the whole titlebar rather than in the "title" piece. And when he did that, the clipping to the title piece was no longer effective, so the title overran the buttons. So, while ellipsizing the title rather than just truncating it would be nice, more important is having a less-hacky way of centering the title. I'll attach two patches here, both that require the version mechanism in bug 592503. The first adds a frame_x_center variable to allow centering with respect to the whole frame. The second one allows specifying ellipsize_width on a <title/> element to get ellipsization rather than a sharp clipping edge.
Created attachment 141289 [details] [review] Add frame_x_center/frame_y_center variables for themes Sometimes you want to position something (usually the title) to be centered with respect to the entire frame instead of centered with respect to the individual piece currently being drawn. This patch adds frame_x_center and frame_y_center variables that represent the X/Y centers of the frame in the coordinate system of the piece being drawn. The theme version is bumped from 3.0 to 3.1 (3.0 is just the new version system, 3.1 will have all the features we add for Mutter-2.28.) position expressions
Created attachment 141290 [details] [review] Allow a theme to specify ellipsize width for a title It's nice to indicate when a title is truncated with an ellipsis. Because themes may draw a title multiple times to draw a shadow, or may include the window icon within the title area, we can't determine the proper ellipsization width automatically, so add an optional attribute to the <title/> element "ellipsize_width" which, if set, is the width to ellipsize at. This is only enabled if a theme version of 3.1 is required. When it's not set, we keep the old behavior of just letting the title be clipped with a hard edge.
This all looks reasonable, the only thing I see is. if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!color", &color, "!x", &x, "!y", &y, + "ellipsize_width", &ellipsize_width, NULL)) return; Shouldn't that be. + "!ellipsize_width", &ellipsize_width,
never mind I see you are not forcing them to set this property. That is fair because we do want to support old themes, there is no reason to have have long theme names running into the buttons.
Comment on attachment 141289 [details] [review] Add frame_x_center/frame_y_center variables for themes Looks good.
Comment on attachment 141290 [details] [review] Allow a theme to specify ellipsize width for a title Looks good, apart from the stray g_print().
Any update? Hylke is trying to make a GNOME 3 theme and needs this.
Pushed with a bit of docs and the stray print removed. Attachment 141289 [details] pushed as e8e78eb - Add frame_x_center/frame_y_center variables for themes Attachment 141290 [details] pushed as 1d7476a - Allow a theme to specify ellipsize width for a title