create separated mod for page widget

This commit is contained in:
yggverse 2024-10-11 02:32:43 +03:00
parent a1aaebdb7e
commit 6684b09ae2
4 changed files with 62 additions and 24 deletions

View file

@ -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
}
}