[longomatch] Escape markup text when rendering list elements



commit 75002d32f5f952752f0b6f7c6f028ba230eb30c2
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Mon Sep 22 16:46:08 2014 +0200

    Escape markup text when rendering list elements

 .../Interfaces/Drawing/IDrawingToolkit.cs          |    2 +-
 LongoMatch.Drawing.Cairo/CairoBackend.cs           |    6 +++++-
 LongoMatch.Drawing/PlayslistCellRenderer.cs        |   10 ++++++----
 3 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/Drawing/IDrawingToolkit.cs 
b/LongoMatch.Core/Interfaces/Drawing/IDrawingToolkit.cs
index d2ad5f6..e37c890 100644
--- a/LongoMatch.Core/Interfaces/Drawing/IDrawingToolkit.cs
+++ b/LongoMatch.Core/Interfaces/Drawing/IDrawingToolkit.cs
@@ -66,7 +66,7 @@ namespace LongoMatch.Core.Interfaces.Drawing
                void DrawPoint (Point point);
                void DrawCircle (Point center, double radius);
                void DrawEllipse (Point center, double axisX, double axisY);
-               void DrawText (Point point, double width, double height, string text);
+               void DrawText (Point point, double width, double height, string text, bool escape=false);
                void DrawImage (Image image); 
                void DrawImage (Point start, double width, double height, Image image, bool scale); 
                void DrawArrow(Point start, Point stop, int lenght, double degrees, bool closed);
diff --git a/LongoMatch.Drawing.Cairo/CairoBackend.cs b/LongoMatch.Drawing.Cairo/CairoBackend.cs
index e28874f..415e86a 100644
--- a/LongoMatch.Drawing.Cairo/CairoBackend.cs
+++ b/LongoMatch.Drawing.Cairo/CairoBackend.cs
@@ -336,7 +336,7 @@ namespace LongoMatch.Drawing.Cairo
                        DrawCircle (point, LineWidth);
                }
 
-               public void DrawText (Point point, double width, double height, string text)
+               public void DrawText (Point point, double width, double height, string text, bool 
escape=false)
                {
                        Layout layout = null;
                        Pango.Rectangle inkRect, logRect;
@@ -345,6 +345,10 @@ namespace LongoMatch.Drawing.Cairo
                                return;
                        }
 
+                       if (escape) {
+                               text = GLib.Markup.EscapeText (text);
+                       }
+                       
                        if (context is CairoContext) {
                                layout = (context as CairoContext).PangoLayout;
                        }
diff --git a/LongoMatch.Drawing/PlayslistCellRenderer.cs b/LongoMatch.Drawing/PlayslistCellRenderer.cs
index 03e1762..f3c2789 100644
--- a/LongoMatch.Drawing/PlayslistCellRenderer.cs
+++ b/LongoMatch.Drawing/PlayslistCellRenderer.cs
@@ -57,7 +57,8 @@ namespace LongoMatch.Drawing
                        tk.DrawRectangle (new Point (countX1, countY), StyleConf.ListCountWidth, 2 * 
StyleConf.ListCountRadio);
                        tk.StrokeColor = Config.Style.PaletteBackgroundDark;
                        tk.FontAlignment = FontAlignment.Center;
-                       tk.DrawText (new Point (countX1, countY), StyleConf.ListCountWidth, 2 * 
StyleConf.ListCountRadio, count.ToString ());
+                       tk.DrawText (new Point (countX1, countY), StyleConf.ListCountWidth,
+                                    2 * StyleConf.ListCountRadio, count.ToString (), true);
                }
 
                static void RenderBackgroundAndText (bool isExpanded, IDrawingToolkit tk, Area 
backgroundArea, Point textP, double textW, string text)
@@ -82,7 +83,7 @@ namespace LongoMatch.Drawing
                        tk.FontSize = 14;
                        tk.FontWeight = FontWeight.Bold;
                        tk.FontAlignment = FontAlignment.Left;
-                       tk.DrawText (textP, textW, backgroundArea.Height, text);
+                       tk.DrawText (textP, textW, backgroundArea.Height, text, true);
                }
 
                public static void RenderPlayer (Player player, int count, bool isExpanded, IDrawingToolkit 
tk,
@@ -123,7 +124,8 @@ namespace LongoMatch.Drawing
                {
                        tk.Context = context;
                        tk.Begin ();
-                       RenderBackgroundAndText (isExpanded, tk, backgroundArea, cellArea.Start, 
cellArea.Width, cat.Name);
+                       RenderBackgroundAndText (isExpanded, tk, backgroundArea, cellArea.Start, 
cellArea.Width,
+                                                cat.Name);
                        RenderCount (cat.Color, count, tk, backgroundArea, cellArea);
                        RenderSeparationLine (tk, context, backgroundArea);
                        tk.End ();
@@ -172,7 +174,7 @@ namespace LongoMatch.Drawing
                        tk.FontWeight = FontWeight.Normal;
                        tk.StrokeColor = Config.Style.PaletteSelected;
                        tk.FontAlignment = FontAlignment.Left;
-                       tk.DrawText (textPoint, textWidth, cellArea.Height, desc);
+                       tk.DrawText (textPoint, textWidth, cellArea.Height, desc, true);
                        
                        if (selected) {
                                if (EyeSurface == null) {


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