mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 14:51:04 +02:00
parent
56153f189a
commit
b2db7b0bb5
10 changed files with 51 additions and 30 deletions
|
@ -1,4 +1,4 @@
|
|||
use glib::IsA;
|
||||
use glib::{markup_escape_text, IsA};
|
||||
use gtk::prelude::*;
|
||||
use gtk::{Orientation, Widget};
|
||||
|
||||
|
@ -75,3 +75,22 @@ impl<W: IsA<Widget>> IronbarGtkExt for W {
|
|||
unsafe { self.set_data(key, value) }
|
||||
}
|
||||
}
|
||||
|
||||
pub trait IronbarLabelExt {
|
||||
/// Sets the label value to the provided string.
|
||||
///
|
||||
/// If the label does not contain markup `span` tags,
|
||||
/// the text is escaped to avoid issues with special characters (ie `&`).
|
||||
/// Otherwise, the text is used verbatim, and it is up to the user to escape.
|
||||
fn set_label_escaped(&self, label: &str);
|
||||
}
|
||||
|
||||
impl IronbarLabelExt for gtk::Label {
|
||||
fn set_label_escaped(&self, label: &str) {
|
||||
if !label.contains("<span") {
|
||||
self.set_label(&markup_escape_text(label));
|
||||
} else {
|
||||
self.set_label(label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue