Compare commits

...

16 Commits

Author SHA1 Message Date
Nefo Fortressia 6cec9c59af Merge branch 'main' into feat/editor-gutter 2021-12-27 13:55:06 +00:00
Nefo Fortressia fa128ca284
feat: enable GtkSourceView line numbers and line marks
Merge branch 'feat/editor-gutter' of https://gitea.treehouse.systems/fortressia/echidna

See: #22
2021-12-27 20:50:25 +07:00
Nefo Fortressia e3b330a57c fix: activity views not appearing
Merge branch 'feat/activitybar' into 'main'

See merge request EchidnaHQ/Echidna!11
2021-12-17 02:38:12 +00:00
Nefo Fortressia d98266255a refactor: use gtk::show_uri() instead of webbrowser crate
Merge branch 'refactor/gtk_show_uri_on_window' into 'main'

See merge request EchidnaHQ/Echidna!17
2021-12-17 02:32:51 +00:00
Nefo Fortressia c1193df8a2 refactor: make tab label their own widget
Merge branch 'refactor/closable-tabs' into 'main'

See merge request EchidnaHQ/Echidna!15
2021-12-17 02:29:51 +00:00
Nefo Fortressia 4583f993ab refactor: reexport functionalities to the crate for easier importing
Merge branch 'refactor/exports' into 'main'

See merge request EchidnaHQ/Echidna!13
2021-12-17 02:29:11 +00:00
Nefo Fortressia 3c9b665cbf fix: fix unexpected } in workspace.rs
Merge branch 'fix/unexpected-curly-bracket' into 'main'

See merge request EchidnaHQ/Echidna!18
2021-12-17 02:26:44 +00:00
Nefo Fortressia 7478d894ea
fix: fix unexpected } in workspace.rs
I think this is due to git add -p mistakes when I did 1b9f20b.

Not affecting anything, as workspace.rs is still WIP.
2021-12-14 08:29:48 +07:00
Nefo Fortressia 92f6770876
refactor: use gtk::show_uri() instead of webbrowser crate 2021-12-13 12:30:43 +07:00
Nefo Fortressia 18ac470c47
refactor: make tab label their own widget
This helps with downcasting which greatly helps with type safety.
2021-11-15 07:14:59 +07:00
Nefo Fortressia 9a21bd54e5
Merge branch 'refactor/exports' into refactor/closable-tabs 2021-11-15 06:59:46 +07:00
Nefo Fortressia 64b63cf416
refactor: reexport all preludes to the crate 2021-11-12 20:22:32 +07:00
Nefo Fortressia 8a9c414aee
refactor: reexport component preludes 2021-11-12 20:20:48 +07:00
Nefo Fortressia 0c43be616e
style: change the /lib prelude to import everything in closeable_tab 2021-11-12 19:49:55 +07:00
Nefo Fortressia fb0a4e731d
refactor: reexport components in components/mod.rs 2021-11-12 19:45:19 +07:00
Nefo Fortressia 3f80738855
fix: activity views not appearing 2021-11-09 05:16:37 +07:00
12 changed files with 219 additions and 239 deletions

118
Cargo.lock generated
View File

