Replace GtkPaned sidebar with AdwOverlaySplitView for responsive layout
This commit is contained in:
parent
bc0ee493e7
commit
b620016397
@ -26,154 +26,155 @@
|
||||
<property name="content">
|
||||
<object class="AdwToastOverlay" id="toast_overlay">
|
||||
<property name="child">
|
||||
<object class="GtkPaned" id="main_pane">
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="position">180</property>
|
||||
<property name="shrink-start-child">False</property>
|
||||
<property name="resize-start-child">True</property>
|
||||
<property name="shrink-end-child">False</property>
|
||||
<property name="resize-end-child">True</property>
|
||||
<property name="wide-handle">False</property>
|
||||
<object class="AdwOverlaySplitView" id="split_view">
|
||||
<property name="min-sidebar-width">200</property>
|
||||
<property name="max-sidebar-width">320</property>
|
||||
|
||||
<!-- LEFT: Sidebar Panel with AdwToolbarView -->
|
||||
<property name="start-child">
|
||||
<object class="AdwToolbarView">
|
||||
<property name="width-request">200</property>
|
||||
<!-- LEFT: Sidebar Panel with AdwToolbarView -->
|
||||
<property name="sidebar">
|
||||
<object class="AdwToolbarView">
|
||||
|
||||
<!-- Sidebar Header Bar -->
|
||||
<child type="top">
|
||||
<object class="AdwHeaderBar">
|
||||
<property name="show-end-title-buttons">False</property>
|
||||
<property name="show-start-title-buttons">False</property>
|
||||
<property name="title-widget">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Projects</property>
|
||||
<style>
|
||||
<class name="title"/>
|
||||
</style>
|
||||
</object>
|
||||
</property>
|
||||
<child type="start">
|
||||
<object class="GtkWindowControls">
|
||||
<property name="side">start</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkButton" id="add_project_button">
|
||||
<property name="icon-name">list-add-symbolic</property>
|
||||
<property name="tooltip-text">Add Project</property>
|
||||
<signal name="clicked" handler="on_add_project_clicked"/>
|
||||
<style>
|
||||
<class name="flat"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkMenuButton" id="import_menu_button">
|
||||
<property name="icon-name">papyrus-vertical-symbolic</property>
|
||||
<property name="tooltip-text">Import</property>
|
||||
<property name="menu-model">import_menu</property>
|
||||
<style>
|
||||
<class name="flat"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Sidebar Content -->
|
||||
<property name="content">
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
|
||||
<!-- Projects List -->
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="vexpand">True</property>
|
||||
<child>
|
||||
<object class="GtkListBox" id="projects_listbox">
|
||||
<!-- Sidebar Header Bar -->
|
||||
<child type="top">
|
||||
<object class="AdwHeaderBar">
|
||||
<property name="show-end-title-buttons">False</property>
|
||||
<property name="show-start-title-buttons">False</property>
|
||||
<property name="title-widget">
|
||||
<object class="GtkLabel">
|
||||
<property name="label">Projects</property>
|
||||
<style>
|
||||
<class name="navigation-sidebar"/>
|
||||
<class name="title"/>
|
||||
</style>
|
||||
</object>
|
||||
</property>
|
||||
<child type="start">
|
||||
<object class="GtkWindowControls">
|
||||
<property name="side">start</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkButton" id="add_project_button">
|
||||
<property name="icon-name">list-add-symbolic</property>
|
||||
<property name="tooltip-text">Add Project</property>
|
||||
<signal name="clicked" handler="on_add_project_clicked"/>
|
||||
<style>
|
||||
<class name="flat"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkMenuButton" id="import_menu_button">
|
||||
<property name="icon-name">papyrus-vertical-symbolic</property>
|
||||
<property name="tooltip-text">Import</property>
|
||||
<property name="menu-model">import_menu</property>
|
||||
<style>
|
||||
<class name="flat"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Sidebar Content -->
|
||||
<property name="content">
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
|
||||
<!-- Projects List -->
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="vexpand">True</property>
|
||||
<child>
|
||||
<object class="GtkListBox" id="projects_listbox">
|
||||
<style>
|
||||
<class name="navigation-sidebar"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
|
||||
<!-- RIGHT: Main Content Panel with AdwToolbarView -->
|
||||
<property name="end-child">
|
||||
<object class="AdwToolbarView">
|
||||
<!-- RIGHT: Main Content Panel with AdwToolbarView -->
|
||||
<property name="content">
|
||||
<object class="AdwToolbarView">
|
||||
|
||||
<!-- Main Header Bar -->
|
||||
<child type="top">
|
||||
<object class="AdwHeaderBar">
|
||||
<property name="show-title">False</property>
|
||||
<property name="show-start-title-buttons">False</property>
|
||||
<property name="show-end-title-buttons">False</property>
|
||||
<!-- Main Header Bar -->
|
||||
<child type="top">
|
||||
<object class="AdwHeaderBar">
|
||||
<property name="show-title">False</property>
|
||||
<property name="show-start-title-buttons">False</property>
|
||||
<property name="show-end-title-buttons">False</property>
|
||||
|
||||
<!-- Left side buttons -->
|
||||
<child type="start">
|
||||
<object class="GtkButton" id="save_request_button">
|
||||
<property name="icon-name">document-save-symbolic</property>
|
||||
<property name="tooltip-text">Save Current Request (Ctrl+S)</property>
|
||||
<signal name="clicked" handler="on_save_request_clicked"/>
|
||||
<style>
|
||||
<class name="flat"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<!-- Sidebar toggle (only visible when collapsed) -->
|
||||
<child type="start">
|
||||
<object class="GtkToggleButton" id="sidebar_toggle_button">
|
||||
<property name="icon-name">view-sidebar-symbolic</property>
|
||||
<property name="tooltip-text">Show Sidebar</property>
|
||||
<style>
|
||||
<class name="flat"/>
|
||||
</style>
|
||||
<binding name="visible">
|
||||
<lookup name="collapsed">split_view</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child type="start">
|
||||
<object class="GtkButton" id="export_request_button">
|
||||
<property name="icon-name">export-symbolic</property>
|
||||
<property name="tooltip-text">Export as cURL</property>
|
||||
<signal name="clicked" handler="on_export_request_clicked"/>
|
||||
<style>
|
||||
<class name="flat"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Right side buttons -->
|
||||
<child type="end">
|
||||
<object class="GtkBox">
|
||||
<property name="spacing">6</property>
|
||||
|
||||
<!-- New Request Button -->
|
||||
<child>
|
||||
<object class="GtkButton" id="new_request_button">
|
||||
<property name="icon-name">list-add-symbolic</property>
|
||||
<property name="tooltip-text">New Request (Ctrl+T)</property>
|
||||
<!-- Left side buttons -->
|
||||
<child type="start">
|
||||
<object class="GtkButton" id="save_request_button">
|
||||
<property name="icon-name">document-save-symbolic</property>
|
||||
<property name="tooltip-text">Save Current Request (Ctrl+S)</property>
|
||||
<signal name="clicked" handler="on_save_request_clicked"/>
|
||||
<style>
|
||||
<class name="flat"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child type="start">
|
||||
<object class="GtkButton" id="export_request_button">
|
||||
<property name="icon-name">export-symbolic</property>
|
||||
<property name="tooltip-text">Export as cURL</property>
|
||||
<signal name="clicked" handler="on_export_request_clicked"/>
|
||||
<style>
|
||||
<class name="flat"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Main Menu -->
|
||||
<child>
|
||||
<object class="GtkMenuButton">
|
||||
<property name="primary">True</property>
|
||||
<property name="icon-name">open-menu-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Main Menu</property>
|
||||
<property name="menu-model">primary_menu</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Window Controls -->
|
||||
<child>
|
||||
<object class="GtkWindowControls">
|
||||
<property name="side">end</property>
|
||||
<!-- Right side buttons -->
|
||||
<child type="end">
|
||||
<object class="GtkBox">
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="new_request_button">
|
||||
<property name="icon-name">list-add-symbolic</property>
|
||||
<property name="tooltip-text">New Request (Ctrl+T)</property>
|
||||
<style>
|
||||
<class name="flat"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuButton">
|
||||
<property name="primary">True</property>
|
||||
<property name="icon-name">open-menu-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Main Menu</property>
|
||||
<property name="menu-model">primary_menu</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkWindowControls">
|
||||
<property name="side">end</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Tab Bar as separate top bar -->
|
||||
<child type="top">
|
||||
@ -256,6 +257,14 @@
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
|
||||
<!-- Collapse sidebar when window is narrow -->
|
||||
<child>
|
||||
<object class="AdwBreakpoint">
|
||||
<condition>max-width: 700sp</condition>
|
||||
<setter object="split_view" property="collapsed">True</setter>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
|
||||
<menu id="primary_menu">
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
|
||||
import gi
|
||||
gi.require_version('GtkSource', '5')
|
||||
from gi.repository import Adw, Gtk, GLib, Gio, GtkSource
|
||||
from gi.repository import Adw, Gtk, GLib, Gio, GtkSource, GObject
|
||||
from typing import Dict, Optional
|
||||
import logging
|
||||
from .models import HttpRequest, HttpResponse, HistoryEntry, RequestTab
|
||||
@ -63,8 +63,9 @@ class RosterWindow(Adw.ApplicationWindow):
|
||||
tab_view = Gtk.Template.Child()
|
||||
tab_bar = Gtk.Template.Child()
|
||||
|
||||
# Panes
|
||||
main_pane = Gtk.Template.Child()
|
||||
# Split view
|
||||
split_view = Gtk.Template.Child()
|
||||
sidebar_toggle_button = Gtk.Template.Child()
|
||||
|
||||
# Sidebar widgets
|
||||
projects_listbox = Gtk.Template.Child()
|
||||
@ -102,6 +103,14 @@ class RosterWindow(Adw.ApplicationWindow):
|
||||
# Setup custom CSS
|
||||
self._setup_custom_css()
|
||||
|
||||
# Bind sidebar toggle button to split view (bidirectional)
|
||||
self.split_view.bind_property(
|
||||
'show-sidebar',
|
||||
self.sidebar_toggle_button,
|
||||
'active',
|
||||
GObject.BindingFlags.BIDIRECTIONAL | GObject.BindingFlags.SYNC_CREATE
|
||||
)
|
||||
|
||||
# Setup UI
|
||||
self._setup_tab_system()
|
||||
self._load_projects()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user