[SCRIPT] Updated
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
from .settings import Settings
|
||||
|
||||
__all__ = [
|
||||
"Settings",
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
from ignis.variable import Variable
|
||||
from .elements import SettingsPage
|
||||
|
||||
fallback_page = SettingsPage(name="Settings")
|
||||
active_page = Variable(value=fallback_page)
|
||||
@@ -0,0 +1,20 @@
|
||||
from .row import SettingsRow
|
||||
from .page import SettingsPage
|
||||
from .group import SettingsGroup
|
||||
from .switchrow import SwitchRow
|
||||
from .filerow import FileRow
|
||||
from .spinrow import SpinRow
|
||||
from .entryrow import EntryRow
|
||||
from .entry import SettingsEntry
|
||||
|
||||
__all__ = [
|
||||
"SettingsRow",
|
||||
"SettingsPage",
|
||||
"SettingsGroup",
|
||||
"SettingsRow",
|
||||
"SwitchRow",
|
||||
"FileRow",
|
||||
"SpinRow",
|
||||
"EntryRow",
|
||||
"SettingsEntry",
|
||||
]
|
||||
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,25 @@
|
||||
from ignis.widgets import Widget
|
||||
from .page import SettingsPage
|
||||
|
||||
|
||||
class SettingsEntry(Widget.ListBoxRow):
|
||||
def __init__(
|
||||
self,
|
||||
icon: str,
|
||||
label: str,
|
||||
page: SettingsPage,
|
||||
**kwargs,
|
||||
):
|
||||
from ..active_page import active_page # avoid a circular import
|
||||
|
||||
super().__init__(
|
||||
child=Widget.Box(
|
||||
child=[
|
||||
Widget.Icon(image=icon, pixel_size=20),
|
||||
Widget.Label(label=label, style="margin-left: 0.75rem;"),
|
||||
],
|
||||
),
|
||||
css_classes=["settings-sidebar-entry"],
|
||||
on_activate=lambda x: active_page.set_value(page),
|
||||
**kwargs,
|
||||
)
|
||||
@@ -0,0 +1,24 @@
|
||||
from ignis.widgets import Widget
|
||||
from .row import SettingsRow
|
||||
from typing import Callable
|
||||
from ignis.gobject import Binding
|
||||
|
||||
|
||||
class EntryRow(SettingsRow):
|
||||
def __init__(
|
||||
self,
|
||||
text: str | Binding | None = None,
|
||||
on_change: Callable | None = None,
|
||||
width: int | None = None,
|
||||
**kwargs,
|
||||
):
|
||||
super().__init__(**kwargs)
|
||||
self._entry = Widget.Entry(
|
||||
on_change=on_change,
|
||||
text=text,
|
||||
halign="end",
|
||||
valign="center",
|
||||
width_request=width,
|
||||
hexpand=True,
|
||||
)
|
||||
self.child.append(self._entry)
|
||||
@@ -0,0 +1,23 @@
|
||||
from ignis.widgets import Widget
|
||||
from .row import SettingsRow
|
||||
from ignis.gobject import Binding
|
||||
|
||||
|
||||
class FileRow(SettingsRow):
|
||||
def __init__(
|
||||
self,
|
||||
dialog: Widget.FileDialog,
|
||||
button_label: str | Binding | None = None,
|
||||
**kwargs,
|
||||
):
|
||||
super().__init__(**kwargs)
|
||||
self._button = Widget.FileChooserButton(
|
||||
dialog=dialog,
|
||||
label=Widget.Label(
|
||||
label=button_label, ellipsize="start", max_width_chars=20
|
||||
),
|
||||
hexpand=True,
|
||||
halign="end",
|
||||
)
|
||||
|
||||
self.child.append(self._button)
|
||||
@@ -0,0 +1,23 @@
|
||||
from ignis.widgets import Widget
|
||||
from .row import SettingsRow
|
||||
from ignis.base_widget import BaseWidget
|
||||
|
||||
|
||||
class SettingsGroup(Widget.Box):
|
||||
def __init__(
|
||||
self, name: str | None, rows: list[SettingsRow | BaseWidget] = [], **kwargs
|
||||
):
|
||||
super().__init__(
|
||||
vertical=True,
|
||||
css_classes=["settings-group"],
|
||||
child=[
|
||||
Widget.Label(
|
||||
label=name,
|
||||
css_classes=["settings-group-name"],
|
||||
halign="start",
|
||||
visible=True if name else False,
|
||||
),
|
||||
Widget.ListBox(rows=[*rows]),
|
||||
],
|
||||
**kwargs,
|
||||
)
|
||||
@@ -0,0 +1,23 @@
|
||||
from ignis.widgets import Widget
|
||||
from .group import SettingsGroup
|
||||
from ignis.base_widget import BaseWidget
|
||||
|
||||
|
||||
class SettingsPage(Widget.Scroll):
|
||||
def __init__(self, name: str, groups: list[SettingsGroup | BaseWidget] = []):
|
||||
super().__init__(
|
||||
hexpand=True,
|
||||
vexpand=True,
|
||||
child=Widget.Box(
|
||||
vertical=True,
|
||||
hexpand=True,
|
||||
vexpand=True,
|
||||
css_classes=["settings-page"],
|
||||
child=[
|
||||
Widget.Label(
|
||||
label=name, css_classes=["settings-page-name"], halign="start"
|
||||
),
|
||||
*groups,
|
||||
],
|
||||
),
|
||||
)
|
||||
@@ -0,0 +1,39 @@
|
||||
from ignis.widgets import Widget
|
||||
|
||||
|
||||
class SettingsRow(Widget.ListBoxRow):
|
||||
def __init__(
|
||||
self,
|
||||
label: str | None = None,
|
||||
sublabel: str | None = None,
|
||||
**kwargs,
|
||||
):
|
||||
super().__init__(
|
||||
css_classes=["settings-row"],
|
||||
child=Widget.Box(
|
||||
child=[
|
||||
Widget.Box(
|
||||
vertical=True,
|
||||
child=[
|
||||
Widget.Label(
|
||||
label=label,
|
||||
css_classes=["settings-row-label"],
|
||||
halign="start",
|
||||
vexpand=True,
|
||||
wrap=True,
|
||||
visible=True if label else False,
|
||||
),
|
||||
Widget.Label(
|
||||
label=sublabel,
|
||||
css_classes=["settings-row-sublabel"],
|
||||
halign="start",
|
||||
vexpand=True,
|
||||
wrap=True,
|
||||
visible=True if sublabel else False,
|
||||
),
|
||||
],
|
||||
)
|
||||
]
|
||||
),
|
||||
**kwargs,
|
||||
)
|
||||
@@ -0,0 +1,30 @@
|
||||
from ignis.widgets import Widget
|
||||
from .row import SettingsRow
|
||||
from typing import Callable
|
||||
from ignis.gobject import Binding
|
||||
|
||||
|
||||
class SpinRow(SettingsRow):
|
||||
def __init__(
|
||||
self,
|
||||
value: int | Binding = 0,
|
||||
on_change: Callable | None = None,
|
||||
min: int = 0,
|
||||
max: int = 100,
|
||||
step: int = 1,
|
||||
width: int = 0,
|
||||
**kwargs,
|
||||
):
|
||||
super().__init__(**kwargs)
|
||||
self._spin_button = Widget.SpinButton(
|
||||
value=value,
|
||||
on_change=on_change,
|
||||
min=min,
|
||||
max=max,
|
||||
halign="end",
|
||||
valign="center",
|
||||
width_request=width,
|
||||
hexpand=True,
|
||||
step=step,
|
||||
)
|
||||
self.child.append(self._spin_button)
|
||||
@@ -0,0 +1,25 @@
|
||||
from ignis.widgets import Widget
|
||||
from .row import SettingsRow
|
||||
from typing import Callable
|
||||
from ignis.gobject import Binding
|
||||
|
||||
|
||||
class SwitchRow(SettingsRow):
|
||||
def __init__(
|
||||
self,
|
||||
active: bool | Binding = False,
|
||||
on_change: Callable | None = None,
|
||||
**kwargs,
|
||||
):
|
||||
super().__init__(**kwargs)
|
||||
self._switch = Widget.Switch(
|
||||
active=active,
|
||||
on_change=on_change,
|
||||
halign="end",
|
||||
valign="center",
|
||||
hexpand=True,
|
||||
)
|
||||
self.on_activate = lambda x: self._switch.emit(
|
||||
"activate"
|
||||
) # if set "active" property animation will not work
|
||||
self.child.append(self._switch)
|
||||
@@ -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",
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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,
|
||||
)
|
||||
@@ -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,
|
||||
)
|
||||
@@ -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,
|
||||
)
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user