@ -20,12 +20,6 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bumpalo"
version = "3.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c"
[[package]]
name = "cairo-rs"
version = "0.14.7"
@ -68,12 +62,6 @@ dependencies = [
"smallvec",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "echidna"
version = "0.1.0"
@ -87,7 +75,6 @@ dependencies = [
"serde",
"serde_json",
"sourceview5",
"webbrowser",
]
[[package]]
@ -438,36 +425,12 @@ version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
[[package]]
name = "js-sys"
version = "0.3.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84"
dependencies = [
"wasm-bindgen",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.102"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103"
[[package]]
name = "log"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
dependencies = [
"cfg-if",
]
[[package]]
name = "memoffset"
version = "0.6.4"
@ -843,87 +806,6 @@ version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
[[package]]
name = "wasm-bindgen"
version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b"
dependencies = [
"bumpalo",
"lazy_static",
"log",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc"
[[package]]
name = "web-sys"
version = "0.3.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "webbrowser"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecad156490d6b620308ed411cfee90d280b3cbd13e189ea0d3fada8acc89158a"
dependencies = [
"web-sys",
"widestring",
"winapi",
]
[[package]]
name = "widestring"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c"
[[package]]
name = "winapi"
version = "0.3.9"

View File

@ -14,5 +14,4 @@ serde = { version = "^1.0.130", features = ["derive"] }
relative-path = "^1.5.0"
gdk = { version = "^0.3.0", package = "gdk4"}
sourceview = { package = "sourceview5", version = "^0.1.0", git = "https://github.com/EchidnaHQ/sourceview" }
webbrowser = { version = "^0.5.5" }
once_cell = "1"

View File

@ -5,4 +5,15 @@
pub mod app;
pub mod editor;
pub mod sidebar;
pub mod tab_label;
pub mod window;
pub use app::EchidnaEditor;
pub use editor::EchidnaCoreEditor;
pub use sidebar::EchidnaSidebar;
pub use tab_label::TabLabel;
pub use window::EchidnaWindow;
pub mod prelude {
pub use super::window::{file::*, menubar::*};
}

View File

@ -6,67 +6,71 @@
- file, You can obtain one at https://mozilla.org/MPL/2.0/.
-->
<template class="EchidnaSidebar">
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
<child>
<object class="GtkStackSidebar">
<property name="stack">
<object class="GtkStack">
<child>
<object class="GtkStackPage">
<!-- Explorer Tab -->
<property name="name">explorer</property>
<property name="title">Explorer</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">GTK_ORIENTATION_VERTICAL</property>
<child>
<object class="GtkTreeView" id="treeview">
<property name="model">liststore1</property>
<child></child>
<child internal-child="selection">
<object class="GtkTreeSelection" id="selection">
<signal name="changed" handler="on_treeview_selection_changed" />
</object>
</child>
</object>
</child>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<!-- Search Tab -->
<property name="name">search</property>
<property name="title">Search</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">GTK_ORIENTATION_VERTICAL</property>
<child>
<object class="GtkLabel">
<property name="label">Search</property>
</object>
</child>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<!-- Extensions Tab -->
<property name="name">extensions</property>
<property name="title">Extensions</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">GTK_ORIENTATION_VERTICAL</property>
</object>
</property>
</object>
</child>
</object>
</property>
<property name="stack">sidebar_stack</property>
</object>
</child>
<child>
<object class="GtkStack" id="sidebar_stack">
<property name="hhomogeneous">1</property>
<property name="width-request">170</property>
<child>
<object class="GtkStackPage">
<!-- Explorer Tab -->
<property name="name">explorer</property>
<property name="title">Explorer</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">GTK_ORIENTATION_VERTICAL</property>
<child>
<object class="GtkLabel">
<property name="label">Explorer</property>
</object>
</child>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<!-- Search Tab -->
<property name="name">search</property>
<property name="title">Search</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">GTK_ORIENTATION_VERTICAL</property>
<child>
<object class="GtkLabel">
<property name="label">Search</property>
</object>
</child>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<!-- Extensions Tab -->
<property name="name">extensions</property>
<property name="title">Extensions</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">GTK_ORIENTATION_VERTICAL</property>
<child>
<object class="GtkLabel">
<property name="label">Extensions</property>
</object>
</child>
</object>
</property>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@ -0,0 +1,45 @@
/* 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 = "./tab-label.ui")]
pub struct TabLabel {
#[template_child]
pub button: TemplateChild<gtk::Button>,
}
#[glib::object_subclass]
impl ObjectSubclass for TabLabel {
const NAME: &'static str = "TabLabel";
type Type = super::TabLabel;
type ParentType = gtk::Box;
fn class_init(klass: &mut Self::Class) {
Self::bind_template(klass);
}
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
obj.init_template();
}
}
impl ObjectImpl for TabLabel {}
impl WidgetImpl for TabLabel {}
impl BoxImpl for TabLabel {}
impl BuildableImpl for TabLabel {
fn add_child(
&self,
buildable: &Self::Type,
builder: &gtk::Builder,
child: &glib::Object,
type_: Option<&str>,
) {
buildable.prepend(child.downcast_ref::<gtk::Widget>().unwrap());
}
}

View File

@ -0,0 +1,29 @@
/* 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 glib::IsA;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
glib::wrapper! {
pub struct TabLabel(ObjectSubclass<imp::TabLabel>)
@extends gtk::Box, gtk::Widget,
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
}
impl TabLabel {
pub fn new<U: IsA<gtk::Widget>>(tab_label: Option<&U>) -> Self {
let this: Self = glib::Object::new(&[]).expect("Failed to create 'TabLabel' component.");
if tab_label.is_some() {
this.prepend(tab_label.unwrap());
}
this
}
pub fn to_imp(&self) -> &imp::TabLabel {
imp::TabLabel::from_instance(self)
}
}

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="4.5.0" />
<!-- 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/.
-->
<template class="TabLabel">
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
<child>
<object class="GtkButton" id="button">
<property name="has-frame">0</property>
<property name="icon-name">window-close-symbolic</property>
</object>
</child>
</template>
</interface>

View File

@ -78,20 +78,20 @@ impl MenubarImplementedEditor for EchidnaWindow {
app.add_action(&act_report_issue);
act_report_issue.connect_activate(|_action, _variant| {
webbrowser::open("https://gitlab.com/EchidnaHQ/Echidna/-/issues/new?issue");
});
act_report_issue.connect_activate(clone!(@weak self as win =>
move |_action, _variant| {
gtk::show_uri(Some(&win), "https://github.com/EchidnaHQ/Echidna/issues/new", gdk::CURRENT_TIME);
}));
}
{
let act_search_feature_requests = SimpleAction::new("search-feature-requests", None);
app.add_action(&act_search_feature_requests);
act_search_feature_requests.connect_activate(|_action, _variant| {
webbrowser::open(
"https://gitlab.com/EchidnaHQ/Echidna/-/issues?label_name%5B%5D=feat",
);
});
act_search_feature_requests.connect_activate(clone!(@weak self as win =>
move |_action, _variant| {
gtk::show_uri(Some(&win), "https://github.com/EchidnaHQ/Echidna/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement", gdk::CURRENT_TIME);
}));
}
{
let act_window_close = SimpleAction::new("close", None);

View File

@ -123,31 +123,30 @@ impl WorkspaceImplementedEditor for EchidnaEditor {
self.open_folder(folder);
}
}
}
/**
*
*
*/
fn recursive_add_files_into_tree_store(&self, parent_file: File, tree: &TreeStore) {
let child_enumerate_cancellable = Cancellable::new();
let child_files = parent_file
.enumerate_children(
"*",
FileQueryInfoFlags::NONE,
Some(&child_enumerate_cancellable),
)
.expect(
format!(
"Could not look up the children files of {:?} because:\n{:#?}",
filepath
/**
*
*
*/
fn recursive_add_files_into_tree_store(&self, parent_file: File, tree: &TreeStore) {
let child_enumerate_cancellable = Cancellable::new();
let child_files = parent_file
.enumerate_children(
"*",
FileQueryInfoFlags::NONE,
Some(&child_enumerate_cancellable),
)
.as_str(),
);
let filepath = &parent_file
.path()
.expect("Could not get the file path of the file.");
.expect(
format!(
"Could not look up the children files of {:?} because:\n{:#?}",
filepath
)
.as_str(),
);
let filepath = &parent_file
.path()
.expect("Could not get the file path of the file.");
for file_iter in files {
let file_info = file_iter.expect();
let file = parent_file.child(file_info.name());

View File

@ -2,6 +2,7 @@
* 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 crate::components::tab_label::TabLabel;
use glib::IsA;
use gtk::{prelude::*, Box, Button, Widget};
@ -16,39 +17,24 @@ pub trait ClosableTabImplementedNotebook {
child: &T,
tab_label: Option<&U>,
) -> u32;
fn create_closable_tab<U: IsA<Widget>>(tab_label: Option<&U>) -> (Box, Button);
}
impl ClosableTabImplementedNotebook for gtk::Notebook {
fn create_closable_tab<U: IsA<Widget>>(tab_label: Option<&U>) -> (Box, Button) {
let tab = Box::new(gtk::Orientation::Horizontal, 5);
if tab_label.is_some() {
tab.append(tab_label.unwrap());
}
let button = gtk::Button::new();
button.set_icon_name("window-close-symbolic");
button.set_has_frame(false);
tab.append(&button);
(tab, button)
}
fn prepend_closable_page<T: IsA<Widget>, U: IsA<Widget>>(
&self,
child: &T,
tab_label: Option<&U>,
) -> u32 {
let (tab, button) = &Self::create_closable_tab(tab_label);
let page = self.prepend_page(child, Some(tab));
let tab_label_widget = TabLabel::new(tab_label);
let page = self.prepend_page(child, Some(&tab_label_widget));
button.connect_clicked(glib::clone!(@weak self as notebook =>
move |_| {
notebook.remove_page(Some(page));
}));
tab_label_widget
.to_imp()
.button
.connect_clicked(glib::clone!(@weak self as notebook =>
move |_| {
notebook.remove_page(Some(page));
}));
page
}
@ -58,13 +44,16 @@ impl ClosableTabImplementedNotebook for gtk::Notebook {
child: &T,
tab_label: Option<&U>,
) -> u32 {
let (tab, button) = &Self::create_closable_tab(tab_label);
let page = self.append_page(child, Some(tab));
let tab_label_widget = TabLabel::new(tab_label);
let page = self.append_page(child, Some(&tab_label_widget));
button.connect_clicked(glib::clone!(@weak self as notebook =>
move |_| {
notebook.remove_page(Some(page));
}));
tab_label_widget
.to_imp()
.button
.connect_clicked(glib::clone!(@weak self as notebook =>
move |_| {
notebook.remove_page(Some(page));
}));
page
}

View File

@ -5,5 +5,5 @@
pub mod closeable_tab;
pub mod prelude {
pub use super::closeable_tab::ClosableTabImplementedNotebook;
pub use super::closeable_tab::*;
}

View File

@ -13,3 +13,8 @@ fn main() {
std::process::exit(app.run());
}
pub mod prelude {
pub use super::components::prelude::*;
pub use super::lib::prelude::*;
}