[pitivi] title: Escape text so it can be properly rendered by pango
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] title: Escape text so it can be properly rendered by pango
- Date: Mon, 30 Mar 2020 21:39:20 +0000 (UTC)
commit 366f3fe196c430f1dff0920215f12c5614a7aa6d
Author: Thibault Saunier <tsaunier igalia com>
Date: Thu Mar 12 15:28:06 2020 -0300
title: Escape text so it can be properly rendered by pango
pitivi/timeline/previewers.py | 12 ++++++------
pitivi/titleeditor.py | 17 ++++++++++-------
2 files changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/pitivi/timeline/previewers.py b/pitivi/timeline/previewers.py
index 6641f56e..fcf71c9d 100644
--- a/pitivi/timeline/previewers.py
+++ b/pitivi/timeline/previewers.py
@@ -1355,14 +1355,14 @@ class TitlePreviewer(Gtk.Layout, Previewer, Zoomable, Loggable):
context.set_source_rgb(1, 1, 1)
# Get text
- res, text = self.ges_elem.get_child_property("text")
+ res, escaped_text = self.ges_elem.get_child_property("text")
if res:
- text = text.strip().split("\n", 1)[0]
- if not res or not text:
- text = _("Title Clip")
+ escaped_text = escaped_text.strip().split("\n", 1)[0]
+ if not res or not escaped_text:
+ escaped_text = _("Title Clip")
# Adapt to RTL/LTR direction
- direction = Pango.unichar_direction(text[0])
+ direction = Pango.unichar_direction(escaped_text[0])
if direction in (Pango.Direction.LTR, Pango.Direction.NEUTRAL):
stops = (0, 1)
x_pos = 10
@@ -1393,7 +1393,7 @@ class TitlePreviewer(Gtk.Layout, Previewer, Zoomable, Loggable):
layout.set_ellipsize(Pango.EllipsizeMode.END)
# Draw text
- layout.set_text(text, -1)
+ layout.set_markup(escaped_text, -1)
context.move_to(x_pos, (rect.height / 2) - 11)
PangoCairo.show_layout(context, layout)
diff --git a/pitivi/titleeditor.py b/pitivi/titleeditor.py
index bec31201..92c6a753 100644
--- a/pitivi/titleeditor.py
+++ b/pitivi/titleeditor.py
@@ -15,9 +15,11 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, see <http://www.gnu.org/licenses/>.
import os
+import html
from gettext import gettext as _
from gi.repository import GES
+from gi.repository import GLib
from gi.repository import Gst
from gi.repository import Gtk
from gi.repository import Pango
@@ -163,7 +165,7 @@ class TitleEditor(Loggable):
self._set_child_property("font-desc", font_desc)
def _update_from_source(self, source):
- self.textbuffer.set_text(source.get_child_property("text")[1] or "")
+ self.textbuffer.props.text = html.unescape(source.get_child_property("text")[1] or "")
self.settings['x-absolute'].set_value(source.get_child_property("x-absolute")[1])
self.settings['y-absolute'].set_value(source.get_child_property("y-absolute")[1])
self.settings['valignment'].set_active_id(
@@ -187,9 +189,9 @@ class TitleEditor(Loggable):
# Nothing to update.
return
- text = self.textbuffer.props.text
- self.log("Source text updated to %s", text)
- self._set_child_property("text", text)
+ escaped_text = html.escape(self.textbuffer.props.text)
+ self.log("Source text updated to %s", escaped_text)
+ self._set_child_property("text", escaped_text)
def _update_source_cb(self, updated_obj):
"""Handles changes in the advanced property widgets at the bottom."""
@@ -272,11 +274,12 @@ class TitleEditor(Loggable):
return
if pspec.name == "text":
- res, value = self.source.get_child_property(pspec.name)
+ res, escaped_text = self.source.get_child_property(pspec.name)
assert res, pspec.name
- if self.textbuffer.props.text == value or "":
+ text = html.unescape(escaped_text)
+ if self.textbuffer.props.text == text or "":
return
- self.textbuffer.props.text = value
+ self.textbuffer.props.text = text
elif pspec.name in ["x-absolute", "y-absolute"]:
res, value = self.source.get_child_property(pspec.name)
assert res, pspec.name
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]