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

Settings dialog #96

Merged
merged 9 commits into from
Dec 12, 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
1 change: 1 addition & 0 deletions data/cartero.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<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="settings_dialog.ui" compressed="true" preprocess="xml-stripblanks">ui/settings_dialog.ui</file>
<file alias="urlencoded_payload_pane.ui" compressed="true" preprocess="xml-stripblanks">ui/urlencoded_payload_pane.ui</file>

<file compressed="true" preprocess="xml-stripblanks">icons/scalable/actions/horizontal-arrows-symbolic.svg</file>
Expand Down
39 changes: 38 additions & 1 deletion data/es.danirod.Cartero.gschema.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?xml version="1.0" ?>
<schemalist>
<enum id="es.danirod.Cartero.theme">
<value nick="system" value="0" />
<value nick="light" value="1" />
<value nick="dark" value="2" />
</enum>

<schema id="es.danirod.Cartero" path="/es/danirod/Cartero/">
<key name="auto-indent" type="b">
<default>false</default>
Expand All @@ -21,7 +27,6 @@
<default>'4'</default>
<summary>How many characters to pad when indenting the request body</summary>
</key>

<key name="window-width" type="i">
<default>1024</default>
<summary>How large should new windows be</summary>
Expand Down Expand Up @@ -50,5 +55,37 @@
<default>nothing</default>
<summary>The last location where a file was saved</summary>
</key>
<key name="validate-tls" type="b">
<default>true</default>
<summary>Whether to validate the TLS certificates during a request</summary>
</key>
<key name="follow-redirects" type="b">
<default>false</default>
<summary>Whether to follow redirections if that is the server response</summary>
</key>
<key name="maximum-redirects" type="u">
<default>5</default>
<summary>Maximum number of redirections to follow before giving up</summary>
</key>
<key name="request-timeout" type="d">
<default>30</default>
<summary>Maximum timeout when awaiting for an HTTP response.</summary>
</key>
<key name="application-theme" enum="es.danirod.Cartero.theme">
<default>"system"</default>
<summary>Whether to use light or dark mode.</summary>
</key>
<key name="custom-font" type="s">
<default>"Monospace 11"</default>
<summary>The custom font in use</summary>
</key>
<key name="use-system-font" type="b">
<default>true</default>
<summary>Whether to use the system font or a custom one</summary>
</key>
<key name="create-backup-files" type="b">
<default>false</default>
<summary>Whether to create backup files on save</summary>
</key>
</schema>
</schemalist>
1 change: 1 addition & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ blueprint_files = [
'ui/response_headers.blp',
'ui/response_panel.blp',
'ui/save_dialog.blp',
'ui/settings_dialog.blp',
'ui/urlencoded_payload_pane.blp',
]

Expand Down
4 changes: 4 additions & 0 deletions data/ui/code_export_pane.blp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ template $CarteroCodeExportPane: $CarteroBaseExportPane {
hexpand: true;

GtkSource.View view {
styles [
"use-cartero-font"
]

left-margin: 10;
right-margin: 10;
top-margin: 10;
Expand Down
1 change: 0 additions & 1 deletion data/ui/endpoint_pane.blp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later
using Gtk 4.0;
using Adw 1;
using GtkSource 5;

template $CarteroEndpointPane: Adw.BreakpointBin {
width-request: 400;
Expand Down
5 changes: 5 additions & 0 deletions data/ui/main_window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ menu main_menu {
}

section {
item {
label: _("Settings");
action: "app.settings";
}

submenu {
label: _("Body appearance");

Expand Down
5 changes: 4 additions & 1 deletion data/ui/raw_payload_pane.blp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
// SPDX-License-Identifier: GPL-3.0-or-later
using Gtk 4.0;
using Adw 1;
using GtkSource 5;

template $CarteroRawPayloadPane: $CarteroBasePayloadPane {
Expand All @@ -25,6 +24,10 @@ template $CarteroRawPayloadPane: $CarteroBasePayloadPane {
vexpand: true;

GtkSource.View view {
styles [
"use-cartero-font"
]

top-margin: 10;
bottom-margin: 10;
left-margin: 10;
Expand Down
4 changes: 4 additions & 0 deletions data/ui/response_panel.blp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ template $CarteroResponsePanel: Adw.Bin {
vexpand: true;

GtkSource.View response_body {
styles [
"use-cartero-font"
]

top-margin: 10;
bottom-margin: 10;
left-margin: 10;
Expand Down
121 changes: 121 additions & 0 deletions data/ui/settings_dialog.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* 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 $CarteroSettingsDialog: Adw.PreferencesDialog {
title: _("Settings");
content-width: 480;
content-height: 640;
width-request: 360;
height-request: 480;
search-enabled: false;

Adw.PreferencesPage {
title: _("General");
icon-name: "applications-system";

Adw.PreferencesGroup {
title: _("HTTP client settings");
description: _("Settings used when performing HTTP requests.");

Adw.SwitchRow option_validate_tls {
title: _("Enforce TLS validation");
subtitle: _("If disabled, invalid TLS certificates will not fail a request.");
}

Adw.ExpanderRow option_follow_redirects {
title: _("Follow redirects");
subtitle: _("If enabled, a responses that return HTTP 3xx will be chained.");
show-enable-switch: true;
enable-expansion: true;

Adw.SpinRow option_maximum_redirects {
title: _("Maximum redirects");

adjustment: Gtk.Adjustment {
lower: 1;
upper: 1000;
value: 1;
step-increment: 1;
};
}
}

Adw.SpinRow option_timeout {
title: _("Request timeout");
digits: 3;

adjustment: Gtk.Adjustment {
lower: 0;
upper: 1000;
value: 5.0;
step-increment: 0.1;
};
}
}

Adw.PreferencesGroup {
title: _("File settings");
description: _("Settings related to storage.");

Adw.SwitchRow option_create_backups {
title: _("Create backup files");
subtitle: _("You might not want to enable this if you are already using a version control such as Git");
}
}

Adw.PreferencesGroup {
title: _("Appearance");
description: _("Display settings.");

Adw.ComboRow option_theme {
title: _("Application theme");
subtitle: _("The style to use in the application");

model: Gtk.StringList {
strings [
_("Follow system settings"),
_("Light mode"),
_("Dark mode"),
]
};
}

Adw.SwitchRow option_use_system_font {
title: _("Use system font");
}

Adw.ActionRow {
title: _("Custom font");

Gtk.FontDialogButton option_custom_font {
styles [
"flat"
]

dialog: font_dialog;
vexpand: false;
valign: center;
}
}
}
}
}

Gtk.FontDialog font_dialog {}
1 change: 1 addition & 0 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ data/ui/raw_payload_pane.blp
data/ui/response_headers.blp
data/ui/response_panel.blp
data/ui/save_dialog.blp
data/ui/settings_dialog.blp
data/ui/urlencoded_payload_pane.blp

src/app.rs
Expand Down
Loading