Skip to content

Commit

Permalink
Don't print a warning when we can't parse Pango attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Jan 4, 2010
1 parent ac22178 commit 4dc9971
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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 <nick@nickg.me.uk>

* src/xcowsay.c (main): Add --at option to specify cow location
Expand Down
13 changes: 8 additions & 5 deletions src/bubblegen.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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);
Expand Down

0 comments on commit 4dc9971

Please sign in to comment.