Skip to content

Commit

Permalink
Changed deprecated widgets since last update
Browse files Browse the repository at this point in the history
  • Loading branch information
aleiepure committed Feb 8, 2025
1 parent eaf646e commit a33115c
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 46 deletions.
26 changes: 12 additions & 14 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 email>
# 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):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
16 changes: 7 additions & 9 deletions src/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/ticketbooth.gresource.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<!-- Views -->
<file preprocess="xml-stripblanks" alias="gtk/help-overlay.ui">ui/gtk/help-overlay.ui</file>
<file preprocess="xml-stripblanks">ui/window.ui</file>
<file preprocess="xml-stripblanks">ui/about_window.ui</file>
<file preprocess="xml-stripblanks">ui/about_dialog.ui</file>
<file preprocess="xml-stripblanks">ui/preferences.ui</file>
<file preprocess="xml-stripblanks">ui/views/first_run_view.ui</file>
<file preprocess="xml-stripblanks">ui/views/main_view.ui</file>
Expand Down
10 changes: 5 additions & 5 deletions src/ui/about_window.blp → src/ui/about_dialog.blp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
24 changes: 12 additions & 12 deletions src/ui/dialogs/message_dialogs.blp
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@
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;
}

Adw.ActionRow _series_row {
[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
]
}
7 changes: 3 additions & 4 deletions src/ui/preferences.blp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 15KB 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.
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit a33115c

Please sign in to comment.