fix: replace logout dialog with a toast (#758) (#816)

## Description

Replace logout message with toast
[HIG](https://developer.gnome.org/hig/patterns/feedback/toasts.html)

Fixes #758 

## Type of change

<!-- What type of change does your pull request introduce? Put an `x` in
the appropriate box . -->
- [ ] Bugfix (Change which fixes an issue)
- [ ] New feature (Change which adds new functionality)
- [x] Enhancement (Change which slightly improves existing code)
- [ ] Breaking change (This change will introduce incompatibility with
existing functionality)

## Testing

- [x] I have tested my changes and verified that they work as expected
<!-- Make sure you did this step before marking your PR as ready for
merge. -->
This commit is contained in:
David Lapshin 2023-09-04 23:54:31 +03:00 committed by GitHub
commit 5cdcfc9b8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 60 deletions

View file

@ -9,7 +9,6 @@
<file preprocess="xml-stripblanks">ui/custom_css_group.ui</file> <file preprocess="xml-stripblanks">ui/custom_css_group.ui</file>
<file preprocess="xml-stripblanks">ui/error_list_row.ui</file> <file preprocess="xml-stripblanks">ui/error_list_row.ui</file>
<file preprocess="xml-stripblanks">ui/explore_preset_row.ui</file> <file preprocess="xml-stripblanks">ui/explore_preset_row.ui</file>
<file preprocess="xml-stripblanks">ui/log_out_dialog.ui</file>
<file preprocess="xml-stripblanks">ui/monet_theming_group.ui</file> <file preprocess="xml-stripblanks">ui/monet_theming_group.ui</file>
<file preprocess="xml-stripblanks">ui/no_plugin_window.ui</file> <file preprocess="xml-stripblanks">ui/no_plugin_window.ui</file>
<file preprocess="xml-stripblanks">ui/option_row.ui</file> <file preprocess="xml-stripblanks">ui/option_row.ui</file>

View file

@ -4,7 +4,6 @@ blueprints = custom_target('blueprints',
'palette_shades.blp', 'palette_shades.blp',
'option_row.blp', 'option_row.blp',
'window.blp', 'window.blp',
'log_out_dialog.blp',
'monet_theming_group.blp', 'monet_theming_group.blp',
'app_type_dialog.blp', 'app_type_dialog.blp',
'custom_css_group.blp', 'custom_css_group.blp',

View file

@ -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 <https://www.gnu.org/licenses/>.
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")

View file

@ -3,7 +3,6 @@ dialogsdir = 'gradience/frontend/dialogs'
gradience_sources = [ gradience_sources = [
'__init__.py', '__init__.py',
'app_type_dialog.py', 'app_type_dialog.py',
'log_out_dialog.py',
'save_dialog.py', 'save_dialog.py',
'unsupported_shell_dialog.py' 'unsupported_shell_dialog.py'
] ]

View file

@ -41,7 +41,6 @@ from gradience.frontend.views.presets_manager_window import GradiencePresetWindo
from gradience.frontend.views.preferences_window import GradiencePreferencesWindow from gradience.frontend.views.preferences_window import GradiencePreferencesWindow
from gradience.frontend.dialogs.app_type_dialog import GradienceAppTypeDialog 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.dialogs.save_dialog import GradienceSaveDialog
from gradience.frontend.widgets.custom_css_group import GradienceCustomCSSGroup from gradience.frontend.widgets.custom_css_group import GradienceCustomCSSGroup
@ -616,11 +615,12 @@ class GradienceApplication(Adw.Application):
self.plugins_list.apply() self.plugins_list.apply()
self.win.toast_overlay.add_toast( 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) toast = Adw.Toast()
dialog.present() 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): def show_preferences(self, *_args):
prefs = GradiencePreferencesWindow(self.win) prefs = GradiencePreferencesWindow(self.win)

View file

@ -22,8 +22,6 @@ from gradience.backend.constants import rootdir
from gradience.backend.logger import Logger from gradience.backend.logger import Logger
from gradience.backend.theming.preset import PresetUtils from gradience.backend.theming.preset import PresetUtils
from gradience.frontend.dialogs.log_out_dialog import GradienceLogOutDialog
logging = Logger() logging = Logger()
@ -57,8 +55,10 @@ class GradienceResetPresetGroup(Adw.PreferencesGroup):
Adw.Toast(title=_("Unable to restore GTK 4 backup")) Adw.Toast(title=_("Unable to restore GTK 4 backup"))
) )
else: else:
dialog = GradienceLogOutDialog(self.win) toast = Adw.Toast(
dialog.present() title=_("GTK 4 preset has been restored. Please log out to apply changes."),
)
self.parent.add_toast(toast)
@Gtk.Template.Callback() @Gtk.Template.Callback()
def on_libadw_reset_button_clicked(self, *_args): def on_libadw_reset_button_clicked(self, *_args):
@ -69,8 +69,10 @@ class GradienceResetPresetGroup(Adw.PreferencesGroup):
Adw.Toast(title=_("Unable to delete current preset")) Adw.Toast(title=_("Unable to delete current preset"))
) )
else: else:
dialog = GradienceLogOutDialog(self.win) toast = Adw.Toast(
dialog.present() title=_("GTK 4 theme has been reset. Please log out to apply changes."),
)
self.parent.add_toast(toast)
@Gtk.Template.Callback() @Gtk.Template.Callback()
@ -82,8 +84,10 @@ class GradienceResetPresetGroup(Adw.PreferencesGroup):
Adw.Toast(title=_("Unable to restore GTK 3 backup")) Adw.Toast(title=_("Unable to restore GTK 3 backup"))
) )
else: else:
dialog = GradienceLogOutDialog(self.win) toast = Adw.Toast(
dialog.present() title=_("GTK 3 preset has been restored. Please log out to apply changes."),
)
self.parent.add_toast(toast)
@Gtk.Template.Callback() @Gtk.Template.Callback()
def on_gtk3_reset_button_clicked(self, *_args): def on_gtk3_reset_button_clicked(self, *_args):
@ -94,5 +98,7 @@ class GradienceResetPresetGroup(Adw.PreferencesGroup):
Adw.Toast(title=_("Unable to delete current preset")) Adw.Toast(title=_("Unable to delete current preset"))
) )
else: else:
dialog = GradienceLogOutDialog(self.win) toast = Adw.Toast(
dialog.present() title=_("GTK 3 theme has been reset. Please log out to apply changes."),
)
self.parent.add_toast(toast)