From 03413d13c3c43af39720c8dc05c63b2d3234851d Mon Sep 17 00:00:00 2001 From: DaPigGuy Date: Wed, 1 May 2024 20:26:21 -0700 Subject: [PATCH 1/4] Use GNOME 46 runtime for Flatpak --- flatpak/com.github.tenderowl.frog.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flatpak/com.github.tenderowl.frog.json b/flatpak/com.github.tenderowl.frog.json index 364891b..0918404 100644 --- a/flatpak/com.github.tenderowl.frog.json +++ b/flatpak/com.github.tenderowl.frog.json @@ -1,7 +1,7 @@ { "app-id" : "com.github.tenderowl.frog", "runtime" : "org.gnome.Platform", - "runtime-version" : "45", + "runtime-version" : "46", "sdk" : "org.gnome.Sdk", "command" : "frog", "finish-args" : [ From 08412c4aa0ec831c1e8982aeefcd5b292be0b93f Mon Sep 17 00:00:00 2001 From: DaPigGuy Date: Wed, 1 May 2024 20:26:41 -0700 Subject: [PATCH 2/4] Port to `Adw.AboutDialog` --- frog/main.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/frog/main.py b/frog/main.py index 5337116..1dc33be 100644 --- a/frog/main.py +++ b/frog/main.py @@ -163,7 +163,7 @@ def on_github_star(self, _action, _param) -> None: def on_about(self, _action, _param): telemetry.capture('about activated') - about_window = Adw.AboutWindow( + about_window = Adw.AboutDialog( application_name="Frog", application_icon=APP_ID, version=self.version, @@ -183,10 +183,9 @@ def on_about(self, _action, _param):

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') From 723caabb4fa0228b732f2ffe9488280e2cb646d5 Mon Sep 17 00:00:00 2001 From: DaPigGuy Date: Wed, 1 May 2024 20:31:40 -0700 Subject: [PATCH 3/4] Port to `Adw.PreferencesDialog` / Rename `PreferencesWindow` -> `PreferencesDialog` --- data/com.github.tenderowl.frog.gresource.xml | 2 +- data/meson.build | 2 +- .../{preferences_window.blp => preferences_dialog.blp} | 7 +++---- .../{preferences_window.py => preferences_dialog.py} | 9 ++++----- frog/window.py | 6 +++--- 5 files changed, 12 insertions(+), 14 deletions(-) rename data/ui/{preferences_window.blp => preferences_dialog.blp} (62%) rename frog/widgets/{preferences_window.py => preferences_dialog.py} (90%) 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 @@ ui/language_dialog.ui ui/language_row.ui ui/shortcuts.ui - ui/preferences_window.ui + ui/preferences_dialog.ui ui/preferences_general.ui ui/preferences_languages.ui ui/share_row.ui diff --git a/data/meson.build b/data/meson.build index 1b8b6d8..597b04e 100644 --- a/data/meson.build +++ b/data/meson.build @@ -56,7 +56,7 @@ subdir('icons') blueprints = custom_target('blueprints', input: files( 'ui/language_dialog.blp', - 'ui/preferences_window.blp', + 'ui/preferences_dialog.blp', 'ui/preferences_general.blp', 'ui/preferences_languages.blp', 'ui/shortcuts.blp', diff --git a/data/ui/preferences_window.blp b/data/ui/preferences_dialog.blp similarity index 62% rename from data/ui/preferences_window.blp rename to data/ui/preferences_dialog.blp index e7d74c8..7b5e0dd 100644 --- a/data/ui/preferences_window.blp +++ b/data/ui/preferences_dialog.blp @@ -1,12 +1,11 @@ using Gtk 4.0; using Adw 1; -template $PreferencesWindow : Adw.PreferencesWindow { - default-height: 480; - default-width: 640; +template $PreferencesDialog : Adw.PreferencesDialog { + content-height: 480; + content-width: 640; width-request: 360; height-request: 300; - modal: true; search-enabled: false; $PreferencesGeneralPage general_page {} diff --git a/frog/widgets/preferences_window.py b/frog/widgets/preferences_dialog.py similarity index 90% rename from frog/widgets/preferences_window.py rename to frog/widgets/preferences_dialog.py index d5e48a6..c384a54 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): 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..c09efd3 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 @@ -295,8 +295,8 @@ def on_copy_to_clipboard(self, sender) -> None: def show_preferences(self): # dialog = LanguagePacksDialog(self) - dialog = PreferencesWindow(settings=self.settings, parent=self) - dialog.present() + dialog = PreferencesDialog(settings=self.settings, parent=self) + dialog.present(self) def show_welcome_page(self, *_): self.split_view.set_show_content(False) From d2ead4c8bb75678ed9aec44ecf5c1b888aa016db Mon Sep 17 00:00:00 2001 From: DaPigGuy Date: Wed, 1 May 2024 20:34:23 -0700 Subject: [PATCH 4/4] Remove dialog dead code --- data/meson.build | 1 - data/ui/language_dialog.blp | 45 ---------------- frog/widgets/language_dialog.py | 87 ------------------------------ frog/widgets/preferences_dialog.py | 2 +- frog/window.py | 3 +- 5 files changed, 2 insertions(+), 136 deletions(-) delete mode 100644 data/ui/language_dialog.blp delete mode 100644 frog/widgets/language_dialog.py diff --git a/data/meson.build b/data/meson.build index 597b04e..e08e27f 100644 --- a/data/meson.build +++ b/data/meson.build @@ -55,7 +55,6 @@ subdir('icons') blueprints = custom_target('blueprints', input: files( - 'ui/language_dialog.blp', 'ui/preferences_dialog.blp', 'ui/preferences_general.blp', 'ui/preferences_languages.blp', diff --git a/data/ui/language_dialog.blp b/data/ui/language_dialog.blp deleted file mode 100644 index 063b584..0000000 --- a/data/ui/language_dialog.blp +++ /dev/null @@ -1,45 +0,0 @@ -using Gtk 4.0; -using Adw 1; - -template $LanguageDialog : Adw.Window { - default-width: 340; - default-height: 400; - - [titlebar] - Adw.HeaderBar header_bar { - styles ["flat"] - - [title] - Label { - label: _("Available Languages"); - single-line-mode: true; - ellipsize: end; - width-chars: 5; - - styles ["title"] - } - } - - Box main_box { - margin-top: 8; - margin-bottom: 8; - margin-start: 8; - margin-end: 8; - - Adw.Clamp { - maximum-size: 420; - - ScrolledWindow { - hscrollbar-policy: never; - - child: Adw.ClampScrollable { - maximum-size: 360; - - child: ListView list_view { - - }; - }; - } - } - } -} 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_dialog.py b/frog/widgets/preferences_dialog.py index c384a54..3f1830c 100644 --- a/frog/widgets/preferences_dialog.py +++ b/frog/widgets/preferences_dialog.py @@ -42,7 +42,7 @@ class PreferencesDialog(Adw.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.connect('show', lambda x: telemetry.capture_page_view('preferences')) diff --git a/frog/window.py b/frog/window.py index c09efd3..363e5ff 100644 --- a/frog/window.py +++ b/frog/window.py @@ -294,8 +294,7 @@ def on_copy_to_clipboard(self, sender) -> None: self.show_toast(_("Text copied")) def show_preferences(self): - # dialog = LanguagePacksDialog(self) - dialog = PreferencesDialog(settings=self.settings, parent=self) + dialog = PreferencesDialog() dialog.present(self) def show_welcome_page(self, *_):