From fa6f4b6b5ba92495d99251ca656d7928a7206b8b Mon Sep 17 00:00:00 2001 From: Nefo Fortressia Date: Sat, 13 Nov 2021 13:45:25 +0700 Subject: [PATCH] feat: create starter component for GettingStartedPage --- src/components/getting_started/imp.rs | 35 +++++++++++++++++++++++++++ src/components/getting_started/mod.rs | 28 +++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/components/getting_started/imp.rs create mode 100644 src/components/getting_started/mod.rs diff --git a/src/components/getting_started/imp.rs b/src/components/getting_started/imp.rs new file mode 100644 index 0000000..eb90893 --- /dev/null +++ b/src/components/getting_started/imp.rs @@ -0,0 +1,35 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +use gtk::prelude::*; +use gtk::subclass::prelude::*; +use gtk::CompositeTemplate; + +#[derive(Default, CompositeTemplate)] +#[template(file = "./getting-started.ui")] +pub struct GettingStartedPage { + #[template_child] + pub link_new_file: TemplateChild, + #[template_child] + pub link_open_file: TemplateChild, +} + +#[glib::object_subclass] +impl ObjectSubclass for GettingStartedPage { + const NAME: &'static str = "GettingStartedPage"; + type Type = super::GettingStartedPage; + type ParentType = gtk::Box; + + fn class_init(class: &mut Self::Class) { + Self::bind_template(class); + } + + fn instance_init(obj: &glib::subclass::InitializingObject) { + obj.init_template(); + } +} + +impl ObjectImpl for GettingStartedPage {} +impl WidgetImpl for GettingStartedPage {} +impl BoxImpl for GettingStartedPage {} diff --git a/src/components/getting_started/mod.rs b/src/components/getting_started/mod.rs new file mode 100644 index 0000000..e51368e --- /dev/null +++ b/src/components/getting_started/mod.rs @@ -0,0 +1,28 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +pub mod imp; +use crate::components::prelude::*; +use glib::clone; +use gtk::prelude::*; +use gtk::subclass::prelude::*; + +glib::wrapper! { + pub struct GettingStartedPage(ObjectSubclass) + @extends gtk::Box, gtk::Widget, + @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable; +} + +impl GettingStartedPage { + pub fn new() -> Self { + glib::Object::new(&[]).expect("Failed to create 'GettingStartedPage' component.") + } + + pub fn setup_actions>(&self, window: &P) + where + P: FileImplementedEditor, + { + let imp_class = imp::GettingStartedPage::from_instance(self); + } +}