diff --git a/src/main.py b/src/main.py index 75f382c..df83c1d 100644 --- a/src/main.py +++ b/src/main.py @@ -23,7 +23,7 @@ from . import shared # type: ignore from .models.search_result_model import SearchResultModel -from .preferences import PreferencesWindow +from .preferences import PreferencesDialog from .views.content_view import ContentView from .views.first_run_view import FirstRunView from .views.main_view import MainView @@ -98,27 +98,25 @@ def do_activate(self): def on_about_action(self, widget: Gtk.Widget, user_data: object | None): """Callback for the app.about action.""" - builder = Gtk.Builder.new_from_resource(shared.PREFIX + '/ui/about_window.ui') - about_window = builder.get_object('about_window') - about_window.set_application_name(shared.APP_NAME) - about_window.set_application_icon(shared.APP_ID) - about_window.set_version(shared.VERSION) - about_window.set_transient_for(self.props.active_window) - about_window.add_credit_section('Contributors', [ + builder = Gtk.Builder.new_from_resource(shared.PREFIX + '/ui/about_dialog.ui') + about_dialog = builder.get_object('about_dialog') + about_dialog.set_application_name(shared.APP_NAME) + about_dialog.set_application_icon(shared.APP_ID) + about_dialog.set_version(shared.VERSION) + about_dialog.add_credit_section('Contributors', [ # your name # your name website ]) - about_window.add_legal_section('Movie and TV Series Metadata', 'This product uses the TMDB API but is not endorsed or certified by TMDB.', Gtk.License.CUSTOM, 'All rights belong to their respective owners.') + about_dialog.add_legal_section('Movie and TV Series Metadata', 'This product uses the TMDB API but is not endorsed or certified by TMDB.', Gtk.License.CUSTOM, 'All rights belong to their respective owners.') logging.debug('About window open') - about_window.present() + about_dialog.present(self.props.active_window) def on_preferences_action(self, widget: Gtk.Widget, user_data: object | None): """Callback for the app.preferences action.""" - pref_window = PreferencesWindow() - pref_window.set_transient_for(self.props.active_window) - logging.debug('Preferences window open') - pref_window.present() + pref_dialog = PreferencesDialog() + logging.debug('Preferences dialog open') + pref_dialog.present(self.props.active_window) def create_action(self, name: Gtk.Widget, callback: Callable, shortcuts=None): """ diff --git a/src/meson.build b/src/meson.build index 32a095a..6e61e2d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -11,7 +11,7 @@ blueprints = custom_target('blueprints', input: files( 'ui/gtk/help-overlay.blp', 'ui/window.blp', - 'ui/about_window.blp', + 'ui/about_dialog.blp', 'ui/preferences.blp', 'ui/views/main_view.blp', diff --git a/src/preferences.py b/src/preferences.py index 75e5f51..c6aea71 100644 --- a/src/preferences.py +++ b/src/preferences.py @@ -21,8 +21,8 @@ @Gtk.Template(resource_path=shared.PREFIX + '/ui/preferences.ui') -class PreferencesWindow(Adw.PreferencesWindow): - __gtype_name__ = 'PreferencesWindow' +class PreferencesDialog(Adw.PreferencesDialog): + __gtype_name__ = 'PreferencesDialog' _download_group = Gtk.Template.Child() _language_comborow = Gtk.Template.Child() @@ -284,8 +284,7 @@ def _on_clear_cache_activate(self, user_data: object | None) -> None: builder = Gtk.Builder.new_from_resource( shared.PREFIX + '/ui/dialogs/message_dialogs.ui') _clear_cache_dialog = builder.get_object('_clear_cache_dialog') - _clear_cache_dialog.set_transient_for(self) - _clear_cache_dialog.choose( + _clear_cache_dialog.choose(self, None, self._on_cache_message_dialog_choose, None) def _on_cache_message_dialog_choose(self, @@ -305,7 +304,7 @@ def _on_cache_message_dialog_choose(self, None """ - result = Adw.MessageDialog.choose_finish(source, result) + result = Adw.AlertDialog.choose_finish(source, result) if result == 'cache_cancel': logging.debug('Cache clear dialog: cancel, aborting') return @@ -371,8 +370,7 @@ def _on_clear_btn_clicked(self, user_data: object | None) -> None: _series_row.set_subtitle(_('{number} Titles').format( number=len(local.get_all_series()))) - _clear_data_dialog.set_transient_for(self) - _clear_data_dialog.choose( + _clear_data_dialog.choose(self, None, self._on_data_message_dialog_choose, None) def _on_data_message_dialog_choose(self, @@ -395,7 +393,7 @@ def _on_data_message_dialog_choose(self, None """ - result = Adw.MessageDialog.choose_finish(source, result) + result = Adw.AlertDialog.choose_finish(source, result) if result == 'data_cancel': logging.debug('Data clear dialog: cancel, aborting') return @@ -445,7 +443,7 @@ def _on_data_clear_done(self, """Callback to complete async activity""" self._update_occupied_space() - self.get_transient_for().activate_action('win.refresh', None) + self.get_parent().activate_action('win.refresh', None) activity.end() def _clear_series(self, activity: BackgroundActivity) -> None: diff --git a/src/ticketbooth.gresource.xml.in b/src/ticketbooth.gresource.xml.in index 5712a9d..c0aa564 100644 --- a/src/ticketbooth.gresource.xml.in +++ b/src/ticketbooth.gresource.xml.in @@ -35,7 +35,7 @@ SPDX-License-Identifier: GPL-3.0-or-later ui/gtk/help-overlay.ui ui/window.ui - ui/about_window.ui + ui/about_dialog.ui ui/preferences.ui ui/views/first_run_view.ui ui/views/main_view.ui diff --git a/src/ui/about_window.blp b/src/ui/about_dialog.blp similarity index 57% rename from src/ui/about_window.blp rename to src/ui/about_dialog.blp index 8d04f94..5118230 100644 --- a/src/ui/about_window.blp +++ b/src/ui/about_dialog.blp @@ -5,13 +5,13 @@ using Gtk 4.0; using Adw 1; -Adw.AboutWindow about_window { - modal: true; - copyright: "Copyright © 2023 Alessandro Iepure"; +Adw.AboutDialog about_dialog { + copyright: _("Copyright © 2023 - 2025 Alessandro Iepure\nSome icons are copyright of the GNOME Project"); + comments: _("Keep track of your favorite shows"); website: "https://github.com/aleiepure/ticketbooth"; issue-url: "https://github.com/aleiepure/ticketbooth/issues"; license-type: gpl_3_0; developer-name: "Alessandro Iepure"; - // TRANSLATORS: replace with your name (and an optional email or website) + // TRANSLATORS: replace with your name (with optional email or website) translator-credits: _("translator-credits"); -} +} \ No newline at end of file diff --git a/src/ui/dialogs/message_dialogs.blp b/src/ui/dialogs/message_dialogs.blp index c1011e7..bdd2fc6 100644 --- a/src/ui/dialogs/message_dialogs.blp +++ b/src/ui/dialogs/message_dialogs.blp @@ -5,25 +5,25 @@ using Gtk 4.0; using Adw 1; -Adw.MessageDialog _clear_cache_dialog { - heading: C_('message dialog heading', 'Clear Cached Data?'); - body: C_('message dialog body', 'This operation will clear all stored cache data. It might get downloaded again next time you add content from TMDB.'); +Adw.AlertDialog _clear_cache_dialog { + heading: C_("message dialog heading", "Clear Cached Data?"); + body: C_("message dialog body", "This operation will clear all stored cache data. It might get downloaded again next time you add content from TMDB."); responses[ - cache_cancel: C_('message dialog action', "Cancel"), - cache_clear: C_('message dialog action', "Clear") destructive + cache_cancel: C_("message dialog action", "Cancel"), + cache_clear: C_("message dialog action", "Clear") destructive ] } -Adw.MessageDialog _clear_data_dialog { - heading: C_('message dialog heading', 'Clear Stored Data?'); - body: C_('message dialog body', 'This operation will permanentlly delete the selected data, loosing all your changes.'); +Adw.AlertDialog _clear_data_dialog { + heading: C_("message dialog heading", "Clear Stored Data?"); + body: C_("message dialog body", "This operation will permanentlly delete the selected data, loosing all your changes."); extra-child: Adw.PreferencesGroup { Adw.ActionRow _movies_row { [prefix] CheckButton _movies_checkbtn {} - title: _('Movies'); + title: _("Movies"); activatable-widget: _movies_checkbtn; } @@ -31,13 +31,13 @@ Adw.MessageDialog _clear_data_dialog { [prefix] CheckButton _series_checkbtn {} - title: _('TV Series'); + title: _("TV Series"); activatable-widget: _series_checkbtn; } }; responses[ - data_cancel: C_('message dialog action', "Cancel"), - data_clear: C_('message dialog action', "Clear") destructive + data_cancel: C_("message dialog action", "Cancel"), + data_clear: C_("message dialog action", "Clear") destructive ] } diff --git a/src/ui/preferences.blp b/src/ui/preferences.blp index 66f4940..d1435ed 100644 --- a/src/ui/preferences.blp +++ b/src/ui/preferences.blp @@ -5,8 +5,7 @@ using Gtk 4.0; using Adw 1; -template $PreferencesWindow: Adw.PreferencesWindow { - default-height: 500; +template $PreferencesDialog: Adw.PreferencesDialog { search-enabled: false; map => $_on_map(); @@ -17,7 +16,7 @@ template $PreferencesWindow: Adw.PreferencesWindow { Adw.PreferencesGroup _download_group { title: C_("preferences", "Optional Download"); - description: C_("preferences", "For a complete experience, a download of 15 KB is required. The initial setup could not retrieve the data automatically and thus offline mode has been activated. It will remain active until the setup is completed."); + description: C_("preferences", "For a complete experience, a download of 15 KB is required. The initial setup could not retrieve the data automatically and thus offline mode has been activated. It will remain active until the setup is completed."); Adw.ActionRow _download_row { // TRANSLATORS: When clicked, it completes the initial setup by downloading the optional data. @@ -73,7 +72,7 @@ template $PreferencesWindow: Adw.PreferencesWindow { [suffix] Button _check_own_key_button { - label: C_('preferences', 'Save Key'); + label: C_("preferences", "Save Key"); valign: center; clicked => $_on_check_own_key_button_clicked();