mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
normalize tab items component
This commit is contained in:
parent
47e2bc4617
commit
65502c247d
29 changed files with 427 additions and 117 deletions
37
src/app/browser/window/tab/item/label/widget.rs
Normal file
37
src/app/browser/window/tab/item/label/widget.rs
Normal 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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue