normalize tab items component

This commit is contained in:
yggverse 2024-10-08 00:56:52 +03:00
parent 47e2bc4617
commit 65502c247d
29 changed files with 427 additions and 117 deletions

View file

@ -0,0 +1,37 @@
use gtk::{
glib::GString, prelude::BoxExt, prelude::WidgetExt, Align, Box, Image, Label, Orientation,
};
pub struct Widget {
gobject: Box,
}
impl Widget {
// Construct
pub fn new(name: GString, pin: &Image, title: &Label) -> Self {
let gobject = Box::builder()
.orientation(Orientation::Horizontal)
.halign(Align::Center)
.name(name)
.tooltip_text(title.text())
.build();
gobject.append(pin);
gobject.append(title);
Self { gobject }
}
// Action
pub fn update(&self, title: Option<&GString>) {
match title {
Some(tooltip_text) => self.gobject.set_tooltip_text(Some(tooltip_text)),
None => self.gobject.set_tooltip_text(None),
}
}
// Getters
pub fn gobject(&self) -> &Box {
&self.gobject
}
}