diff options
author | Owen W. Taylor <[email protected]> | 2014-09-27 16:47:27 +0300 |
---|---|---|
committer | Victor Kareh <[email protected]> | 2018-08-28 09:38:37 -0400 |
commit | a47f178df47ae26bf080b5c4f34762102c58085e (patch) | |
tree | 10de970315f7f835c2bac590c4e2a18150b24409 /src/ui/theme-parser.c | |
parent | 728f0022b1b5b75a289abf8f3acec43378c06d92 (diff) | |
download | marco-a47f178df47ae26bf080b5c4f34762102c58085e.tar.bz2 marco-a47f178df47ae26bf080b5c4f34762102c58085e.tar.xz |
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.
https://bugzilla.gnome.org/show_bug.cgi?id=591842
NOTE: Patch copied from mutter and adapted for metacity.
Diffstat (limited to 'src/ui/theme-parser.c')
-rw-r--r-- | src/ui/theme-parser.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/ui/theme-parser.c b/src/ui/theme-parser.c index 56ea32b5..38c1e664 100644 --- a/src/ui/theme-parser.c +++ b/src/ui/theme-parser.c @@ -2615,12 +2615,14 @@ parse_draw_op_element (GMarkupParseContext *context, const char *color; const char *x; const char *y; + const char *ellipsize_width; MetaColorSpec *color_spec; if (!locate_attributes (context, element_name, attribute_names, attribute_values, error, "!color", &color, "!x", &x, "!y", &y, + "ellipsize_width", &ellipsize_width, NULL)) return; @@ -2630,8 +2632,18 @@ parse_draw_op_element (GMarkupParseContext *context, if (!check_expression (y, FALSE, info->theme, context, error)) return; + + if (!check_expression (ellipsize_width, FALSE, info->theme, context, error)) + return; #endif + if (ellipsize_width && peek_required_version (info) < 3001) + { + set_error (error, context, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, + ATTRIBUTE_NOT_FOUND, "ellipsize_width", element_name); + return; + } + /* Check last so we don't have to free it when other * stuff fails */ @@ -2648,6 +2660,8 @@ parse_draw_op_element (GMarkupParseContext *context, op->data.title.x = meta_draw_spec_new (info->theme, x, NULL); op->data.title.y = meta_draw_spec_new (info->theme, y, NULL); + if (ellipsize_width) + op->data.title.ellipsize_width = meta_draw_spec_new (info->theme, ellipsize_width, NULL); g_assert (info->op_list); |