diff --git a/src/components/getting_started/getting-started.ui b/src/components/getting_started/getting-started.ui new file mode 100644 index 0000000..fdb2f4a --- /dev/null +++ b/src/components/getting_started/getting-started.ui @@ -0,0 +1,84 @@ + + + + + + \ No newline at end of file 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..bff671f --- /dev/null +++ b/src/components/getting_started/mod.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/. */ + +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 to_imp(&self) -> &imp::GettingStartedPage { + imp::GettingStartedPage::from_instance(self) + } + pub fn setup_actions(&self, window: &crate::components::EchidnaWindow) -> &Self { + let imp_class = self.to_imp(); + imp_class + .link_open_file + .connect_clicked(clone!(@weak window => + move |_| { + window.action_open_file(); + })); + self + } +} diff --git a/src/components/mod.rs b/src/components/mod.rs index 5353e5a..fe8c259 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -4,12 +4,14 @@ pub mod app; pub mod editor; +pub mod getting_started; pub mod sidebar; pub mod tab_label; pub mod window; pub use app::EchidnaEditor; pub use editor::EchidnaCoreEditor; +pub use getting_started::GettingStartedPage; pub use sidebar::EchidnaSidebar; pub use tab_label::TabLabel; pub use window::EchidnaWindow; diff --git a/src/components/window/menu.ui b/src/components/window/menu.ui index 1d08627..7452287 100644 --- a/src/components/window/menu.ui +++ b/src/components/window/menu.ui @@ -141,7 +141,7 @@
Get Started - window.get-started + win.get-started Show All Commands diff --git a/src/components/window/menubar.rs b/src/components/window/menubar.rs index f51f47f..c2ab0af 100644 --- a/src/components/window/menubar.rs +++ b/src/components/window/menubar.rs @@ -4,11 +4,12 @@ use super::file::FileImplementedEditor; use super::EchidnaWindow; +use crate::components::GettingStartedPage; +use crate::prelude::*; use gio::{MenuModel, SimpleAction}; use glib::clone; use gtk::prelude::*; use gtk::AboutDialog; - pub trait MenubarImplementedEditor { fn setup_menubar(&self); } @@ -118,9 +119,22 @@ impl MenubarImplementedEditor for EchidnaWindow { self.add_action(&action_save_file_as); action_save_file_as.connect_activate(clone!(@weak self as window => - move |_action, _variant| { - window.action_save_file_as(); + move |_action, _variant| { + window.action_save_file_as(); })); } + { + let action_getting_started = SimpleAction::new("get-started", None); + + self.add_action(&action_getting_started); + + action_getting_started.connect_activate(clone!(@weak self as window => + move |_action, _variant| { + let page = GettingStartedPage::new(); + page.setup_actions(&window); + window.to_imp().notebook.prepend_closable_page(&page, Some(>k::Label::new(Some(&"Getting Started")))); + + })); + } } }