Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request body panel #21

Merged
merged 7 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
427 changes: 417 additions & 10 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ csd = []

[dependencies]
adw = { version = "0.6.0", package = "libadwaita", features = ["v1_5", "gtk_v4_12"] }
formdata = "0.13.0"
futures-lite = "2.3.0"
gettext-rs = { version = "0.7.0", features = ["gettext-system"] }
glib = "0.19.3"
gtk = { package = "gtk4", version = "0.8.2", features = ["v4_12"] }
isahc = "1.7.2"
serde = { version = "1.0.198", features = ["derive"] }
serde_urlencoded = "0.7.1"
sourceview5 = "0.8.0"
srtemplate = { version = "0.3.0", features = [] }
thiserror = "1.0.60"
Expand Down
6 changes: 5 additions & 1 deletion data/cartero.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
<gresources>
<gresource prefix="/es/danirod/Cartero/">
<file alias="endpoint_pane.ui" compressed="true" preprocess="xml-stripblanks">ui/endpoint_pane.ui</file>
<file alias="formdata_payload_pane.ui" compressed="true" preprocess="xml-stripblanks">ui/formdata_payload_pane.ui</file>
<file alias="key_value_row.ui" compressed="true" preprocess="xml-stripblanks">ui/key_value_row.ui</file>
<file alias="key_value_pane.ui" compressed="true" preprocess="xml-stripblanks">ui/key_value_pane.ui</file>
<file alias="main_window.ui" compressed="true" preprocess="xml-stripblanks">ui/main_window.ui</file>
<file alias="main_window_no_csd.ui" compressed="true" preprocess="xml-stripblanks">ui/main_window_no_csd.ui</file>
<file alias="main_window_no_csd.ui" compressed="true" preprocess="xml-stripblanks">ui/main_window_no_csd.ui</file>
<file alias="payload_tab.ui" compressed="true" preprocess="xml-stripblanks">ui/payload_tab.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>
<file alias="save_dialog.ui" compressed="true" preprocess="xml-stripblanks">ui/save_dialog.ui</file>
<file alias="urlencoded_payload_pane.ui" compressed="true" preprocess="xml-stripblanks">ui/urlencoded_payload_pane.ui</file>
<file alias="style.css" compressed="true">style.css</file>
</gresource>

Expand Down
4 changes: 4 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ subdir('icons')

blueprint_files = [
'ui/endpoint_pane.blp',
'ui/formdata_payload_pane.blp',
'ui/main_window.blp',
'ui/main_window_no_csd.blp',
'ui/key_value_pane.blp',
'ui/key_value_row.blp',
'ui/payload_tab.blp',
'ui/raw_payload_pane.blp',
'ui/response_headers.blp',
'ui/response_panel.blp',
'ui/save_dialog.blp',
'ui/urlencoded_payload_pane.blp',
]

blueprint_targets = []
Expand Down
16 changes: 1 addition & 15 deletions data/ui/endpoint_pane.blp
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,7 @@ template $CarteroEndpointPane: Adw.BreakpointBin {
label: _("Body");
};

child: ScrolledWindow {
hexpand: true;
vexpand: true;

GtkSource.View request_body {
top-margin: 10;
bottom-margin: 10;
left-margin: 10;
right-margin: 10;
smart-backspace: true;
monospace: true;

buffer: GtkSource.Buffer {};
}
};
child: $CarteroPayloadTab payload_pane {};
}
}
};
Expand Down
36 changes: 36 additions & 0 deletions data/ui/formdata_payload_pane.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2024 the Cartero authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// SPDX-License-Identifier: GPL-3.0-or-later
using Gtk 4.0;
using Adw 1;

template $CarteroFormdataPayloadPane: $CarteroBasePayloadPane {
ScrolledWindow {
hexpand: true;
vexpand: true;

Adw.Clamp {
styles [
"background"
]

maximum-size: 720;

$CarteroKeyValuePane data {}
}
}
}
88 changes: 88 additions & 0 deletions data/ui/payload_tab.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright 2024 the Cartero authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// SPDX-License-Identifier: GPL-3.0-or-later
using Gtk 4.0;
using Adw 1;

template $CarteroPayloadTab: Gtk.Box {
styles [
"background"
]

orientation: vertical;
spacing: 15;

Adw.Clamp {
margin-top: 10;
vexpand: false;

Adw.PreferencesGroup {
Adw.ComboRow combo {
title: _("Body type");
model: entries;
notify::selected => $on_selection_changed() swapped;
}
}
}

Gtk.Box {
orientation: vertical;
vexpand: true;
valign: fill;

Gtk.Separator sep {}

Gtk.Stack stack {
Gtk.StackPage {
name: "none";

child: Adw.Bin {};
}

Gtk.StackPage {
name: "urlencoded";

child: $CarteroUrlencodedPayloadPane urlencoded {};
}

Gtk.StackPage {
name: "formdata";

child: $CarteroFormdataPayloadPane formdata {};
}

Gtk.StackPage {
name: "raw";

child: $CarteroRawPayloadPane raw {};
}

visible-child-name: "none";
}
}
}

Gtk.StringList entries {
strings [
_("(none)"),
_("URL Encoded"),
_("Multipart Form Data"),
"JSON",
"XML",
_("Raw"),
]
}
39 changes: 39 additions & 0 deletions data/ui/raw_payload_pane.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2024 the Cartero authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// SPDX-License-Identifier: GPL-3.0-or-later
using Gtk 4.0;
using Adw 1;
using GtkSource 5;

template $CarteroRawPayloadPane: $CarteroBasePayloadPane {
ScrolledWindow {
hexpand: true;
vexpand: true;

GtkSource.View view {
top-margin: 10;
bottom-margin: 10;
left-margin: 10;
right-margin: 10;
smart-backspace: true;
monospace: true;
buffer: buffer;
}
}
}

GtkSource.Buffer buffer {}
36 changes: 36 additions & 0 deletions data/ui/urlencoded_payload_pane.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2024 the Cartero authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// SPDX-License-Identifier: GPL-3.0-or-later
using Gtk 4.0;
using Adw 1;

template $CarteroUrlencodedPayloadPane: $CarteroBasePayloadPane {
ScrolledWindow {
hexpand: true;
vexpand: true;

Adw.Clamp {
styles [
"background"
]

maximum-size: 720;

$CarteroKeyValuePane data {}
}
}
}
1 change: 0 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ mod imp {

let obj = self.obj();
obj.set_accels_for_action("win.request", &["<Primary>Return"]);

obj.setup_app_actions();
}
}
Expand Down
Loading