Compare commits
4 Commits
8ad720afc8
...
f43b5a5dc5
| Author | SHA1 | Date | |
|---|---|---|---|
| f43b5a5dc5 | |||
| fa1b51a1bd | |||
| 034f1a7443 | |||
| 4a8776a42d |
@ -31,7 +31,7 @@
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://git.bugsy.cz/beval/roster.git",
|
||||
"tag": "v0.8.2"
|
||||
"tag": "v0.8.3"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
project('roster',
|
||||
version: '0.8.2',
|
||||
version: '0.8.3',
|
||||
meson_version: '>= 1.0.0',
|
||||
default_options: [ 'warning_level=2', 'werror=false', ],
|
||||
)
|
||||
|
||||
@ -924,6 +924,9 @@ class RequestTabWidget(Gtk.Box):
|
||||
language = self._get_language_from_content_type(content_type)
|
||||
source_buffer.set_language(language)
|
||||
|
||||
# Switch to body tab
|
||||
self.response_stack.set_visible_child_name("body")
|
||||
|
||||
def display_error(self, error: str) -> None:
|
||||
"""Display error in this tab's UI."""
|
||||
self.status_label.set_text("Error")
|
||||
@ -1150,6 +1153,18 @@ class RequestTabWidget(Gtk.Box):
|
||||
|
||||
return ""
|
||||
|
||||
def _is_json_content_type(self, content_type):
|
||||
"""Check if the content type is JSON or a JSON-based format."""
|
||||
return ('application/json' in content_type
|
||||
or 'text/json' in content_type
|
||||
or '+json' in content_type)
|
||||
|
||||
def _is_xml_content_type(self, content_type):
|
||||
"""Check if the content type is XML or an XML-based format."""
|
||||
return ('application/xml' in content_type
|
||||
or 'text/xml' in content_type
|
||||
or '+xml' in content_type)
|
||||
|
||||
def _get_language_from_content_type(self, content_type):
|
||||
"""Get GtkSourceView language ID from content type."""
|
||||
if not content_type:
|
||||
@ -1157,9 +1172,9 @@ class RequestTabWidget(Gtk.Box):
|
||||
|
||||
language_manager = GtkSource.LanguageManager.get_default()
|
||||
|
||||
if 'application/json' in content_type or 'text/json' in content_type:
|
||||
if self._is_json_content_type(content_type):
|
||||
return language_manager.get_language('json')
|
||||
elif 'application/xml' in content_type or 'text/xml' in content_type:
|
||||
elif self._is_xml_content_type(content_type):
|
||||
return language_manager.get_language('xml')
|
||||
elif 'text/html' in content_type:
|
||||
return language_manager.get_language('html')
|
||||
@ -1176,10 +1191,10 @@ class RequestTabWidget(Gtk.Box):
|
||||
return body
|
||||
|
||||
try:
|
||||
if 'application/json' in content_type or 'text/json' in content_type:
|
||||
if self._is_json_content_type(content_type):
|
||||
parsed = json.loads(body)
|
||||
return json.dumps(parsed, indent=2, ensure_ascii=False)
|
||||
elif 'application/xml' in content_type or 'text/xml' in content_type:
|
||||
elif self._is_xml_content_type(content_type):
|
||||
dom = xml.dom.minidom.parseString(body)
|
||||
return dom.toprettyxml(indent=" ")
|
||||
except Exception as e:
|
||||
|
||||
@ -1183,9 +1183,8 @@ class RosterWindow(Adw.ApplicationWindow):
|
||||
return
|
||||
|
||||
# Apply variable substitution if environment is selected
|
||||
def show_export(env):
|
||||
substituted_request = request
|
||||
if widget.selected_environment_id:
|
||||
env = widget.get_selected_environment()
|
||||
if env:
|
||||
from .variable_substitution import VariableSubstitution
|
||||
substituted_request, undefined = VariableSubstitution.substitute_request(request, env)
|
||||
@ -1201,6 +1200,11 @@ class RosterWindow(Adw.ApplicationWindow):
|
||||
dialog = ExportDialog(substituted_request)
|
||||
dialog.present(self)
|
||||
|
||||
if widget.selected_environment_id:
|
||||
widget.get_selected_environment(show_export)
|
||||
else:
|
||||
show_export(None)
|
||||
|
||||
def _mark_tab_as_saved(self, saved_request_id, name, request, scripts=None):
|
||||
"""Mark the current tab as saved (clear modified flag)."""
|
||||
page = self.tab_view.get_selected_page()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user