roster/src/widgets/header_row.py
Pavel Baksy cbc1972797 Initial commit: Roster HTTP client for GNOME
Roster is a modern HTTP client application for GNOME, similar to Postman,
built with GTK 4 and libadwaita.

Features:
- Send HTTP requests (GET, POST, PUT, DELETE)
- Configure custom headers with add/remove functionality
- Request body editor for POST/PUT/DELETE requests
- View response headers and bodies in separate tabs
- Track request history with JSON persistence
- Load previous requests from history with confirmation dialog
- Beautiful GNOME-native UI with libadwaita components
- HTTPie backend for reliable HTTP communication

Technical implementation:
- Python 3 with GTK 4 and libadwaita 1
- Meson build system with Flatpak support
- Custom widgets (HeaderRow, HistoryItem) with GObject signals
- Background threading for non-blocking HTTP requests
- AdwTabView for modern tabbed interface
- History persistence to ~/.config/roster/history.json
- Comprehensive error handling and user feedback
2025-12-18 11:05:33 +01:00

54 lines
1.7 KiB
Python

# header_row.py
#
# Copyright 2025 Pavel Baksy
#
# 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
from gi.repository import Gtk, GObject
@Gtk.Template(resource_path='/cz/vesp/roster/widgets/header-row.ui')
class HeaderRow(Gtk.Box):
"""Widget for editing a single HTTP header key-value pair."""
__gtype_name__ = 'HeaderRow'
key_entry = Gtk.Template.Child()
value_entry = Gtk.Template.Child()
remove_button = Gtk.Template.Child()
# Signal emitted when remove button clicked
__gsignals__ = {
'remove-requested': (GObject.SIGNAL_RUN_FIRST, None, ())
}
def __init__(self):
super().__init__()
@Gtk.Template.Callback()
def on_remove_clicked(self, button):
"""Handle remove button click."""
self.emit('remove-requested')
def get_header(self):
"""Return (key, value) tuple."""
return (self.key_entry.get_text(), self.value_entry.get_text())
def set_header(self, key: str, value: str):
"""Set header key and value."""
self.key_entry.set_text(key)
self.value_entry.set_text(value)