mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
create separated mod for page widget
This commit is contained in:
parent
a1aaebdb7e
commit
6684b09ae2
4 changed files with 62 additions and 24 deletions
45
src/app/browser/window/tab/item/page/widget.rs
Normal file
45
src/app/browser/window/tab/item/page/widget.rs
Normal 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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue