[SCRIPT] Updated

This commit is contained in:
t
2025-03-31 20:14:11 +02:00
parent 810f54cb65
commit 314a27eb42
472 changed files with 11721 additions and 921 deletions
+4 -82
View File
@@ -1,83 +1,5 @@
from ignis.widgets import Widget
from ignis.gobject import IgnisGObject
from gi.repository import GObject # type: ignore
from .notifications import notifications_entry
from .about import about_entry
from .appearance import appearance_entry
from .recorder import recorder_entry
from .user import user_entry
from .elements import SettingsPage
from ignis.app import IgnisApp
from ignis.exceptions import WindowNotFoundError
from options import settings_last_page
from .settings import Settings
app = IgnisApp.get_default()
class ActivePage(IgnisGObject):
def __init__(self, name: str | None, page: SettingsPage | None):
super().__init__()
self._name = name
self._page = page
@GObject.Property
def name(self) -> str | None:
return self._name
@name.setter
def name(self, value: str | None) -> None:
self._name = value
@GObject.Property
def page(self) -> SettingsPage | None:
return self._page
@page.setter
def page(self, value: SettingsPage | None) -> None:
self._page = value
def settings_widget():
active_page = ActivePage(name="Settings", page=None)
content = Widget.Box(
hexpand=True,
vexpand=True,
child=active_page.bind("page", transform=lambda value: [value]),
)
listbox = Widget.ListBox(
rows=[
notifications_entry(active_page),
recorder_entry(active_page),
appearance_entry(active_page),
user_entry(active_page),
about_entry(active_page),
],
)
listbox.select_row(listbox.rows[settings_last_page.value])
navigation_sidebar = Widget.Box(
vertical=True,
css_classes=["settings-sidebar"],
child=[
Widget.Label(
label="Settings", halign="start", css_classes=["settings-sidebar-label"]
),
listbox,
],
)
return Widget.Box(child=[navigation_sidebar, content])
def settings_window():
try:
app.get_window("ignis_SETTINGS")
except WindowNotFoundError:
return Widget.RegularWindow(
default_width=900,
default_height=600,
resizable=False,
child=settings_widget(),
namespace="ignis_SETTINGS",
)
__all__ = [
"Settings",
]
+5
View File
@@ -0,0 +1,5 @@
from ignis.variable import Variable
from .elements import SettingsPage
fallback_page = SettingsPage(name="Settings")
active_page = Variable(value=fallback_page)
+2 -8
View File
@@ -1,6 +1,5 @@
from ignis.widgets import Widget
from .page import SettingsPage
from options import settings_last_page
class SettingsEntry(Widget.ListBoxRow):
@@ -8,15 +7,10 @@ class SettingsEntry(Widget.ListBoxRow):
self,
icon: str,
label: str,
active_page,
page: SettingsPage,
**kwargs,
):
def callback(x):
active_page.page = page
active_page.name = label
if self in self.parent.rows:
settings_last_page.set_value(self.parent.rows.index(self))
from ..active_page import active_page # avoid a circular import
super().__init__(
child=Widget.Box(
@@ -26,6 +20,6 @@ class SettingsEntry(Widget.ListBoxRow):
],
),
css_classes=["settings-sidebar-entry"],
on_activate=callback,
on_activate=lambda x: active_page.set_value(page),
**kwargs,
)
+1 -2
View File
@@ -1,4 +1,3 @@
from typing import List
from ignis.widgets import Widget
from .row import SettingsRow
from ignis.base_widget import BaseWidget
@@ -6,7 +5,7 @@ from ignis.base_widget import BaseWidget
class SettingsGroup(Widget.Box):
def __init__(
self, name: str | None, rows: List[SettingsRow | BaseWidget] = [], **kwargs
self, name: str | None, rows: list[SettingsRow | BaseWidget] = [], **kwargs
):
super().__init__(
vertical=True,
+1 -2
View File
@@ -1,11 +1,10 @@
from ignis.widgets import Widget
from typing import List
from .group import SettingsGroup
from ignis.base_widget import BaseWidget
class SettingsPage(Widget.Scroll):
def __init__(self, name: str, groups: List[SettingsGroup | BaseWidget] = []):
def __init__(self, name: str, groups: list[SettingsGroup | BaseWidget] = []):
super().__init__(
hexpand=True,
vexpand=True,
+6 -1
View File
@@ -2,7 +2,12 @@ from ignis.widgets import Widget
class SettingsRow(Widget.ListBoxRow):
def __init__(self, label: str | None = None, sublabel: str | None = None, **kwargs):
def __init__(
self,
label: str | None = None,
sublabel: str | None = None,
**kwargs,
):
super().__init__(
css_classes=["settings-row"],
child=Widget.Box(
+13
View File
@@ -0,0 +1,13 @@
from .about import AboutEntry
from .appearance import AppearanceEntry
from .notifications import NotificationsEntry
from .recorder import RecorderEntry
from .user import UserEntry
__all__ = [
"AboutEntry",
"AppearanceEntry",
"NotificationsEntry",
"RecorderEntry",
"UserEntry",
]
+52
View File
@@ -0,0 +1,52 @@
from ..elements import SettingsPage, SettingsRow, SettingsEntry, SettingsGroup
from ignis.utils import Utils
from ignis.widgets import Widget
from ignis.services.fetch import FetchService
from user_options import user_options
fetch = FetchService.get_default()
class AboutEntry(SettingsEntry):
def __init__(self):
page = SettingsPage(
name="About",
groups=[
Widget.Box(
child=[
Widget.Picture(
image=user_options.material.bind(
"dark_mode",
transform=lambda value: fetch.os_logo_text_dark
if value
else fetch.os_logo_text,
),
width=300,
height=100,
)
],
halign="center",
width_request=300,
height_request=100,
),
SettingsGroup(
name="Info",
rows=[
SettingsRow(label="OS", sublabel=fetch.os_name),
SettingsRow(
label="Ignis version", sublabel=Utils.get_ignis_version()
),
SettingsRow(label="Session type", sublabel=fetch.session_type),
SettingsRow(
label="Wayland compositor", sublabel=fetch.current_desktop
),
SettingsRow(label="Kernel", sublabel=fetch.kernel),
],
),
],
)
super().__init__(
label="About",
icon="help-about-symbolic",
page=page,
)
@@ -0,0 +1,67 @@
import os
from services.material import MaterialService
from ..elements import SwitchRow, SettingsPage, SettingsGroup, FileRow, SettingsEntry
from ignis.widgets import Widget
from user_options import user_options
from ignis.options import options
material = MaterialService.get_default()
class AppearanceEntry(SettingsEntry):
def __init__(self):
page = SettingsPage(
name="Appearance",
groups=[
SettingsGroup(
name=None,
rows=[
Widget.ListBoxRow(
child=Widget.Picture(
image=options.wallpaper.bind("wallpaper_path"),
width=1920 // 4,
height=1080 // 4,
halign="center",
style="border-radius: 1rem;",
content_fit="cover",
),
selectable=False,
activatable=False,
),
SwitchRow(
label="Dark mode",
active=user_options.material.bind("dark_mode"),
on_change=lambda x,
state: user_options.material.set_dark_mode(state),
style="margin-top: 1rem;",
),
FileRow(
label="Wallpaper path",
button_label=os.path.basename(
options.wallpaper.wallpaper_path
)
if options.wallpaper.wallpaper_path
else None,
dialog=Widget.FileDialog(
on_file_set=lambda x, file: material.generate_colors(
file.get_path()
),
initial_path=options.wallpaper.bind("wallpaper_path"),
filters=[
Widget.FileFilter(
mime_types=["image/jpeg", "image/png"],
default=True,
name="Images JPEG/PNG",
)
],
),
),
],
)
],
)
super().__init__(
label="Appearance",
icon="preferences-desktop-wallpaper-symbolic",
page=page,
)
@@ -0,0 +1,45 @@
from ..elements import SwitchRow, SettingsPage, SettingsGroup, SpinRow, SettingsEntry
from ignis.options import options
class NotificationsEntry(SettingsEntry):
def __init__(self):
page = SettingsPage(
name="Notifications",
groups=[
SettingsGroup(
name="General",
rows=[
SwitchRow(
label="Do not disturb",
active=options.notifications.bind("dnd"),
on_change=lambda x, state: options.notifications.set_dnd(
state
),
),
SpinRow(
label="Maximum popups count",
sublabel="The first popup will automatically dismiss",
value=options.notifications.bind("max_popups_count"),
min=1,
on_change=lambda x,
value: options.notifications.set_max_popups_count(value),
),
SpinRow(
label="Popup timeout",
sublabel="Timeout before popup will be dismissed, in milliseconds.",
max=100000,
step=100,
value=options.notifications.bind("popup_timeout"),
on_change=lambda x,
value: options.notifications.set_popup_timeout(value),
),
],
)
],
)
super().__init__(
label="Notifications",
icon="notification-symbolic",
page=page,
)
+61
View File
@@ -0,0 +1,61 @@
from ..elements import (
SpinRow,
SettingsPage,
SettingsGroup,
EntryRow,
FileRow,
SettingsEntry,
)
from ignis.widgets import Widget
from ignis.options import options
class RecorderEntry(SettingsEntry):
def __init__(self):
page = SettingsPage(
name="Recorder",
groups=[
SettingsGroup(
name="General",
rows=[
SpinRow(
label="Recording bitrate",
sublabel="Affects the recording quality",
value=options.recorder.bind("bitrate"),
max=640000,
width=150,
on_change=lambda x, value: options.recorder.set_bitrate(
int(value)
),
step=1000,
),
FileRow(
label="Recording path",
button_label=options.recorder.bind("default_file_location"),
dialog=Widget.FileDialog(
on_file_set=lambda x,
file: options.recorder.set_default_file_location(
file.get_path()
),
select_folder=True,
initial_path=options.recorder.default_file_location,
),
),
EntryRow(
label="Recording filename",
sublabel="Support time formatting",
text=options.recorder.bind("default_filename"),
on_change=lambda x: options.recorder.set_default_filename(
x.text
),
width=200,
),
],
)
],
)
super().__init__(
label="Recorder",
icon="media-record-symbolic",
page=page,
)
+54
View File
@@ -0,0 +1,54 @@
import os
from ..elements import SettingsGroup, SettingsPage, SettingsEntry, FileRow
from ignis.widgets import Widget
from user_options import user_options
class UserEntry(SettingsEntry):
def __init__(self):
page = SettingsPage(
name="User",
groups=[
Widget.Box(
halign="start",
style="margin-left: 2rem;",
child=[
Widget.Picture(
image=user_options.user.bind(
"avatar",
lambda value: "user-info"
if not os.path.exists(value)
else value,
),
width=96,
height=96,
style="border-radius: 10rem;",
),
Widget.Label(
label=os.getenv("USER"), css_classes=["settings-user-name"]
),
],
),
SettingsGroup(
style="margin-top: 2rem;",
valign="start",
name="General",
vexpand=True,
rows=[
FileRow(
label="Avatar",
dialog=Widget.FileDialog(
initial_path=user_options.user.bind("avatar"),
on_file_set=lambda x,
gfile: user_options.user.set_avatar(gfile.get_path()),
),
)
],
),
],
)
super().__init__(
label="User",
icon="user-available-symbolic",
page=page,
)
+71
View File
@@ -0,0 +1,71 @@
from ignis.widgets import Widget
from ignis.app import IgnisApp
from user_options import user_options
from .active_page import active_page
from .pages import (
AboutEntry,
AppearanceEntry,
NotificationsEntry,
RecorderEntry,
UserEntry,
)
app = IgnisApp.get_default()
class Settings(Widget.RegularWindow):
def __init__(self) -> None:
content = Widget.Box(
hexpand=True,
vexpand=True,
child=active_page.bind("value", transform=lambda value: [value]),
)
self._listbox = Widget.ListBox()
navigation_sidebar = Widget.Box(
vertical=True,
css_classes=["settings-sidebar"],
child=[
Widget.Label(
label="Settings",
halign="start",
css_classes=["settings-sidebar-label"],
),
self._listbox,
],
)
super().__init__(
default_width=900,
default_height=600,
resizable=False,
hide_on_close=True,
visible=False,
child=Widget.Box(child=[navigation_sidebar, content]),
namespace="ignis_SETTINGS",
)
self.connect("notify::visible", self.__on_open)
def __on_open(self, *args) -> None:
if self.visible is False:
return
if len(self._listbox.rows) != 0:
return
rows = [
NotificationsEntry(),
RecorderEntry(),
AppearanceEntry(),
UserEntry(),
AboutEntry(),
]
self._listbox.rows = rows
self._listbox.select_row(rows[user_options.settings.last_page])
self._listbox.connect("row-activated", self.__update_last_page)
def __update_last_page(self, x, row) -> None:
user_options.settings.last_page = self._listbox.rows.index(row)