[glom] Print Layout / Relationships Overview: Avoid errors with & in the text.



commit 18ce618f9d196b9d08d33c8af3fe200ed8b676db
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Aug 22 14:08:18 2011 +0200

    Print Layout / Relationships Overview: Avoid errors with & in the text.
    
    * glom/utility_widgets/canvas/canvas_text_movable.cc: reconstruct_markup:
      Escape the text before using it to build markup. Otherwise pango will complain
      (correctly) about & in the text.

 ChangeLog                                          |    8 ++++++++
 glom/utility_widgets/canvas/canvas_text_movable.cc |    7 ++++++-
 2 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9d71bcc..de51571 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-08-22  Murray Cumming  <murrayc murrayc com>
+
+	Print Layout / Relationships Overview: Avoid errors with & in the text.
+
+	* glom/utility_widgets/canvas/canvas_text_movable.cc: reconstruct_markup:
+  Escape the text before using it to build markup. Otherwise pango will complain
+  (correctly) about & in the text.
+
 2011-08-15  Murray Cumming  <murrayc murrayc com>
 
 	Print Layout: Do not show navigation options for related records portals.
diff --git a/glom/utility_widgets/canvas/canvas_text_movable.cc b/glom/utility_widgets/canvas/canvas_text_movable.cc
index 521b5fe..bf84dd0 100644
--- a/glom/utility_widgets/canvas/canvas_text_movable.cc
+++ b/glom/utility_widgets/canvas/canvas_text_movable.cc
@@ -176,12 +176,17 @@ void CanvasTextMovable::reconstruct_markup()
   char* markup = 0;
   if(!m_text.empty())
   {
+    //We will use the text as markup, so remove anything that could be 
+    //interpreted as pango markup.
+    //This is not really pango-specific, but it might just work:
+    const Glib::ustring text_escaped = Glib::Markup::escape_text(m_text);
+    
     //We add px (meaning absolute points size).
     //Otherwise both GooCanvas and GTK+ scale the font up, making it too large.
     //This really seems like a bug in GooCanvas.
     //TODO: This might not be robust - it assumes that the font size is at the end of the font_desc 
     //provided by GtkFontButton.
-    markup = g_strdup_printf("<span font_desc=\"%s\">%s</span>", m_font.c_str(), m_text.c_str());
+    markup = g_strdup_printf("<span font_desc=\"%s\">%s</span>", m_font.c_str(), text_escaped.c_str());
     //std::cout << "DEBUG: markup=" << markup << std::endl;
   }
   property_use_markup() = true;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]