Gradience/gradience/frontend/widgets/reset_preset_group.py
tfuxu e412a2c537
GNOME Shell theming support (#679)
Signed-off-by: tfuxu <73042332+tfuxu@users.noreply.github.com>
Co-authored-by: 0xMRTT <0xMRTT@evta.fr>
Co-authored-by: 0xMRTT <0xMRTT@proton.me>
Co-authored-by: daudix-UFO <ddaudix@gmail.com>
2023-05-04 13:24:18 +00:00

99 lines
3 KiB
Python

# reset_preset_group.py
#
# Change the look of Adwaita, with ease
# Copyright (C) 2023, Gradience Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from gi.repository import GLib, Gtk, Adw
from gradience.backend.constants import rootdir
from gradience.backend.logger import Logger
from gradience.backend.theming.preset import PresetUtils
from gradience.frontend.dialogs.log_out_dialog import GradienceLogOutDialog
logging = Logger()
@Gtk.Template(resource_path=f"{rootdir}/ui/reset_preset_group.ui")
class GradienceResetPresetGroup(Adw.PreferencesGroup):
__gtype_name__ = "GradienceResetPresetGroup"
def __init__(self, parent, **kwargs):
super().__init__(**kwargs)
self.parent = parent
self.app = self.parent.get_application()
self.win = self.parent
self.setup_signals()
self.setup()
def setup_signals(self):
pass
def setup(self):
pass
@Gtk.Template.Callback()
def on_libadw_restore_button_clicked(self, *_args):
try:
PresetUtils().restore_preset("gtk4")
except GLib.GError:
self.parent.add_toast(
Adw.Toast(title=_("Unable to restore GTK 4 backup"))
)
else:
dialog = GradienceLogOutDialog(self.win)
dialog.present()
@Gtk.Template.Callback()
def on_libadw_reset_button_clicked(self, *_args):
try:
PresetUtils().reset_preset("gtk4")
except GLib.GError:
self.parent.add_toast(
Adw.Toast(title=_("Unable to delete current preset"))
)
else:
dialog = GradienceLogOutDialog(self.win)
dialog.present()
@Gtk.Template.Callback()
def on_gtk3_restore_button_clicked(self, *_args):
try:
PresetUtils().restore_preset("gtk3")
except GLib.GError:
self.parent.add_toast(
Adw.Toast(title=_("Unable to restore GTK 3 backup"))
)
else:
dialog = GradienceLogOutDialog(self.win)
dialog.present()
@Gtk.Template.Callback()
def on_gtk3_reset_button_clicked(self, *_args):
try:
PresetUtils().reset_preset("gtk3")
except GLib.GError:
self.parent.add_toast(
Adw.Toast(title=_("Unable to delete current preset"))
)
else:
dialog = GradienceLogOutDialog(self.win)
dialog.present()