Commit 30d749b6 authored by Roman Alifanov's avatar Roman Alifanov

icons can now be assigned to categories

parent a826b552
- name: "Example"
- name: "Gnome"
icon: preferences-desktop-display-symbolic
weight: 30
sections:
- name: Themes
......@@ -62,6 +63,7 @@
backend: gsettings
key: org.gnome.desktop.interface.enable-animations
- name: "Fonts"
icon: font-x-generic-symbolic
weight: 1
sections:
- name: Main
......@@ -101,117 +103,26 @@
lower: 0.5
step: 0.01
digits: 2
- name: "Example2"
weight: 30
sections:
- name: Themes2
type: classic
weight: 0
settings:
- name: IconTheme
type: entry
gtype: string
backend: gsettings
key: org.gnome.desktop.interface.icon-theme
- name: Style
type: choice
gtype: string
help: Prefer dark or light for Adwaita applications
backend: gsettings
key: org.gnome.desktop.interface.color-scheme
default: "default"
map:
Default: default
Light: prefer-light
Dark: prefer-dark
- name: Clock
weight: 10
settings:
- name: Weekday
type: boolean
gtype: boolean
backend: gsettings
key: org.gnome.desktop.interface.clock-show-weekday
- name: Date
type: boolean
gtype: boolean
backend: gsettings
key: org.gnome.desktop.interface.clock-show-date
- name: Seconds
type: boolean
gtype: boolean
backend: gsettings
key: org.gnome.desktop.interface.clock-show-seconds
- name: Battery
weight: 10
settings:
- name: Show percentage
type: boolean
gtype: boolean
backend: gsettings
key: org.gnome.desktop.interface.show-battery-percentage
- name: Performance
weight: 20
settings:
- name: Animations
help: Animations can be disabled for performance
type: boolean
gtype: boolean
backend: gsettings
key: org.gnome.desktop.interface.enable-animations
- name: "ThemeSwitcher"
- name: "GRUB"
icon: system-reboot-symbolic
weight: 25
sections:
- name: Themes
- name: Main
type: classic
weight: 0
settings:
- name: KV Light Theme
type: entry
gtype: string
backend: file
key: KV_LIGHT_THEME
help: Select the Kvantum light theme
default: KvLibadwaita
params:
file_path: "~/.config/ximper-unified-theme-switcher/themes"
- name: KV Dark Theme
type: entry
gtype: string
backend: file
key: KV_DARK_THEME
help: Select the Kvantum dark theme
default: KvLibadwaitaDark
params:
file_path: "~/.config/ximper-unified-theme-switcher/themes"
- name: GTK3 Light Theme
type: entry
gtype: string
backend: file
key: GTK3_LIGHT_THEME
help: Select the GTK3 light theme
default: adw-gtk3
params:
file_path: "~/.config/ximper-unified-theme-switcher/themes"
- name: GTK3 Dark Theme
type: entry
gtype: string
- name: Timeout
root: true
type: number
gtype: i
backend: file
key: GTK3_DARK_THEME
help: Select the GTK3 dark theme
default: adw-gtk3-dark
key: GRUB_TIMEOUT
help: Select the GRUB2 timeout
params:
file_path: "~/.config/ximper-unified-theme-switcher/themes"
- name: Current Theme
type: choice
gtype: string
backend: file
key: CURRENT_THEME
help: Define the current theme preference
default: "prefer-dark"
file_path: "/etc/sysconfig/grub2"
default: 5
map:
Prefer Dark: prefer-dark
Prefer Light: prefer-light
Default: default
params:
file_path: "~/.config/ximper-unified-theme-switcher/themes"
upper: 999
lower: 0
step: 1
digits: 0
......@@ -188,10 +188,11 @@ class SectionFactory:
class Category:
def __init__(self, category_data, section_factory: SectionFactory):
self.name = category_data['name']
self.icon_name = category_data.get('icon', 'preferences-system')
self.weight = category_data.get('weight', 0)
self.sections = [section_factory.create_section(s) for s in category_data.get('sections', [])]
def create_stack_page(self, stack):
def create_stack_page(self, stack, listbox):
box = Gtk.ScrolledWindow()
pref_page = Adw.PreferencesPage()
clamp = Adw.Clamp()
......@@ -212,6 +213,12 @@ class Category:
stack_page = stack.add_child(box)
stack_page.set_title(self.name)
stack_page.set_name(self.name)
row = TuneItPanelRow()
row.set_name(self.name)
row.set_title(self.name)
row.icon_name = self.icon_name
listbox.append(row)
else:
print(f"the category {self.name} is empty, ignored")
......@@ -232,22 +239,11 @@ def init_settings_stack(stack, listbox, split_view):
categories = [Category(c, section_factory) for c in merged_data]
for category in categories:
category.create_stack_page(stack)
category.create_stack_page(stack, listbox)
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)
row = TuneItPanelRow()
row.set_name(page.get_name())
row.set_title(page.get_title())
row.icon_name = "preferences-system"
listbox.append(row)
def on_row_selected(listbox, row):
if row:
page_id = row.get_name()
......@@ -259,4 +255,3 @@ def init_settings_stack(stack, listbox, split_view):
split_view.set_show_content(True)
listbox.connect("row-selected", on_row_selected)
populate_listbox_from_stack()
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