Skip to content

Commit

Permalink
chore: CurlExportPane -> CodeExportPane
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaTechnolog committed Oct 29, 2024
1 parent eedd8cb commit d6c7f29
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion data/cartero.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<file alias="method_dropdown.ui" compressed="true" preprocess="xml-stripblanks">ui/method_dropdown.ui</file>
<file alias="payload_tab.ui" compressed="true" preprocess="xml-stripblanks">ui/payload_tab.ui</file>
<file alias="export_tab.ui" compressed="true" preprocess="xml-stripblanks">ui/export_tab.ui</file>
<file alias="curl_export_pane.ui" compressed="true" preprocess="xml-stripblanks">ui/curl_export_pane.ui</file>
<file alias="code_export_pane.ui" compressed="true" preprocess="xml-stripblanks">ui/code_export_pane.ui</file>
<file alias="raw_payload_pane.ui" compressed="true" preprocess="xml-stripblanks">ui/raw_payload_pane.ui</file>
<file alias="response_headers.ui" compressed="true" preprocess="xml-stripblanks">ui/response_headers.ui</file>
<file alias="response_panel.ui" compressed="true" preprocess="xml-stripblanks">ui/response_panel.ui</file>
Expand Down
2 changes: 1 addition & 1 deletion data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using Gtk 4.0;
using GtkSource 5;

template $CarteroCurlExportPane: $CarteroBaseExportPane {
template $CarteroCodeExportPane: $CarteroBaseExportPane {
ScrolledWindow {
hexpand: true;
vexpand: true;
Expand Down
4 changes: 2 additions & 2 deletions data/ui/export_tab.blp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ template $CarteroExportTab: Gtk.Box {
}

Gtk.StackPage {
name: "curl";
name: "code";

child: $CarteroCurlExportPane curl {};
child: $CarteroCodeExportPane code {};
}

visible-child-name: "none";
Expand Down
28 changes: 14 additions & 14 deletions src/widgets/export_tab/curl.rs → src/widgets/export_tab/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<View>,

Expand All @@ -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) {
Expand All @@ -68,7 +68,7 @@ mod imp {
}

#[glib::derived_properties]
impl ObjectImpl for CurlExportPane {
impl ObjectImpl for CodeExportPane {
fn signals() -> &'static [Signal] {
static SIGNALS: OnceLock<Vec<Signal>> = OnceLock::new();
SIGNALS.get_or_init(|| vec![Signal::builder("changed").build()])
Expand All @@ -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<u8> {
let (start, end) = self.buffer.bounds();
Expand Down Expand Up @@ -206,12 +206,12 @@ mod imp {
}

glib::wrapper! {
pub struct CurlExportPane(ObjectSubclass<imp::CurlExportPane>)
pub struct CodeExportPane(ObjectSubclass<imp::CodeExportPane>)
@extends gtk::Widget, adw::Bin, super::BaseExportPane,
@implements gtk::Accessible, gtk::Buildable;
}

impl CurlExportPane {
impl CodeExportPane {
pub fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> glib::SignalHandlerId {
self.connect_closure(
"changed",
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/export_tab/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
18 changes: 9 additions & 9 deletions src/widgets/export_tab/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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;

Expand All @@ -71,7 +71,7 @@ mod imp {
sep: TemplateChild<Separator>,

#[template_child]
curl: TemplateChild<CurlExportPane>,
code: TemplateChild<CodeExportPane>,

#[property(get = Self::export_type, set = Self::set_export_type, builder(ExportType::default()))]
_payload_type: RefCell<ExportType>,
Expand Down Expand Up @@ -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", &[]);
}));
Expand All @@ -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 {
Expand All @@ -148,7 +148,7 @@ mod imp {
pub(super) fn get_active_widget(&self) -> Option<BaseExportPane> {
match self.export_type() {
ExportType::None => None,
ExportType::Curl => Some(self.curl.upcast_ref::<BaseExportPane>().clone()),
ExportType::Curl => Some(self.code.upcast_ref::<BaseExportPane>().clone()),
}
}
}
Expand Down Expand Up @@ -184,7 +184,7 @@ impl ExportTab {
match imp.export_type() {
ExportType::None => {}
ExportType::Curl => {
let widget = widget.and_downcast::<CurlExportPane>().unwrap();
let widget = widget.and_downcast::<CodeExportPane>().unwrap();
widget.set_request_export_type(req_export_type);
}
}
Expand All @@ -197,7 +197,7 @@ impl ExportTab {
match imp.export_type() {
ExportType::None => RequestExportType::None,
ExportType::Curl => {
let widget = widget.and_downcast::<CurlExportPane>().unwrap();
let widget = widget.and_downcast::<CodeExportPane>().unwrap();
widget.request_export_type()
}
}
Expand Down

0 comments on commit d6c7f29

Please sign in to comment.