mirror of https://github.com/YGGverse/Yoda.git
yggverse
2 months ago
4 changed files with 78 additions and 43 deletions
@ -1,22 +1,30 @@ |
|||||||
use gtk::Image; |
use gtk::{prelude::WidgetExt, Image}; |
||||||
|
|
||||||
pub struct Pin { |
pub struct Pin { |
||||||
widget: Image, |
gobject: Image, |
||||||
} |
} |
||||||
|
|
||||||
impl Pin { |
impl Pin { |
||||||
// Construct
|
// Construct
|
||||||
pub fn new(visible: bool) -> Pin { |
pub fn new(visible: bool) -> Pin { |
||||||
let widget = Image::builder() |
let gobject = Image::builder() |
||||||
.icon_name("view-pin-symbolic") |
.icon_name("view-pin-symbolic") |
||||||
.visible(visible) |
.visible(visible) |
||||||
.build(); |
.build(); |
||||||
|
|
||||||
Self { widget } |
Self { gobject } |
||||||
|
} |
||||||
|
|
||||||
|
pub fn pin(&self, is_pinned: bool) { |
||||||
|
self.gobject().set_visible(is_pinned); |
||||||
} |
} |
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
pub fn widget(&self) -> &Image { |
pub fn is_pinned(&self) -> bool { |
||||||
&self.widget |
self.gobject.is_visible() |
||||||
|
} |
||||||
|
|
||||||
|
pub fn gobject(&self) -> &Image { |
||||||
|
&self.gobject |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -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…
Reference in new issue