mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
48 lines
1.1 KiB
Rust
48 lines
1.1 KiB
Rust
use adw::Clamp;
|
|
use gtk::{
|
|
gio::{SimpleAction, SimpleActionGroup},
|
|
glib::uuid_string_random,
|
|
prelude::{ActionMapExt, BoxExt, WidgetExt},
|
|
Box, Orientation,
|
|
};
|
|
use std::sync::Arc;
|
|
|
|
pub struct Widget {
|
|
gobject: Box,
|
|
}
|
|
|
|
impl Widget {
|
|
// Construct
|
|
pub fn new_arc(
|
|
name: &str,
|
|
// Actions
|
|
action_page_open: SimpleAction,
|
|
// Components
|
|
navigation: &Box,
|
|
content: &Box,
|
|
input: &Clamp,
|
|
) -> Arc<Self> {
|
|
// Init additional action group
|
|
let action_group = SimpleActionGroup::new();
|
|
action_group.add_action(&action_page_open);
|
|
|
|
// Init self
|
|
let gobject = Box::builder()
|
|
.orientation(Orientation::Vertical)
|
|
.name(name)
|
|
.build();
|
|
|
|
gobject.append(navigation);
|
|
gobject.append(content);
|
|
gobject.append(input);
|
|
|
|
gobject.insert_action_group(&uuid_string_random(), Some(&action_group));
|
|
|
|
Arc::new(Self { gobject })
|
|
}
|
|
|
|
// Getters
|
|
pub fn gobject(&self) -> &Box {
|
|
&self.gobject
|
|
}
|
|
}
|