From 3e1ef88a1fb017a01c6faf216fdeeeddd459bdf8 Mon Sep 17 00:00:00 2001 From: kramo Date: Sat, 27 Jan 2024 08:52:50 +0100 Subject: [PATCH 1/5] Port to libadwaita 1.5 widgets --- .../{details_window.py => details_dialog.py} | 10 +++------- cartridges/importer/importer.py | 2 +- cartridges/main.py | 17 ++++++++--------- cartridges/meson.build | 4 ++-- cartridges/preferences.py | 5 ++--- data/cartridges.gresource.xml.in | 2 +- .../{details-window.blp => details-dialog.blp} | 17 ++++------------- data/gtk/preferences.blp | 3 ++- data/gtk/window.blp | 4 +++- data/hu.kramo.Cartridges.metainfo.xml.in | 2 +- data/meson.build | 2 +- flatpak/hu.kramo.Cartridges.Devel.json | 2 +- 12 files changed, 29 insertions(+), 41 deletions(-) rename cartridges/{details_window.py => details_dialog.py} (98%) rename data/gtk/{details-window.blp => details-dialog.blp} (93%) diff --git a/cartridges/details_window.py b/cartridges/details_dialog.py similarity index 98% rename from cartridges/details_window.py rename to cartridges/details_dialog.py index 3afcb60..84d1454 100644 --- a/cartridges/details_window.py +++ b/cartridges/details_dialog.py @@ -36,9 +36,9 @@ from cartridges.utils.create_dialog import create_dialog from cartridges.utils.save_cover import convert_cover, save_cover -@Gtk.Template(resource_path=shared.PREFIX + "/gtk/details-window.ui") -class DetailsWindow(Adw.Window): - __gtype_name__ = "DetailsWindow" +@Gtk.Template(resource_path=shared.PREFIX + "/gtk/details-dialog.ui") +class DetailsDialog(Adw.Dialog): + __gtype_name__ = "DetailsDialog" cover_overlay = Gtk.Template.Child() cover = Gtk.Template.Child() @@ -61,12 +61,9 @@ class DetailsWindow(Adw.Window): def __init__(self, game: Optional[Game] = None, **kwargs: Any): super().__init__(**kwargs) - self.game: Game = game self.game_cover: GameCover = GameCover({self.cover}) - self.set_transient_for(shared.win) - if self.game: self.set_title(_("Game Details")) self.name.set_text(self.game.name) @@ -152,7 +149,6 @@ class DetailsWindow(Adw.Window): self.executable.connect("entry-activated", self.apply_preferences) self.set_focus(self.name) - self.present() def delete_pixbuf(self, *_args: Any) -> None: self.game_cover.new_cover() diff --git a/cartridges/importer/importer.py b/cartridges/importer/importer.py index 0f96615..65194e4 100644 --- a/cartridges/importer/importer.py +++ b/cartridges/importer/importer.py @@ -407,7 +407,7 @@ class Importer(ErrorProducer): self, page_name: Optional[str] = None, expander_row: Optional[Adw.ExpanderRow] = None, - ) -> Adw.PreferencesWindow: + ) -> Adw.PreferencesDialog: return shared.win.get_application().on_preferences_action( page_name=page_name, expander_row=expander_row ) diff --git a/cartridges/main.py b/cartridges/main.py index 5914208..3023663 100644 --- a/cartridges/main.py +++ b/cartridges/main.py @@ -34,7 +34,7 @@ gi.require_version("Adw", "1") from gi.repository import Adw, Gio, GLib, Gtk from cartridges import shared -from cartridges.details_window import DetailsWindow +from cartridges.details_dialog import DetailsDialog from cartridges.game import Game from cartridges.importer.bottles_source import BottlesSource from cartridges.importer.desktop_source import DesktopSource @@ -47,7 +47,7 @@ from cartridges.importer.lutris_source import LutrisSource from cartridges.importer.retroarch_source import RetroarchSource from cartridges.importer.steam_source import SteamSource from cartridges.logging.setup import log_system_info, setup_logging -from cartridges.preferences import PreferencesWindow +from cartridges.preferences import CartridgesPreferences from cartridges.store.managers.cover_manager import CoverManager from cartridges.store.managers.display_manager import DisplayManager from cartridges.store.managers.file_manager import FileManager @@ -246,10 +246,9 @@ class CartridgesApplication(Adw.Application): debug_str += log_file.read() log_file.close() - about = Adw.AboutWindow.new_from_appdata( + about = Adw.AboutDialog.new_from_appdata( shared.PREFIX + "/" + shared.APP_ID + ".metainfo.xml", shared.VERSION ) - about.set_transient_for(shared.win) about.set_developers( ( "kramo https://kramo.hu", @@ -275,7 +274,7 @@ class CartridgesApplication(Adw.Application): Gtk.License.CUSTOM, "Steam and the Steam logo are trademarks and/or registered trademarks of Valve Corporation in the U.S. and/or other countries.", # pylint: disable=line-too-long ) - about.present() + about.present(shared.win) def on_preferences_action( self, @@ -284,12 +283,12 @@ class CartridgesApplication(Adw.Application): page_name: Optional[str] = None, expander_row: Optional[str] = None, ) -> CartridgesWindow: - win = PreferencesWindow() + win = CartridgesPreferences() if page_name: win.set_visible_page_name(page_name) if expander_row: getattr(win, expander_row).set_expanded(True) - win.present() + win.present(shared.win) return win @@ -300,10 +299,10 @@ class CartridgesApplication(Adw.Application): shared.win.active_game.toggle_hidden() def on_edit_game_action(self, *_args: Any) -> None: - DetailsWindow(shared.win.active_game) + DetailsDialog(shared.win.active_game).present(shared.win) def on_add_game_action(self, *_args: Any) -> None: - DetailsWindow() + DetailsDialog().present(shared.win) def on_import_action(self, *_args: Any) -> None: shared.importer = Importer() diff --git a/cartridges/meson.build b/cartridges/meson.build index 535284d..61da5c3 100644 --- a/cartridges/meson.build +++ b/cartridges/meson.build @@ -18,7 +18,7 @@ install_data( 'main.py', 'window.py', 'preferences.py', - 'details_window.py', + 'details_dialog.py', 'game.py', 'game_cover.py', configure_file( @@ -28,4 +28,4 @@ install_data( ) ], install_dir: moduledir -) \ No newline at end of file +) diff --git a/cartridges/preferences.py b/cartridges/preferences.py index a0d158e..cdd37d8 100644 --- a/cartridges/preferences.py +++ b/cartridges/preferences.py @@ -43,8 +43,8 @@ from cartridges.utils.create_dialog import create_dialog @Gtk.Template(resource_path=shared.PREFIX + "/gtk/preferences.ui") -class PreferencesWindow(Adw.PreferencesWindow): - __gtype_name__ = "PreferencesWindow" +class CartridgesPreferences(Adw.PreferencesDialog): + __gtype_name__ = "CartridgesPreferences" general_page = Gtk.Template.Child() import_page = Gtk.Template.Child() @@ -123,7 +123,6 @@ class PreferencesWindow(Adw.PreferencesWindow): def __init__(self, **kwargs: Any) -> None: super().__init__(**kwargs) self.file_chooser = Gtk.FileDialog() - self.set_transient_for(shared.win) self.toast = Adw.Toast.new(_("All games removed")) self.toast.set_button_label(_("Undo")) diff --git a/data/cartridges.gresource.xml.in b/data/cartridges.gresource.xml.in index 4704591..4c2ab68 100644 --- a/data/cartridges.gresource.xml.in +++ b/data/cartridges.gresource.xml.in @@ -6,7 +6,7 @@ gtk/help-overlay.ui gtk/game.ui gtk/preferences.ui - gtk/details-window.ui + gtk/details-dialog.ui gtk/style.css gtk/style-dark.css library_placeholder.svg diff --git a/data/gtk/details-window.blp b/data/gtk/details-dialog.blp similarity index 93% rename from data/gtk/details-window.blp rename to data/gtk/details-dialog.blp index 2bef55d..add24a6 100644 --- a/data/gtk/details-window.blp +++ b/data/gtk/details-dialog.blp @@ -1,17 +1,8 @@ using Gtk 4.0; using Adw 1; -template $DetailsWindow : Adw.Window { - default-width: 480; // Same as Nautilus' properties window - default-height: -1; - modal: true; - - ShortcutController { - Shortcut { - trigger: "Escape"; - action: "action(window.close)"; - } - } +template $DetailsDialog : Adw.Dialog { + content-width: 480; Adw.ToolbarView { @@ -85,7 +76,7 @@ template $DetailsWindow : Adw.Window { Picture cover { width-request: 200; height-request: 300; - + styles [ "card" ] @@ -149,4 +140,4 @@ template $DetailsWindow : Adw.Window { } } } -} \ No newline at end of file +} diff --git a/data/gtk/preferences.blp b/data/gtk/preferences.blp index 0badc13..1c84b51 100644 --- a/data/gtk/preferences.blp +++ b/data/gtk/preferences.blp @@ -1,7 +1,8 @@ using Gtk 4.0; using Adw 1; -template $PreferencesWindow : Adw.PreferencesWindow { +template $CartridgesPreferences : Adw.PreferencesDialog { + search-enabled: true; Adw.PreferencesPage general_page { name: "general"; diff --git a/data/gtk/window.blp b/data/gtk/window.blp index 277198f..7217a79 100644 --- a/data/gtk/window.blp +++ b/data/gtk/window.blp @@ -45,7 +45,7 @@ Adw.StatusPage hidden_notice_empty { template $CartridgesWindow : Adw.ApplicationWindow { title: _("Cartridges"); - width-request: 281; + width-request: 360; height-request: 100; Adw.Breakpoint { @@ -75,6 +75,8 @@ template $CartridgesWindow : Adw.ApplicationWindow { title: _("All Games"); Adw.OverlaySplitView overlay_split_view { + sidebar-width-fraction: .2; + [sidebar] Adw.NavigationPage { title: _("Cartridges"); diff --git a/data/hu.kramo.Cartridges.metainfo.xml.in b/data/hu.kramo.Cartridges.metainfo.xml.in index 4afa764..d4b0e43 100644 --- a/data/hu.kramo.Cartridges.metainfo.xml.in +++ b/data/hu.kramo.Cartridges.metainfo.xml.in @@ -28,7 +28,7 @@ touch - 280 + 360 diff --git a/data/meson.build b/data/meson.build index 756c573..cf98149 100644 --- a/data/meson.build +++ b/data/meson.build @@ -4,7 +4,7 @@ blueprints = custom_target('blueprints', 'gtk/window.blp', 'gtk/game.blp', 'gtk/preferences.blp', - 'gtk/details-window.blp' + 'gtk/details-dialog.blp' ), output: '.', command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'], diff --git a/flatpak/hu.kramo.Cartridges.Devel.json b/flatpak/hu.kramo.Cartridges.Devel.json index 69850b9..3ea2258 100644 --- a/flatpak/hu.kramo.Cartridges.Devel.json +++ b/flatpak/hu.kramo.Cartridges.Devel.json @@ -1,7 +1,7 @@ { "id" : "hu.kramo.Cartridges.Devel", "runtime" : "org.gnome.Platform", - "runtime-version" : "45", + "runtime-version" : "master", "sdk" : "org.gnome.Sdk", "command" : "cartridges", "finish-args" : [ From 303f2a2063b13b19705e8b5cbb8a39e4b932f04f Mon Sep 17 00:00:00 2001 From: kramo Date: Sat, 27 Jan 2024 09:34:30 +0100 Subject: [PATCH 2/5] Fix CI, escape not working --- .github/workflows/ci.yml | 6 ++++-- cartridges/main.py | 1 - cartridges/window.py | 9 --------- data/gtk/window.blp | 12 ++++++++++++ 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c9ce2c..c70bce6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,8 @@ jobs: with: bundle: hu.kramo.Cartridges.Devel.flatpak manifest-path: flatpak/hu.kramo.Cartridges.Devel.json + repository-url: https://nightly.gnome.org/gnome-nightly.flatpakrepo + repository-name: gnome-nightly windows: name: Windows @@ -47,7 +49,7 @@ jobs: - name: Test shell: msys2 {0} run: | - set +e + set +e timeout 2 cartridges; [ "$?" -eq "124" ] - name: Inno Setup @@ -57,4 +59,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: Windows Installer - path: _build/windows/Output/Cartridges Setup.exe \ No newline at end of file + path: _build/windows/Output/Cartridges Setup.exe diff --git a/cartridges/main.py b/cartridges/main.py index 3023663..65042e5 100644 --- a/cartridges/main.py +++ b/cartridges/main.py @@ -153,7 +153,6 @@ class CartridgesApplication(Adw.Application): ("go_to_parent", ("Up",), shared.win), ("go_home", ("Home",), shared.win), ("toggle_search", ("f",), shared.win), - ("escape", ("Escape",), shared.win), ("undo", ("z",), shared.win), ("open_menu", ("F10",), shared.win), ("close", ("w",), shared.win), diff --git a/cartridges/window.py b/cartridges/window.py index 81350b1..1fb9553 100644 --- a/cartridges/window.py +++ b/cartridges/window.py @@ -469,15 +469,6 @@ class CartridgesWindow(Adw.ApplicationWindow): search_entry.set_text("") - def on_escape_action(self, *_args: Any) -> None: - if ( - self.get_focus() == self.search_entry.get_focus_child() - or self.hidden_search_entry.get_focus_child() - ): - self.on_toggle_search_action() - else: - self.navigation_view.pop() - def show_details_page_search(self, widget: Gtk.Widget) -> None: library = ( self.hidden_library if widget == self.hidden_search_entry else self.library diff --git a/data/gtk/window.blp b/data/gtk/window.blp index 7217a79..bc0f6dc 100644 --- a/data/gtk/window.blp +++ b/data/gtk/window.blp @@ -201,6 +201,13 @@ template $CartridgesWindow : Adw.ApplicationWindow { SearchEntry search_entry { placeholder-text: _("Search"); hexpand: true; + + ShortcutController { + Shortcut { + trigger: "Escape"; + action: "action(win.toggle_search)"; + } + } } } } @@ -261,6 +268,11 @@ Adw.NavigationPage hidden_library_page { SearchEntry hidden_search_entry { placeholder-text: _("Search"); hexpand: true; + + Shortcut { + trigger: "Escape"; + action: "action(win.toggle_search)"; + } } } } From b086766b774883598c1faaf663b0d608b1a1c6c3 Mon Sep 17 00:00:00 2001 From: kramo <93832451+kra-mo@users.noreply.github.com> Date: Sun, 28 Jan 2024 20:07:56 +0100 Subject: [PATCH 3/5] =?UTF-8?q?kramo.hu=20=E2=86=92=20kramo.page=20(#230)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CODE_OF_CONDUCT.md | 2 +- cartridges.doap | 4 ++-- cartridges/main.py | 4 ++-- data/hu.kramo.Cartridges.metainfo.xml.in | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 54853d7..91aae9e 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,3 +1,3 @@ The project follows the [GNOME Code of Conduct](https://wiki.gnome.org/Foundation/CodeOfConduct). -If you believe that someone is violating the Code of Conduct, or have any other concerns, please contact us via [cartridges-community@kramo.hu](mailto:cartridges-community@kramo.hu). \ No newline at end of file +If you believe that someone is violating the Code of Conduct, or have any other concerns, please contact us via [cartridges-community@kramo.page](mailto:cartridges-community@kramo.page). diff --git a/cartridges.doap b/cartridges.doap index 6a9a56d..af8a159 100644 --- a/cartridges.doap +++ b/cartridges.doap @@ -22,7 +22,7 @@ Cartridges is a simple game launcher for all of your games. It has support for i kramo - + @@ -38,4 +38,4 @@ Cartridges is a simple game launcher for all of your games. It has support for i - \ No newline at end of file + diff --git a/cartridges/main.py b/cartridges/main.py index 65042e5..a808297 100644 --- a/cartridges/main.py +++ b/cartridges/main.py @@ -250,7 +250,7 @@ class CartridgesApplication(Adw.Application): ) about.set_developers( ( - "kramo https://kramo.hu", + "kramo https://kramo.page", "Geoffrey Coulaud https://geoffrey-coulaud.fr", "Rilic https://rilic.red", "Arcitec https://github.com/Arcitec", @@ -261,7 +261,7 @@ class CartridgesApplication(Adw.Application): "Sabri Ünal https://github.com/sabriunal", ) ) - about.set_designers(("kramo https://kramo.hu",)) + about.set_designers(("kramo https://kramo.page",)) about.set_copyright("© 2022-2023 kramo") # Translators: Replace this with your name for it to show up in the about window about.set_translator_credits = (_("translator_credits"),) diff --git a/data/hu.kramo.Cartridges.metainfo.xml.in b/data/hu.kramo.Cartridges.metainfo.xml.in index d4b0e43..46f3b91 100644 --- a/data/hu.kramo.Cartridges.metainfo.xml.in +++ b/data/hu.kramo.Cartridges.metainfo.xml.in @@ -11,12 +11,12 @@ https://github.com/kra-mo/cartridges https://github.com/kra-mo/cartridges/issues https://hosted.weblate.org/engage/cartridges/ - https://www.kramo.hu/about/ + https://www.kramo.page/about/ https://github.com/kra-mo/cartridges https://github.com/kra-mo/cartridges/blob/main/CONTRIBUTING.md kramo - + kramo GNOME From 35d85a607f807ede72ef2f712e61dde466279bc2 Mon Sep 17 00:00:00 2001 From: kramo Date: Sat, 17 Feb 2024 09:58:03 +0100 Subject: [PATCH 4/5] Port to adaptive dialogs --- cartridges/importer/importer.py | 32 ++++++++++++++----------------- cartridges/utils/create_dialog.py | 6 +++--- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/cartridges/importer/importer.py b/cartridges/importer/importer.py index 65194e4..6f565ec 100644 --- a/cartridges/importer/importer.py +++ b/cartridges/importer/importer.py @@ -40,7 +40,7 @@ class Importer(ErrorProducer): progressbar: Gtk.ProgressBar import_statuspage: Adw.StatusPage - import_dialog: Adw.MessageDialog + import_dialog: Adw.AlertDialog summary_toast: Optional[Adw.Toast] = None sources: set[Source] @@ -53,7 +53,7 @@ class Importer(ErrorProducer): removed_game_ids: set[str] imported_game_ids: set[str] - close_req_id: int + close_attempt_id: int def __init__(self) -> None: super().__init__() @@ -145,20 +145,17 @@ class Importer(ErrorProducer): title=_("Importing Games…"), child=self.progressbar, ) - self.import_dialog = Adw.Window( - content=self.import_statuspage, - modal=True, - default_width=350, - default_height=-1, - transient_for=shared.win, - deletable=False, + self.import_dialog = Adw.Dialog( + child=self.import_statuspage, + content_width=350, + can_close=False, ) - self.close_req_id = self.import_dialog.connect( - "close-request", lambda *_: shared.win.close() + self.close_attempt_id = self.import_dialog.connect( + "close-attempt", lambda *_: shared.win.close() ) - self.import_dialog.present() + self.import_dialog.present(shared.win) def source_task_thread_func(self, data: tuple) -> None: """Source import task code""" @@ -282,9 +279,9 @@ class Importer(ErrorProducer): self.imported_game_ids = shared.store.new_game_ids shared.store.new_game_ids = set() shared.store.duplicate_game_ids = set() - # Disconnect the close-request signal that closes the main window - self.import_dialog.disconnect(self.close_req_id) - self.import_dialog.close() + # Disconnect the close-attempt signal that closes the main window + self.import_dialog.disconnect(self.close_attempt_id) + self.import_dialog.force_close() self.__class__.summary_toast = self.create_summary_toast() self.create_error_dialog() shared.win.get_application().lookup_action("import").set_enabled(True) @@ -317,13 +314,12 @@ class Importer(ErrorProducer): return # Create error dialog - dialog = Adw.MessageDialog() + dialog = Adw.AlertDialog() dialog.set_heading(_("Warning")) dialog.add_response("close", _("Dismiss")) dialog.add_response("open_preferences_import", _("Preferences")) dialog.set_default_response("open_preferences_import") dialog.connect("response", self.dialog_response_callback) - dialog.set_transient_for(shared.win) if len(errors) == 1: dialog.set_heading((error := next(iter(errors)))[0]) @@ -342,7 +338,7 @@ class Importer(ErrorProducer): dialog.set_body(_("The following errors occured during import:")) dialog.set_extra_child(list_box) - dialog.present() + dialog.present(shared.win) def undo_import(self, *_args: Any) -> None: for game_id in self.imported_game_ids: diff --git a/cartridges/utils/create_dialog.py b/cartridges/utils/create_dialog.py index 06219e2..2ff6495 100644 --- a/cartridges/utils/create_dialog.py +++ b/cartridges/utils/create_dialog.py @@ -28,12 +28,12 @@ def create_dialog( body: str, extra_option: Optional[str] = None, extra_label: Optional[str] = None, -) -> Adw.MessageDialog: - dialog = Adw.MessageDialog.new(win, heading, body) +) -> Adw.AlertDialog: + dialog = Adw.AlertDialog.new(heading, body) dialog.add_response("dismiss", _("Dismiss")) if extra_option: dialog.add_response(extra_option, _(extra_label)) - dialog.present() + dialog.choose(win) return dialog From c80f5271da3b101d07394c6996c256e62a12948f Mon Sep 17 00:00:00 2001 From: kramo Date: Sat, 16 Mar 2024 11:06:59 +0100 Subject: [PATCH 5/5] Update CI to Flathub 46 runtime --- .github/workflows/ci.yml | 2 -- flatpak/hu.kramo.Cartridges.Devel.json | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c70bce6..9eb6f2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,8 +21,6 @@ jobs: with: bundle: hu.kramo.Cartridges.Devel.flatpak manifest-path: flatpak/hu.kramo.Cartridges.Devel.json - repository-url: https://nightly.gnome.org/gnome-nightly.flatpakrepo - repository-name: gnome-nightly windows: name: Windows diff --git a/flatpak/hu.kramo.Cartridges.Devel.json b/flatpak/hu.kramo.Cartridges.Devel.json index 3ea2258..581fa5e 100644 --- a/flatpak/hu.kramo.Cartridges.Devel.json +++ b/flatpak/hu.kramo.Cartridges.Devel.json @@ -1,7 +1,7 @@ { "id" : "hu.kramo.Cartridges.Devel", "runtime" : "org.gnome.Platform", - "runtime-version" : "master", + "runtime-version" : "46", "sdk" : "org.gnome.Sdk", "command" : "cartridges", "finish-args" : [