diff --git a/data/com.github.tenderowl.frog.gresource.xml b/data/com.github.tenderowl.frog.gresource.xml
index 4aec268..34906f4 100644
--- a/data/com.github.tenderowl.frog.gresource.xml
+++ b/data/com.github.tenderowl.frog.gresource.xml
@@ -9,7 +9,7 @@
Full list of changes you may find in the repository.
We hope you enjoy our work!
- """, - transient_for=self.props.active_window + """ ) - about_window.present() + about_window.present(self.props.active_window) def on_shortcuts(self, _action, _param): telemetry.capture('shortcuts activated') diff --git a/frog/widgets/language_dialog.py b/frog/widgets/language_dialog.py deleted file mode 100644 index 5b1a9e3..0000000 --- a/frog/widgets/language_dialog.py +++ /dev/null @@ -1,87 +0,0 @@ -# language_dialog.py -# -# Copyright 2021-2023 Andrey Maksimov -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY -# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -# Except as contained in this notice, the name(s) of the above copyright -# holders shall not be used in advertising or otherwise to promote the sale, -# use or other dealings in this Software without prior written -# authorization. - -from gi.repository import Gtk, Gio, Adw - -from frog.config import RESOURCE_PREFIX -from frog.language_manager import language_manager -from frog.types.language_item import LanguageItem -from frog.widgets.language_row import LanguageRow - - -@Gtk.Template(resource_path=f'{RESOURCE_PREFIX}/ui/language_dialog.ui') -class LanguagePacksDialog(Adw.Window): - __gtype_name__ = 'LanguageDialog' - - downloaded_list = [] - - language_listbox: Gtk.ListBox = Gtk.Template.Child() - - def __init__(self, transient_for: Gtk.Window, **kwargs): - super().__init__(transient_for=transient_for, **kwargs) - - # self.resize(400, 450) - self.set_modal(True) - - self.store: Gio.ListStore = Gio.ListStore.new(LanguageItem) - self.model: Gtk.SingleSelection = Gtk.SingleSelection.new(self.store) - self.language_listbox.bind_model(self.store, - create_widget_func=LanguagePacksDialog.create_list_widget) - self.language_listbox.set_selection_mode(Gtk.SelectionMode.SINGLE) - - self.reload_language_list() - - language_manager.connect('downloaded', lambda sender, code: self.reload_language_list()) - language_manager.connect('removed', lambda sender, code: self.reload_language_list()) - - def reload_language_list(self): - self.store.remove_all() - - for lang_code in language_manager.get_available_codes(): - self.store.append(LanguageItem(code=lang_code, title=language_manager.get_language(lang_code))) - - @staticmethod - def create_list_widget(item: LanguageItem): - row = LanguageRow(item.code, item.title) - return row - - @staticmethod - def sort_rows(row1: LanguageRow, row2: LanguageRow) -> int: - """ - Used to sort languages list by its name not code. - - See https://lazka.github.io/pgi-docs/index.html#Gtk-3.0/callbacks.html#Gtk.ListBoxSortFunc for details. - """ - lang1 = language_manager.get_language(row1.lang_code) - lang2 = language_manager.get_language(row2.lang_code) - - if lang1 > lang2: - return 1 - elif lang1 < lang2: - return -1 - return 0 diff --git a/frog/widgets/preferences_window.py b/frog/widgets/preferences_dialog.py similarity index 87% rename from frog/widgets/preferences_window.py rename to frog/widgets/preferences_dialog.py index d5e48a6..3f1830c 100644 --- a/frog/widgets/preferences_window.py +++ b/frog/widgets/preferences_dialog.py @@ -1,4 +1,4 @@ -# preferences_window.py +# preferences_dialog.py # # Copyright 2021-2023 Andrey Maksimov # @@ -35,16 +35,15 @@ from frog.widgets.preferences_languages_page import PreferencesLanguagesPage -@Gtk.Template(resource_path=f'{RESOURCE_PREFIX}/ui/preferences_window.ui') -class PreferencesWindow(Adw.PreferencesWindow): - __gtype_name__ = 'PreferencesWindow' +@Gtk.Template(resource_path=f'{RESOURCE_PREFIX}/ui/preferences_dialog.ui') +class PreferencesDialog(Adw.PreferencesDialog): + __gtype_name__ = 'PreferencesDialog' general_page: PreferencesGeneralPage = Gtk.Template.Child() languages_page: PreferencesLanguagesPage = Gtk.Template.Child() - def __init__(self, settings: Settings, parent: Adw.Window = None): + def __init__(self): super().__init__() - self.set_transient_for(parent) self.connect('show', lambda x: telemetry.capture_page_view('preferences')) diff --git a/frog/window.py b/frog/window.py index a5b7442..363e5ff 100644 --- a/frog/window.py +++ b/frog/window.py @@ -42,7 +42,7 @@ from frog.services.share_service import ShareService from frog.widgets.extracted_page import ExtractedPage from frog.widgets.list_menu_row import ListMenuRow -from frog.widgets.preferences_window import PreferencesWindow +from frog.widgets.preferences_dialog import PreferencesDialog from frog.widgets.welcome_page import WelcomePage @@ -294,9 +294,8 @@ def on_copy_to_clipboard(self, sender) -> None: self.show_toast(_("Text copied")) def show_preferences(self): - # dialog = LanguagePacksDialog(self) - dialog = PreferencesWindow(settings=self.settings, parent=self) - dialog.present() + dialog = PreferencesDialog() + dialog.present(self) def show_welcome_page(self, *_): self.split_view.set_show_content(False)