From 212aef6a4ad99e4499beb9a670ef7257238f2ed7 Mon Sep 17 00:00:00 2001
From: 0xMRTT <0xMRTT@projectsegfau.lt>
Date: Mon, 4 Sep 2023 22:43:29 +0200
Subject: [PATCH] fix: replace logout dialog with a toast (#758)
---
data/gradience.gresource.xml | 1 -
data/ui/meson.build | 1 -
gradience/frontend/dialogs/log_out_dialog.py | 43 -------------------
gradience/frontend/dialogs/meson.build | 1 -
gradience/frontend/main.py | 8 ++--
.../frontend/widgets/reset_preset_group.py | 26 ++++++-----
6 files changed, 20 insertions(+), 60 deletions(-)
delete mode 100644 gradience/frontend/dialogs/log_out_dialog.py
diff --git a/data/gradience.gresource.xml b/data/gradience.gresource.xml
index 82897acdc..53001d53b 100644
--- a/data/gradience.gresource.xml
+++ b/data/gradience.gresource.xml
@@ -9,7 +9,6 @@
ui/custom_css_group.ui
ui/error_list_row.ui
ui/explore_preset_row.ui
- ui/log_out_dialog.ui
ui/monet_theming_group.ui
ui/no_plugin_window.ui
ui/option_row.ui
diff --git a/data/ui/meson.build b/data/ui/meson.build
index 8a882a9a8..68d7eccc3 100644
--- a/data/ui/meson.build
+++ b/data/ui/meson.build
@@ -4,7 +4,6 @@ blueprints = custom_target('blueprints',
'palette_shades.blp',
'option_row.blp',
'window.blp',
- 'log_out_dialog.blp',
'monet_theming_group.blp',
'app_type_dialog.blp',
'custom_css_group.blp',
diff --git a/gradience/frontend/dialogs/log_out_dialog.py b/gradience/frontend/dialogs/log_out_dialog.py
deleted file mode 100644
index 944521e7b..000000000
--- a/gradience/frontend/dialogs/log_out_dialog.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# log_out_dialog.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 .
-
-from gi.repository import Gtk, Adw
-
-from gradience.backend.constants import rootdir
-
-
-@Gtk.Template(resource_path=f"{rootdir}/ui/log_out_dialog.ui")
-class GradienceLogOutDialog(Adw.MessageDialog):
- __gtype_name__ = "GradienceLogOutDialog"
-
- def __init__(self, parent, **kwargs):
- super().__init__(**kwargs)
-
- self.parent = parent
- self.app = self.parent.get_application()
-
- if isinstance(self.parent, Gtk.Window):
- self.win = self.parent
- else:
- self.win = self.app.get_active_window()
-
- self.set_transient_for(self.win)
-
- self.add_response("ok", _("OK"))
- self.set_default_response("ok")
- self.set_close_response("ok")
diff --git a/gradience/frontend/dialogs/meson.build b/gradience/frontend/dialogs/meson.build
index 22b6a4228..a13e4451a 100644
--- a/gradience/frontend/dialogs/meson.build
+++ b/gradience/frontend/dialogs/meson.build
@@ -3,7 +3,6 @@ dialogsdir = 'gradience/frontend/dialogs'
gradience_sources = [
'__init__.py',
'app_type_dialog.py',
- 'log_out_dialog.py',
'save_dialog.py',
'unsupported_shell_dialog.py'
]
diff --git a/gradience/frontend/main.py b/gradience/frontend/main.py
index d5f212401..5dfb82588 100644
--- a/gradience/frontend/main.py
+++ b/gradience/frontend/main.py
@@ -41,7 +41,6 @@
from gradience.frontend.views.preferences_window import GradiencePreferencesWindow
from gradience.frontend.dialogs.app_type_dialog import GradienceAppTypeDialog
-from gradience.frontend.dialogs.log_out_dialog import GradienceLogOutDialog
from gradience.frontend.dialogs.save_dialog import GradienceSaveDialog
from gradience.frontend.widgets.custom_css_group import GradienceCustomCSSGroup
@@ -616,11 +615,12 @@ def apply_color_scheme(self, widget, response):
self.plugins_list.apply()
self.win.toast_overlay.add_toast(
- Adw.Toast(title=_("Preset set successfully"))
+ Adw.Toast(title=_("Preset set successfully. You may need to restart some apps and log out."))
)
- dialog = GradienceLogOutDialog(self.win)
- dialog.present()
+ toast = Adw.Toast()
+ toast.set_title(_("Preset set successfully. You may need to restart some apps and log out."))
+ self.win.toast_overlay.add_toast(toast)
def show_preferences(self, *_args):
prefs = GradiencePreferencesWindow(self.win)
diff --git a/gradience/frontend/widgets/reset_preset_group.py b/gradience/frontend/widgets/reset_preset_group.py
index aa4008871..fee4e82e8 100644
--- a/gradience/frontend/widgets/reset_preset_group.py
+++ b/gradience/frontend/widgets/reset_preset_group.py
@@ -22,8 +22,6 @@
from gradience.backend.logger import Logger
from gradience.backend.theming.preset import PresetUtils
-from gradience.frontend.dialogs.log_out_dialog import GradienceLogOutDialog
-
logging = Logger()
@@ -57,8 +55,10 @@ def on_libadw_restore_button_clicked(self, *_args):
Adw.Toast(title=_("Unable to restore GTK 4 backup"))
)
else:
- dialog = GradienceLogOutDialog(self.win)
- dialog.present()
+ toast = Adw.Toast(
+ title=_("GTK 4 preset has been restored. Please log out to apply changes."),
+ )
+ self.parent.add_toast(toast)
@Gtk.Template.Callback()
def on_libadw_reset_button_clicked(self, *_args):
@@ -69,8 +69,10 @@ def on_libadw_reset_button_clicked(self, *_args):
Adw.Toast(title=_("Unable to delete current preset"))
)
else:
- dialog = GradienceLogOutDialog(self.win)
- dialog.present()
+ toast = Adw.Toast(
+ title=_("GTK 4 theme has been reset. Please log out to apply changes."),
+ )
+ self.parent.add_toast(toast)
@Gtk.Template.Callback()
@@ -82,8 +84,10 @@ def on_gtk3_restore_button_clicked(self, *_args):
Adw.Toast(title=_("Unable to restore GTK 3 backup"))
)
else:
- dialog = GradienceLogOutDialog(self.win)
- dialog.present()
+ toast = Adw.Toast(
+ title=_("GTK 3 preset has been restored. Please log out to apply changes."),
+ )
+ self.parent.add_toast(toast)
@Gtk.Template.Callback()
def on_gtk3_reset_button_clicked(self, *_args):
@@ -94,5 +98,7 @@ def on_gtk3_reset_button_clicked(self, *_args):
Adw.Toast(title=_("Unable to delete current preset"))
)
else:
- dialog = GradienceLogOutDialog(self.win)
- dialog.present()
+ toast = Adw.Toast(
+ title=_("GTK 3 theme has been reset. Please log out to apply changes."),
+ )
+ self.parent.add_toast(toast)