From fa6f4b6b5ba92495d99251ca656d7928a7206b8b Mon Sep 17 00:00:00 2001 From: Nefo Fortressia Date: Sat, 13 Nov 2021 13:45:25 +0700 Subject: [PATCH 1/7] 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); + } +} From a6d60e62f0a69772ef4d006a71dd2cc7cf26a6ae Mon Sep 17 00:00:00 2001 From: Nefo Fortressia Date: Sat, 13 Nov 2021 13:47:04 +0700 Subject: [PATCH 2/7] feat: add barebones ui file for GettingStartedPage widget --- src/components/getting_started/getting-started.ui | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/components/getting_started/getting-started.ui diff --git a/src/components/getting_started/getting-started.ui b/src/components/getting_started/getting-started.ui new file mode 100644 index 0000000..c5fa784 --- /dev/null +++ b/src/components/getting_started/getting-started.ui @@ -0,0 +1 @@ +< \ No newline at end of file From ed605508f9f13aa12e4f45e430249147b943d9a9 Mon Sep 17 00:00:00 2001 From: Nefo Fortressia Date: Sat, 13 Nov 2021 19:11:55 +0700 Subject: [PATCH 3/7] feat: reexport GettingStartedPage in components/mod.rs --- src/components/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/mod.rs b/src/components/mod.rs index 1cd3fdb..dd379ca 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -4,11 +4,13 @@ pub mod app; pub mod editor; +pub mod getting_started; pub mod sidebar; pub mod window; pub use app::EchidnaEditor; pub use editor::EchidnaCoreEditor; +pub use getting_started::GettingStartedPage; pub use sidebar::EchidnaSidebar; pub use window::EchidnaWindow; From f3df221577ab913e7583a1cc1566dc60441e4c9d Mon Sep 17 00:00:00 2001 From: Nefo Fortressia Date: Sat, 13 Nov 2021 20:48:41 +0700 Subject: [PATCH 4/7] chore: rename window.get-started to win.get-started --- src/components/window/menu.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 82841a12712f76726e7dc438488297fe21a9b921 Mon Sep 17 00:00:00 2001 From: Nefo Fortressia Date: Sat, 13 Nov 2021 20:49:34 +0700 Subject: [PATCH 5/7] feat: add barebones ui file for GettingStartedPage --- .../getting_started/getting-started.ui | 85 ++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/src/components/getting_started/getting-started.ui b/src/components/getting_started/getting-started.ui index c5fa784..fdb2f4a 100644 --- a/src/components/getting_started/getting-started.ui +++ b/src/components/getting_started/getting-started.ui @@ -1 +1,84 @@ -< \ No newline at end of file + + + + + + \ No newline at end of file From d022ed7bc19a242c53672fe56825377c6edd4b4c Mon Sep 17 00:00:00 2001 From: Nefo Fortressia Date: Sat, 13 Nov 2021 21:08:32 +0700 Subject: [PATCH 6/7] feat: implement closure for GettingStartedPage's "Open File" button --- src/components/getting_started/mod.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/getting_started/mod.rs b/src/components/getting_started/mod.rs index e51368e..bff671f 100644 --- a/src/components/getting_started/mod.rs +++ b/src/components/getting_started/mod.rs @@ -19,10 +19,17 @@ impl GettingStartedPage { 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); + 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 } } From f0246f281b50534d1494c546d7c8aac361720997 Mon Sep 17 00:00:00 2001 From: Nefo Fortressia Date: Sat, 13 Nov 2021 21:15:25 +0700 Subject: [PATCH 7/7] feat: implement win.get-started action --- src/components/window/menubar.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/components/window/menubar.rs b/src/components/window/menubar.rs index e7706a8..a15f363 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); } @@ -116,9 +117,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")))); + + })); + } } }