Commit 0a505ff4 authored by Roman Alifanov's avatar Roman Alifanov

more adaptability - better :)

parent 3da4c51e
......@@ -124,10 +124,13 @@ class Category:
else:
print(f"Секция {section.name} не создала виджетов.")
stack.add_child(box).set_title(self.name)
stack_page = stack.add_child(box)
stack_page.set_title(self.name)
stack_page.set_name(self.name)
def init_settings_stack(stack):
def init_settings_stack(stack, listbox, split_view):
yaml_files_directory = "/usr/share/ximper-tuneit/modules" # Укажите путь к папке с YAML файлами
yaml_data = load_yaml_files_from_directory(yaml_files_directory)
merged_data = merge_categories_by_name(yaml_data)
......@@ -139,3 +142,28 @@ def init_settings_stack(stack):
category.create_stack_page(stack)
if not stack:
print("Ошибка: settings_pagestack не найден.")
def populate_listbox_from_stack():
pages = stack.get_pages()
for i in range(pages.get_n_items()):
page = pages.get_item(i)
label = Gtk.Label(label=page.get_title(), xalign=0)
row = Gtk.ListBoxRow()
row.set_name(page.get_name())
row.set_child(label)
listbox.append(row)
def on_row_selected(listbox, row):
if row:
page_id = row.get_name()
print(f"Selected page: {page_id}")
visible_child = stack.get_child_by_name(page_id)
if visible_child:
stack.set_visible_child(visible_child)
split_view.set_show_content(True)
listbox.connect("row-selected", on_row_selected)
populate_listbox_from_stack()
......@@ -2,9 +2,22 @@ using Gtk 4.0;
using Adw 1;
template $TuneitWindow: Adw.ApplicationWindow {
content: Adw.ToolbarView {
Adw.Breakpoint {
condition ("max-width: 400sp")
setters {
header_bar.title-widget: null;
main_toolbar.top-bar-style: flat;
settinga_content_bar.visible: true;
switcher_bar.reveal: true;
settings_split_view.collapsed: true;
}
}
content: Adw.ToolbarView main_toolbar{
top-bar-style: raised_border;
[top]
Adw.HeaderBar {
Adw.HeaderBar header_bar {
[end]
MenuButton {
icon-name: "open-menu-symbolic";
......@@ -23,13 +36,20 @@ template $TuneitWindow: Adw.ApplicationWindow {
Adw.ViewStack main_stack {
Adw.ViewStackPage {
child: Box {
Adw.NavigationSplitView {
Adw.NavigationSplitView settings_split_view {
hexpand: true;
content: Adw.NavigationPage {
Adw.ToolbarView {
[top]
Adw.HeaderBar settinga_content_bar {
decoration-layout: "";
visible: false;
}
Stack settings_pagestack {}
}
};
hexpand: true;
sidebar: Adw.NavigationPage {
Adw.ClampScrollable {
margin-bottom: 8;
......@@ -37,8 +57,10 @@ template $TuneitWindow: Adw.ApplicationWindow {
margin-start: 8;
margin-top: 8;
StackSidebar {
stack: settings_pagestack;
ListBox settings_listbox {
styles [
"navigation-sidebar",
]
}
}
};
......@@ -57,6 +79,12 @@ template $TuneitWindow: Adw.ApplicationWindow {
title: _("Shop");
}
}
[bottom]
Adw.ViewSwitcherBar switcher_bar {
stack: main_stack;
}
};
default-height: 600;
......
......@@ -26,10 +26,10 @@ class TuneitWindow(Adw.ApplicationWindow):
__gtype_name__ = 'TuneitWindow'
settings_pagestack = Gtk.Template.Child()
settings_listbox = Gtk.Template.Child()
settings_split_view = Gtk.Template.Child()
def __init__(self, **kwargs):
super().__init__(**kwargs)
init_settings_stack(self.settings_pagestack)
init_settings_stack(self.settings_pagestack, self.settings_listbox, self.settings_split_view)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment