WIP: Implement "Getting Started" Page #14
|
@ -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>
|
|
@ -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 {}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -4,5 +4,16 @@
|
|||
|
||||
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;
|
||||
|
||||
pub mod prelude {
|
||||
pub use super::window::{file::*, menubar::*};
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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"))));
|
||||
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,5 +5,5 @@
|
|||
pub mod closeable_tab;
|
||||
|
||||
pub mod prelude {
|
||||
pub use super::closeable_tab::ClosableTabImplementedNotebook;
|
||||
pub use super::closeable_tab::*;
|
||||
}
|
||||
|
|
|
@ -13,3 +13,8 @@ fn main() {
|
|||
|
||||
std::process::exit(app.run());
|
||||
}
|
||||
|
||||
pub mod prelude {
|
||||
pub use super::components::prelude::*;
|
||||
pub use super::lib::prelude::*;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue