diff --git a/data/cartero.gresource.xml b/data/cartero.gresource.xml index d187927..1655b0d 100644 --- a/data/cartero.gresource.xml +++ b/data/cartero.gresource.xml @@ -13,7 +13,7 @@ ui/method_dropdown.ui ui/payload_tab.ui ui/export_tab.ui - ui/curl_export_pane.ui + ui/code_export_pane.ui ui/raw_payload_pane.ui ui/response_headers.ui ui/response_panel.ui diff --git a/data/meson.build b/data/meson.build index 1a16988..5d3da05 100644 --- a/data/meson.build +++ b/data/meson.build @@ -27,7 +27,7 @@ blueprint_files = [ 'ui/payload_tab.blp', 'ui/export_tab.blp', 'ui/raw_payload_pane.blp', - 'ui/curl_export_pane.blp', + 'ui/code_export_pane.blp', 'ui/response_headers.blp', 'ui/response_panel.blp', 'ui/save_dialog.blp', diff --git a/data/ui/curl_export_pane.blp b/data/ui/code_export_pane.blp similarity index 94% rename from data/ui/curl_export_pane.blp rename to data/ui/code_export_pane.blp index a28f992..9f40cbe 100644 --- a/data/ui/curl_export_pane.blp +++ b/data/ui/code_export_pane.blp @@ -18,7 +18,7 @@ using Gtk 4.0; using GtkSource 5; -template $CarteroCurlExportPane: $CarteroBaseExportPane { +template $CarteroCodeExportPane: $CarteroBaseExportPane { ScrolledWindow { hexpand: true; vexpand: true; diff --git a/data/ui/export_tab.blp b/data/ui/export_tab.blp index ba58638..9bc1bb4 100644 --- a/data/ui/export_tab.blp +++ b/data/ui/export_tab.blp @@ -54,9 +54,9 @@ template $CarteroExportTab: Gtk.Box { } Gtk.StackPage { - name: "curl"; + name: "code"; - child: $CarteroCurlExportPane curl {}; + child: $CarteroCodeExportPane code {}; } visible-child-name: "none"; diff --git a/src/widgets/export_tab/curl.rs b/src/widgets/export_tab/code.rs similarity index 92% rename from src/widgets/export_tab/curl.rs rename to src/widgets/export_tab/code.rs index 6bb6bf0..b4fdacc 100644 --- a/src/widgets/export_tab/curl.rs +++ b/src/widgets/export_tab/code.rs @@ -38,9 +38,9 @@ mod imp { use crate::widgets::{BaseExportPane, BaseExportPaneImpl, ExportType}; #[derive(Default, CompositeTemplate, Properties)] - #[properties(wrapper_type = super::CurlExportPane)] - #[template(resource = "/es/danirod/Cartero/curl_export_pane.ui")] - pub struct CurlExportPane { + #[properties(wrapper_type = super::CodeExportPane)] + #[template(resource = "/es/danirod/Cartero/code_export_pane.ui")] + pub struct CodeExportPane { #[template_child] view: TemplateChild, @@ -52,10 +52,10 @@ mod imp { } #[glib::object_subclass] - impl ObjectSubclass for CurlExportPane { - const NAME: &'static str = "CarteroCurlExportPane"; + impl ObjectSubclass for CodeExportPane { + const NAME: &'static str = "CarteroCodeExportPane"; - type Type = super::CurlExportPane; + type Type = super::CodeExportPane; type ParentType = BaseExportPane; fn class_init(klass: &mut Self::Class) { @@ -68,7 +68,7 @@ mod imp { } #[glib::derived_properties] - impl ObjectImpl for CurlExportPane { + impl ObjectImpl for CodeExportPane { fn signals() -> &'static [Signal] { static SIGNALS: OnceLock> = OnceLock::new(); SIGNALS.get_or_init(|| vec![Signal::builder("changed").build()]) @@ -81,13 +81,13 @@ mod imp { } } - impl WidgetImpl for CurlExportPane {} + impl WidgetImpl for CodeExportPane {} - impl BinImpl for CurlExportPane {} + impl BinImpl for CodeExportPane {} - impl BaseExportPaneImpl for CurlExportPane {} + impl BaseExportPaneImpl for CodeExportPane {} - impl CurlExportPane { + impl CodeExportPane { #[allow(unused)] pub(super) fn buffer_content(&self) -> Vec { let (start, end) = self.buffer.bounds(); @@ -206,12 +206,12 @@ mod imp { } glib::wrapper! { - pub struct CurlExportPane(ObjectSubclass) + pub struct CodeExportPane(ObjectSubclass) @extends gtk::Widget, adw::Bin, super::BaseExportPane, @implements gtk::Accessible, gtk::Buildable; } -impl CurlExportPane { +impl CodeExportPane { pub fn connect_changed(&self, f: F) -> glib::SignalHandlerId { self.connect_closure( "changed", @@ -223,7 +223,7 @@ impl CurlExportPane { } } -impl BaseExportPaneExt for CurlExportPane { +impl BaseExportPaneExt for CodeExportPane { fn request_export_type(&self) -> RequestExportType { // TODO: Maybe we could extract url and others from the service which is // gonna generate curl output or idk, like reparse the generated content diff --git a/src/widgets/export_tab/mod.rs b/src/widgets/export_tab/mod.rs index dcdb5f2..4e4e900 100644 --- a/src/widgets/export_tab/mod.rs +++ b/src/widgets/export_tab/mod.rs @@ -16,11 +16,11 @@ // SPDX-License-Identifier: GPL-3.0-or-later mod base; -mod curl; +mod code; mod service; mod tab; pub use base::*; -pub use curl::*; +pub use code::*; pub use service::*; pub use tab::*; diff --git a/src/widgets/export_tab/tab.rs b/src/widgets/export_tab/tab.rs index 8121899..7efdda5 100644 --- a/src/widgets/export_tab/tab.rs +++ b/src/widgets/export_tab/tab.rs @@ -22,7 +22,7 @@ use gtk::subclass::prelude::*; use crate::entities::RequestExportType; -use super::{BaseExportPaneExt, CurlExportPane}; +use super::{BaseExportPaneExt, CodeExportPane}; #[derive(Debug, Copy, Clone, Default, PartialEq, Eq, glib::Enum)] #[enum_type(name = "CarteroExportType")] @@ -53,7 +53,7 @@ mod imp { use gtk::{CompositeTemplate, Stack}; use crate::widgets::BaseExportPane; - use crate::widgets::CurlExportPane; + use crate::widgets::CodeExportPane; use super::ExportType; @@ -71,7 +71,7 @@ mod imp { sep: TemplateChild, #[template_child] - curl: TemplateChild, + code: TemplateChild, #[property(get = Self::export_type, set = Self::set_export_type, builder(ExportType::default()))] _payload_type: RefCell, @@ -104,7 +104,7 @@ mod imp { pane.obj().emit_by_name::<()>("changed", &[]); })); - self.curl + self.code .connect_changed(glib::clone!(@weak self as pane => move |_| { pane.obj().emit_by_name::<()>("changed", &[]); })); @@ -127,12 +127,12 @@ mod imp { let export_type = self.export_type(); let tab = match export_type { ExportType::None => "none", - ExportType::Curl => "curl", + ExportType::Curl => "code", }; self.stack.set_visible_child_name(tab); self.sep.set_visible(export_type != ExportType::None); - self.curl.set_format(export_type); + self.code.set_format(export_type); } pub fn export_type(&self) -> ExportType { @@ -148,7 +148,7 @@ mod imp { pub(super) fn get_active_widget(&self) -> Option { match self.export_type() { ExportType::None => None, - ExportType::Curl => Some(self.curl.upcast_ref::().clone()), + ExportType::Curl => Some(self.code.upcast_ref::().clone()), } } } @@ -184,7 +184,7 @@ impl ExportTab { match imp.export_type() { ExportType::None => {} ExportType::Curl => { - let widget = widget.and_downcast::().unwrap(); + let widget = widget.and_downcast::().unwrap(); widget.set_request_export_type(req_export_type); } } @@ -197,7 +197,7 @@ impl ExportTab { match imp.export_type() { ExportType::None => RequestExportType::None, ExportType::Curl => { - let widget = widget.and_downcast::().unwrap(); + let widget = widget.and_downcast::().unwrap(); widget.request_export_type() } }