roster/src/widgets/header_row.py
vesp 0d5bb837f5 Add header change tracking to tab modification detection
Previously, changes to HTTP headers (adding, editing, or removing headers)
were not being tracked, causing tabs to not show the modified indicator (•)
when only header values changed.

Changes:
- Add 'changed' signal to HeaderRow widget that emits when key or value entries change
- Connect HeaderRow 'changed' signal to window's _on_request_changed handler
- Real-time tab modification tracking now includes all header edits

This completes the comprehensive change tracking system for tabs:
- URL changes ✓
- Method changes ✓
- Body changes ✓
- Syntax changes ✓
- Header changes ✓ (now fixed)
2025-12-22 00:49:54 +01:00

63 lines
2.0 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()
# Signals
__gsignals__ = {
'remove-requested': (GObject.SIGNAL_RUN_FIRST, None, ()),
'changed': (GObject.SIGNAL_RUN_FIRST, None, ())
}
def __init__(self):
super().__init__()
# Connect to entry changes to emit our own changed signal
self.key_entry.connect('changed', self._on_entry_changed)
self.value_entry.connect('changed', self._on_entry_changed)
def _on_entry_changed(self, entry):
"""Handle changes to key or value entries."""
self.emit('changed')
@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)