mirror of https://github.com/YGGverse/Yoda.git
yggverse
2 months ago
4 changed files with 62 additions and 24 deletions
@ -0,0 +1,45 @@ |
|||||||
|
use gtk::{ |
||||||
|
gio::{SimpleAction, SimpleActionGroup}, |
||||||
|
prelude::{ActionMapExt, BoxExt, WidgetExt}, |
||||||
|
Box, Orientation, |
||||||
|
}; |
||||||
|
use std::sync::Arc; |
||||||
|
|
||||||
|
pub struct Widget { |
||||||
|
gobject: Box, |
||||||
|
} |
||||||
|
|
||||||
|
impl Widget { |
||||||
|
// Construct
|
||||||
|
pub fn new_arc( |
||||||
|
// Actions
|
||||||
|
action_page_open: Arc<SimpleAction>, |
||||||
|
// Options
|
||||||
|
name: &str, |
||||||
|
// Components
|
||||||
|
navigation: &Box, |
||||||
|
content: &Box, |
||||||
|
) -> Arc<Self> { |
||||||
|
// Init additional action group
|
||||||
|
let action_group = SimpleActionGroup::new(); |
||||||
|
action_group.add_action(action_page_open.as_ref()); |
||||||
|
|
||||||
|
// Init self
|
||||||
|
let gobject = Box::builder() |
||||||
|
.orientation(Orientation::Vertical) |
||||||
|
.name(name) |
||||||
|
.build(); |
||||||
|
|
||||||
|
gobject.append(navigation); |
||||||
|
gobject.append(content); |
||||||
|
|
||||||
|
gobject.insert_action_group("page", Some(&action_group)); |
||||||
|
|
||||||
|
Arc::new(Self { gobject }) |
||||||
|
} |
||||||
|
|
||||||
|
// Getters
|
||||||
|
pub fn gobject(&self) -> &Box { |
||||||
|
&self.gobject |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue