Commit 4ec846c6 authored by Roman Alifanov's avatar Roman Alifanov

preferences: add skip root modules setting

parent 6bcf27a0
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<schemalist gettext-domain="tuneit"> <schemalist gettext-domain="tuneit">
<schema id="ru.ximperlinux.TuneIt" path="/ru.ximperlinux.TuneIt/"> <schema id="ru.ximperlinux.TuneIt" path="/ru.ximperlinux.TuneIt/">
<key name="show-root-modules" type="b"> <key name="show-root-modules" type="b">
<default>false</default> <default>true</default>
<description>Show modules that require root permissions</description> <description>Show modules that require root permissions</description>
</key> </key>
<key name="disabled-modules" type="as"> <key name="disabled-modules" type="as">
......
...@@ -12,6 +12,20 @@ class PreferencesDialog(Adw.PreferencesDialog): ...@@ -12,6 +12,20 @@ class PreferencesDialog(Adw.PreferencesDialog):
icon_name="application-x-addon-symbolic" icon_name="application-x-addon-symbolic"
) )
general_group = Adw.PreferencesGroup(
title=_("General"),
)
show_root_row = Adw.SwitchRow(
title=_("Show modules that require root permissions"),
subtitle=_("You need root rights to read and modify system configs."),
active=self.settings.get_boolean("show-root-modules")
)
show_root_row.connect("notify::active", self._on_show_root_toggled)
general_group.add(show_root_row)
page.add(general_group)
group = Adw.PreferencesGroup( group = Adw.PreferencesGroup(
title=_("Available Modules"), title=_("Available Modules"),
description=_("Restart the application to apply changes") description=_("Restart the application to apply changes")
...@@ -32,6 +46,9 @@ class PreferencesDialog(Adw.PreferencesDialog): ...@@ -32,6 +46,9 @@ class PreferencesDialog(Adw.PreferencesDialog):
page.add(group) page.add(group)
self.add(page) self.add(page)
def _on_show_root_toggled(self, row, pspec):
self.settings.set_boolean("show-root-modules", row.get_active())
def _on_switch_toggled(self, row, pspec, module_name): def _on_switch_toggled(self, row, pspec, module_name):
disabled = list(self.settings.get_strv("disabled-modules")) disabled = list(self.settings.get_strv("disabled-modules"))
if row.get_active(): if row.get_active():
......
from gi.repository import Gio
from .base import BaseSetting from .base import BaseSetting
from .widgets import WidgetFactory from .widgets import WidgetFactory
from ..backends import backend_factory from ..backends import backend_factory
...@@ -18,6 +20,10 @@ class Setting(BaseSetting): ...@@ -18,6 +20,10 @@ class Setting(BaseSetting):
def create_row(self): def create_row(self):
if self.root is True: if self.root is True:
self.logger.info("Root is true") self.logger.info("Root is true")
settings = Gio.Settings.new("ru.ximperlinux.TuneIt")
if not settings.get_boolean("show-root-modules"):
self.logger.info("Root modules are hidden, skipping")
return None
if dclient is not None: if dclient is not None:
self.widget = WidgetFactory.create_widget(self) self.widget = WidgetFactory.create_widget(self)
if not self.widget: if not self.widget:
......
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