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 591842 - ellipsize titles when oversize
ellipsize titles when oversize
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on: 592503
Blocks:
 
 
Reported: 2009-08-14 19:20 UTC by William Jon McCann
Modified: 2010-04-13 18:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (3.69 KB, patch)
2009-08-14 23:37 UTC, William Jon McCann
rejected Details | Review
Add frame_x_center/frame_y_center variables for themes (4.05 KB, patch)
2009-08-20 20:34 UTC, Owen Taylor
committed Details | Review
Allow a theme to specify ellipsize width for a title (7.57 KB, patch)
2009-08-20 20:34 UTC, Owen Taylor
committed Details | Review

Description William Jon McCann 2009-08-14 19:20:06 UTC
We should ellipsize title strings when there isn't enough space to display them.  Currently we clip them.

See bug 491114.
Comment 1 William Jon McCann 2009-08-14 23:37:14 UTC
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.
Comment 2 Owen Taylor 2009-08-20 20:34:11 UTC
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.
Comment 3 Owen Taylor 2009-08-20 20:34:40 UTC
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
Comment 4 Owen Taylor 2009-08-20 20:34:41 UTC
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.
Comment 5 Jon Nettleton 2009-09-25 15:43:50 UTC
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,
Comment 6 Jon Nettleton 2009-09-25 16:04:23 UTC
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 7 Tomas Frydrych 2009-10-09 15:11:41 UTC
Comment on attachment 141289 [details] [review]
Add frame_x_center/frame_y_center variables for themes

Looks good.
Comment 8 Tomas Frydrych 2009-10-09 15:12:32 UTC
Comment on attachment 141290 [details] [review]
Allow a theme to specify ellipsize width for a title

Looks good, apart from the stray g_print().
Comment 9 William Jon McCann 2010-04-02 15:56:54 UTC
Any update?  Hylke is trying to make a GNOME 3 theme and needs this.
Comment 10 Owen Taylor 2010-04-13 18:11:47 UTC
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