diff --git a/data/ui/response_panel.blp b/data/ui/response_panel.blp index 76e6424..c4a753c 100644 --- a/data/ui/response_panel.blp +++ b/data/ui/response_panel.blp @@ -31,6 +31,20 @@ template $CarteroResponsePanel: Adw.Bin { }; } + StackPage { + name: "error"; + + child: Adw.StatusPage error_page { + icon-name: "network-error-symbolic"; + title: _("Request error"); + + child: Gtk.Label error_extra { + label: "PRUEBA"; + selectable: true; + }; + }; + } + StackPage { name: "response"; diff --git a/src/widgets/endpoint_pane.rs b/src/widgets/endpoint_pane.rs index c624829..50d95db 100644 --- a/src/widgets/endpoint_pane.rs +++ b/src/widgets/endpoint_pane.rs @@ -471,6 +471,11 @@ impl EndpointPane { imp.extract_endpoint() } + pub fn show_error(&self, error: CarteroError) { + let imp = self.imp(); + imp.response.show_error(error); + } + /// Executes an HTTP request based on the current contents of the pane. /// /// TODO: Should actually the EndpointPane do the requests? This method diff --git a/src/widgets/response_panel.rs b/src/widgets/response_panel.rs index 8c3573b..1e64f6b 100644 --- a/src/widgets/response_panel.rs +++ b/src/widgets/response_panel.rs @@ -26,16 +26,19 @@ use serde_json::Value; use sourceview5::prelude::BufferExt; use sourceview5::LanguageManager; +use crate::client::RequestError; use crate::entities::ResponseData; +use crate::error::CarteroError; use crate::objects::KeyValueItem; use glib::subclass::types::ObjectSubclassIsExt; mod imp { use std::cell::RefCell; + use crate::error::CarteroError; use crate::widgets::{CodeView, ResponseHeaders, SearchBox}; - use adw::prelude::*; use adw::subclass::bin::BinImpl; + use adw::{prelude::*, StatusPage}; use glib::object::Cast; use glib::subclass::InitializingObject; use glib::Properties; @@ -53,6 +56,10 @@ mod imp { #[template_child] stack: TemplateChild, #[template_child] + error_page: TemplateChild, + #[template_child] + error_extra: TemplateChild