This is a major refactor which updates GTK, GLib and GTK Layer Shell to their latest versions. GLib channels, previously used for receiving events on the GLib Main Context thread have been deprecated and a new method for running Futures on the main thread has been added instead. This commit also replaces all the deprecated code with this. As part of the above, a bug was uncovered related to creating the GLib main context inside the Tokio runtime. Spawning of Tokio tasks has been refactored to fix this.
35 lines
728 B
Rust
35 lines
728 B
Rust
use gtk::prelude::*;
|
|
use gtk::Label;
|
|
use serde::Deserialize;
|
|
|
|
use crate::build;
|
|
use crate::dynamic_value::dynamic_string;
|
|
|
|
use super::{CustomWidget, CustomWidgetContext};
|
|
|
|
#[derive(Debug, Deserialize, Clone)]
|
|
pub struct LabelWidget {
|
|
name: Option<String>,
|
|
class: Option<String>,
|
|
label: String,
|
|
}
|
|
|
|
impl CustomWidget for LabelWidget {
|
|
type Widget = Label;
|
|
|
|
fn into_widget(self, _context: CustomWidgetContext) -> Self::Widget {
|
|
let label = build!(self, Self::Widget);
|
|
|
|
label.set_use_markup(true);
|
|
|
|
{
|
|
let label = label.clone();
|
|
dynamic_string(&self.label, move |string| {
|
|
label.set_markup(&string);
|
|
});
|
|
}
|
|
|
|
label
|
|
}
|
|
}
|