1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-17 14:51:04 +02:00

fix: correctly escape pango markup

This commit is contained in:
Jake Stanger 2024-06-02 15:23:30 +01:00
parent c28de8d902
commit 9d8a3eb370
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
10 changed files with 35 additions and 18 deletions

View file

@ -1,6 +1,6 @@
use glib::IsA;
use glib::{markup_escape_text, IsA};
use gtk::prelude::*;
use gtk::{Orientation, Widget};
use gtk::{Label, Orientation, Widget};
/// Represents a widget's size
/// and location relative to the bar's start edge.
@ -75,3 +75,16 @@ impl<W: IsA<Widget>> IronbarGtkExt for W {
unsafe { self.set_data(key, value) }
}
}
pub trait IronbarLabelExt {
/// Sets a label's pango markup, escaping it in the process.
/// This should be used for any label values
/// which could contain special characters, for example `&`.
fn set_markup_escaped(&self, text: &str);
}
impl IronbarLabelExt for Label {
fn set_markup_escaped(&self, text: &str) {
self.set_markup(markup_escape_text(text).as_str())
}
}