Implement a 3-column layout with a collapsible sidebar for organizing and managing HTTP requests within projects. Requests are stored in ~/.roster/requests.json for easy git versioning. Features: - Create, rename, and delete projects - Save current request to a project with custom name - Load saved requests with direct click (no confirmation dialog) - Delete saved requests with confirmation - Expandable/collapsible project folders - Context menu for project actions Technical changes: - Add SavedRequest and Project data models with JSON serialization - Implement ProjectManager for persistence to ~/.roster/requests.json - Create RequestItem and ProjectItem widgets with GTK templates - Restructure main window UI to nested GtkPaned (3-column layout) - Add project management dialogs using AdwAlertDialog - Update build system with new source files and UI resources
56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
# request_item.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/request-item.ui')
|
|
class RequestItem(Gtk.Box):
|
|
"""Widget for displaying a saved request."""
|
|
|
|
__gtype_name__ = 'RequestItem'
|
|
|
|
method_label = Gtk.Template.Child()
|
|
name_label = Gtk.Template.Child()
|
|
|
|
__gsignals__ = {
|
|
'load-requested': (GObject.SIGNAL_RUN_FIRST, None, ()),
|
|
'delete-requested': (GObject.SIGNAL_RUN_FIRST, None, ()),
|
|
}
|
|
|
|
def __init__(self, saved_request):
|
|
super().__init__()
|
|
self.saved_request = saved_request
|
|
self.method_label.set_text(saved_request.request.method)
|
|
self.name_label.set_text(saved_request.name)
|
|
|
|
# Add click gesture for loading
|
|
gesture = Gtk.GestureClick.new()
|
|
gesture.connect('released', self._on_clicked)
|
|
self.add_controller(gesture)
|
|
|
|
def _on_clicked(self, gesture, n_press, x, y):
|
|
"""Handle click to load request."""
|
|
self.emit('load-requested')
|
|
|
|
@Gtk.Template.Callback()
|
|
def on_delete_clicked(self, button):
|
|
"""Handle delete button click."""
|
|
self.emit('delete-requested')
|