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