[gnome-shell] st-private: Don't create attr lists if we don't need them
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] st-private: Don't create attr lists if we don't need them
- Date: Mon, 3 Dec 2012 01:12:01 +0000 (UTC)
commit 7e5f1fe41104dfcf4ca2a104651441ae49ee5865
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Nov 30 20:27:27 2012 -0500
st-private: Don't create attr lists if we don't need them
Decorations are fairly uncommon in gnome-shell, so it's
worthwhile to avoid effort creating empty attr lists. This
can also help prevent a relayout.
https://bugzilla.gnome.org/show_bug.cgi?id=689400
src/st/st-private.c | 34 +++++++++++++++++++---------------
1 files changed, 19 insertions(+), 15 deletions(-)
---
diff --git a/src/st/st-private.c b/src/st/st-private.c
index bab1d3c..cd4e52a 100644
--- a/src/st/st-private.c
+++ b/src/st/st-private.c
@@ -173,7 +173,7 @@ _st_set_text_from_style (ClutterText *text,
ClutterColor color;
StTextDecoration decoration;
- PangoAttrList *attribs;
+ PangoAttrList *attribs = NULL;
const PangoFontDescription *font;
gchar *font_string;
StTextAlign align;
@@ -186,26 +186,30 @@ _st_set_text_from_style (ClutterText *text,
clutter_text_set_font_name (text, font_string);
g_free (font_string);
- attribs = pango_attr_list_new ();
-
decoration = st_theme_node_get_text_decoration (theme_node);
- if (decoration & ST_TEXT_DECORATION_UNDERLINE)
- {
- PangoAttribute *underline = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
- pango_attr_list_insert (attribs, underline);
- }
- if (decoration & ST_TEXT_DECORATION_LINE_THROUGH)
+ if (decoration)
{
- PangoAttribute *strikethrough = pango_attr_strikethrough_new (TRUE);
- pango_attr_list_insert (attribs, strikethrough);
+ attribs = pango_attr_list_new ();
+
+ if (decoration & ST_TEXT_DECORATION_UNDERLINE)
+ {
+ PangoAttribute *underline = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
+ pango_attr_list_insert (attribs, underline);
+ }
+ if (decoration & ST_TEXT_DECORATION_LINE_THROUGH)
+ {
+ PangoAttribute *strikethrough = pango_attr_strikethrough_new (TRUE);
+ pango_attr_list_insert (attribs, strikethrough);
+ }
+ /* Pango doesn't have an equivalent attribute for _OVERLINE, and we deliberately
+ * skip BLINK (for now...)
+ */
}
- /* Pango doesn't have an equivalent attribute for _OVERLINE, and we deliberately
- * skip BLINK (for now...)
- */
clutter_text_set_attributes (text, attribs);
- pango_attr_list_unref (attribs);
+ if (attribs)
+ pango_attr_list_unref (attribs);
align = st_theme_node_get_text_align (theme_node);
if(align == ST_TEXT_ALIGN_JUSTIFY) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]