Draft: Implement "Getting Started" Page

Merge branch 'feat/getting-started' into 'main'

See merge request EchidnaHQ/Echidna!14
merge-requests/14/merge
Nefo Fortressia 2021-12-17 02:38:45 +00:00
commit d17da956c7
6 changed files with 174 additions and 4 deletions

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- 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/.
-->
<interface>
<requires lib="gtk+" version="4.5.0" />
<template class="GettingStartedPage">
<property name="margin-top">40</property>
<property name="margin-bottom">40</property>
<property name="margin-start">40</property>
<property name="margin-end">40</property>
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
<child>
<object class="GtkBox">
<property name="orientation">GTK_ORIENTATION_VERTICAL</property>
<child>
<object class="GtkBox">
<property name="orientation">GTK_ORIENTATION_VERTICAL</property>
<child>
<object class="GtkLinkButton" id="link_new_file">
<child>
<object class="GtkLabel">
<property name="label">New File</property>
<property name="halign">GTK_ALIGN_START</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="link_open_file">
<property name="has-frame">0</property>c
<property name="use-underline">1</property>
<property name="icon-name">text-x-generic-symbolic</property>
<child>
<object class="GtkLabel">
<property name="label">__Open File__</property>
<property name="halign">GTK_ALIGN_START</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="link_open_folder">
<property name="has-frame">0</property>
<property name="use-underline">1</property>
<property name="icon-name">folder-symbolic</property>
<child>
<object class="GtkLabel">
<property name="label">Open Folder</property>
<property name="halign">GTK_ALIGN_START</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="link_clone_git_repo">
<property name="has-frame">0</property>
<property name="use-underline">1</property>
<property name="icon-name">folder-new-symbolic</property>
<child>
<object class="GtkLabel">
<property name="label">Clone Git Repository</property>
<property name="halign">GTK_ALIGN_START</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox"></object>
</child>
</template>
</interface>

View File

@ -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<gtk::LinkButton>,
#[template_child]
pub link_open_file: TemplateChild<gtk::Button>,
}
#[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<Self>) {
obj.init_template();
}
}
impl ObjectImpl for GettingStartedPage {}
impl WidgetImpl for GettingStartedPage {}
impl BoxImpl for GettingStartedPage {}

View File

@ -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<imp::GettingStartedPage>)
@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
}
}

View File

@ -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;

View File

@ -141,7 +141,7 @@
<section>
<item>
<attribute name="label">Get Started</attribute>
<attribute name="action">window.get-started</attribute>
<attribute name="action">win.get-started</attribute>
</item>
<item>
<attribute name="label">Show All Commands</attribute>

View File

@ -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(&gtk::Label::new(Some(&"Getting Started"))));
}));
}
}
}