From 4dc997146ea85bf649d477b06b52297bf0748185 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Mon, 4 Jan 2010 20:49:02 +0000 Subject: [PATCH] Don't print a warning when we can't parse Pango attributes --- ChangeLog | 4 ++++ src/bubblegen.c | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 53246b9..e3400bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,10 @@ * src/config_file.c (next_token): Fix parsing config files where there is no whitespace between tokens. + * src/bubblegen.c (make_text_bubble): Don't print a warning when + we can't parse Pango attributes. This may arise from valid + input e.g. '1 < 0'. + 2010-01-03 Nick Gasson * src/xcowsay.c (main): Add --at option to specify cow location diff --git a/src/bubblegen.c b/src/bubblegen.c index 3cd0eab..3bba779 100644 --- a/src/bubblegen.c +++ b/src/bubblegen.c @@ -1,5 +1,5 @@ /* bubblegen.c -- Generate various sorts of bubbles. - * Copyright (C) 2008 Nick Gasson + * Copyright (C) 2008-2010 Nick Gasson * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -269,7 +269,8 @@ GdkPixbuf *make_dream_bubble(const char *file, int *p_width, int *p_height) return bubble_tidy(&bubble); } -GdkPixbuf *make_text_bubble(char *text, int *p_width, int *p_height, cowmode_t mode) +GdkPixbuf *make_text_bubble(char *text, int *p_width, + int *p_height, cowmode_t mode) { bubble_t bubble; int text_width, text_height; @@ -282,8 +283,10 @@ GdkPixbuf *make_text_bubble(char *text, int *p_width, int *p_height, cowmode_t m PangoAttrList *pango_attrs = NULL; char *stripped; - if (!pango_parse_markup(text, -1, 0, &pango_attrs, &stripped, NULL, NULL)) { - fprintf(stderr, i18n("Warning: Failed to parse Pango attributes\n")); + if (!pango_parse_markup(text, -1, 0, &pango_attrs, + &stripped, NULL, NULL)) { + + // This isn't fatal as the the text may contain angled brackets, etc. stripped = text; } else { @@ -304,7 +307,7 @@ GdkPixbuf *make_text_bubble(char *text, int *p_width, int *p_height, cowmode_t m // Render the text gdk_draw_layout(bubble.pixmap, bubble.gc, - bubble_content_left(mode), bubble_content_top(), layout); + bubble_content_left(mode), bubble_content_top(), layout); // Make sure to free the Pango objects g_object_unref(pango_context); -- 2.39.2