[fractal/wip/cdavis/next-style-cleanup: 6/6] room_title: Parse and escape markup for title and subtitle
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/wip/cdavis/next-style-cleanup: 6/6] room_title: Parse and escape markup for title and subtitle
- Date: Fri, 25 Jun 2021 21:23:02 +0000 (UTC)
commit 83b67ca8b20da99c9244ecbff022766106c9289a
Author: Christopher Davis <christopherdavis gnome org>
Date: Fri Jun 25 14:21:28 2021 -0700
room_title: Parse and escape markup for title and subtitle
Parsing and escaping markup fixes issues with special
characters in titles and descriptions; Also allows links
to work properly in descriptions.
src/components/room_title.rs | 5 +++++
1 file changed, 5 insertions(+)
---
diff --git a/src/components/room_title.rs b/src/components/room_title.rs
index 26698a66..52dce93e 100644
--- a/src/components/room_title.rs
+++ b/src/components/room_title.rs
@@ -2,6 +2,7 @@ use adw::subclass::prelude::*;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::{glib, CompositeTemplate};
+use html2pango::markup;
mod imp {
use super::*;
@@ -104,6 +105,8 @@ impl RoomTitle {
pub fn set_title(&self, title: Option<String>) {
let priv_ = imp::RoomTitle::from_instance(self);
+ // Parse and escape markup in title
+ let title = title.map(|s| markup(&s));
// If there's an existing title, check that current title and new title aren't equal
if priv_.title.borrow().as_deref() != title.as_deref() {
priv_.title.replace(title);
@@ -122,6 +125,8 @@ impl RoomTitle {
pub fn set_subtitle(&self, subtitle: Option<String>) {
let priv_ = imp::RoomTitle::from_instance(self);
+ // Parse and escape markup in subtitle
+ let subtitle = subtitle.map(|s| markup(&s));
// If there's an existing subtitle, check that current subtitle and new subtitle aren't equal
if priv_.subtitle.borrow().as_deref() != subtitle.as_deref() {
priv_.subtitle.replace(subtitle);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]