Type hint GTK template imports
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# pyright: reportAssignmentType=none
|
||||
|
||||
import shlex
|
||||
from pathlib import Path
|
||||
from sys import platform
|
||||
@@ -40,26 +42,26 @@ from cartridges.utils.save_cover import convert_cover, save_cover
|
||||
class DetailsDialog(Adw.Dialog):
|
||||
__gtype_name__ = "DetailsDialog"
|
||||
|
||||
cover_overlay = Gtk.Template.Child()
|
||||
cover = Gtk.Template.Child()
|
||||
cover_button_edit = Gtk.Template.Child()
|
||||
cover_button_delete_revealer = Gtk.Template.Child()
|
||||
cover_button_delete = Gtk.Template.Child()
|
||||
spinner = Gtk.Template.Child()
|
||||
cover_overlay: Gtk.Overlay = Gtk.Template.Child()
|
||||
cover: Gtk.Picture = Gtk.Template.Child()
|
||||
cover_button_edit: Gtk.Button = Gtk.Template.Child()
|
||||
cover_button_delete_revealer: Gtk.Revealer = Gtk.Template.Child()
|
||||
cover_button_delete: Gtk.Button = Gtk.Template.Child()
|
||||
spinner: Gtk.Spinner = Gtk.Template.Child()
|
||||
|
||||
name = Gtk.Template.Child()
|
||||
developer = Gtk.Template.Child()
|
||||
executable = Gtk.Template.Child()
|
||||
name: Adw.EntryRow = Gtk.Template.Child()
|
||||
developer: Adw.EntryRow = Gtk.Template.Child()
|
||||
executable: Adw.EntryRow = Gtk.Template.Child()
|
||||
|
||||
exec_info_label = Gtk.Template.Child()
|
||||
exec_info_popover = Gtk.Template.Child()
|
||||
file_chooser_button = Gtk.Template.Child()
|
||||
exec_info_label: Gtk.Label = Gtk.Template.Child()
|
||||
exec_info_popover: Gtk.Popover = Gtk.Template.Child()
|
||||
file_chooser_button: Gtk.Button = Gtk.Template.Child()
|
||||
|
||||
apply_button = Gtk.Template.Child()
|
||||
apply_button: Gtk.Button = Gtk.Template.Child()
|
||||
|
||||
cover_changed: bool = False
|
||||
|
||||
is_open = False
|
||||
is_open: bool = False
|
||||
|
||||
def __init__(self, game: Optional[Game] = None, **kwargs: Any):
|
||||
super().__init__(**kwargs)
|
||||
@@ -68,7 +70,7 @@ class DetailsDialog(Adw.Dialog):
|
||||
self.__class__.is_open = True
|
||||
self.connect("closed", lambda *_: self.set_is_open(False))
|
||||
|
||||
self.game: Game = game
|
||||
self.game: Optional[Game] = game
|
||||
self.game_cover: GameCover = GameCover({self.cover})
|
||||
|
||||
if self.game:
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# pyright: reportAssignmentType=none
|
||||
|
||||
import logging
|
||||
import re
|
||||
from pathlib import Path
|
||||
@@ -48,74 +50,74 @@ from cartridges.utils.create_dialog import create_dialog
|
||||
class CartridgesPreferences(Adw.PreferencesDialog):
|
||||
__gtype_name__ = "CartridgesPreferences"
|
||||
|
||||
general_page = Gtk.Template.Child()
|
||||
import_page = Gtk.Template.Child()
|
||||
sgdb_page = Gtk.Template.Child()
|
||||
general_page: Adw.PreferencesPage = Gtk.Template.Child()
|
||||
import_page: Adw.PreferencesPage = Gtk.Template.Child()
|
||||
sgdb_page: Adw.PreferencesPage = Gtk.Template.Child()
|
||||
|
||||
sources_group = Gtk.Template.Child()
|
||||
sources_group: Adw.PreferencesGroup = Gtk.Template.Child()
|
||||
|
||||
exit_after_launch_switch = Gtk.Template.Child()
|
||||
cover_launches_game_switch = Gtk.Template.Child()
|
||||
high_quality_images_switch = Gtk.Template.Child()
|
||||
exit_after_launch_switch: Adw.SwitchRow = Gtk.Template.Child()
|
||||
cover_launches_game_switch: Adw.SwitchRow = Gtk.Template.Child()
|
||||
high_quality_images_switch: Adw.SwitchRow = Gtk.Template.Child()
|
||||
|
||||
remove_missing_switch = Gtk.Template.Child()
|
||||
remove_missing_switch: Adw.SwitchRow = Gtk.Template.Child()
|
||||
|
||||
steam_expander_row = Gtk.Template.Child()
|
||||
steam_data_action_row = Gtk.Template.Child()
|
||||
steam_data_file_chooser_button = Gtk.Template.Child()
|
||||
steam_expander_row: Adw.ExpanderRow = Gtk.Template.Child()
|
||||
steam_data_action_row: Adw.ActionRow = Gtk.Template.Child()
|
||||
steam_data_file_chooser_button: Gtk.Button = Gtk.Template.Child()
|
||||
|
||||
lutris_expander_row = Gtk.Template.Child()
|
||||
lutris_data_action_row = Gtk.Template.Child()
|
||||
lutris_data_file_chooser_button = Gtk.Template.Child()
|
||||
lutris_import_steam_switch = Gtk.Template.Child()
|
||||
lutris_import_flatpak_switch = Gtk.Template.Child()
|
||||
lutris_expander_row: Adw.ExpanderRowClass = Gtk.Template.Child()
|
||||
lutris_data_action_row: Adw.ActionRow = Gtk.Template.Child()
|
||||
lutris_data_file_chooser_button: Gtk.Button = Gtk.Template.Child()
|
||||
lutris_import_steam_switch: Adw.SwitchRow = Gtk.Template.Child()
|
||||
lutris_import_flatpak_switch: Adw.SwitchRow = Gtk.Template.Child()
|
||||
|
||||
heroic_expander_row = Gtk.Template.Child()
|
||||
heroic_config_action_row = Gtk.Template.Child()
|
||||
heroic_config_file_chooser_button = Gtk.Template.Child()
|
||||
heroic_import_epic_switch = Gtk.Template.Child()
|
||||
heroic_import_gog_switch = Gtk.Template.Child()
|
||||
heroic_import_amazon_switch = Gtk.Template.Child()
|
||||
heroic_import_sideload_switch = Gtk.Template.Child()
|
||||
heroic_expander_row: Adw.ExpanderRow = Gtk.Template.Child()
|
||||
heroic_config_action_row: Adw.ActionRow = Gtk.Template.Child()
|
||||
heroic_config_file_chooser_button: Gtk.Button = Gtk.Template.Child()
|
||||
heroic_import_epic_switch: Adw.SwitchRow = Gtk.Template.Child()
|
||||
heroic_import_gog_switch: Adw.SwitchRow = Gtk.Template.Child()
|
||||
heroic_import_amazon_switch: Adw.SwitchRow = Gtk.Template.Child()
|
||||
heroic_import_sideload_switch: Adw.SwitchRow = Gtk.Template.Child()
|
||||
|
||||
bottles_expander_row = Gtk.Template.Child()
|
||||
bottles_data_action_row = Gtk.Template.Child()
|
||||
bottles_data_file_chooser_button = Gtk.Template.Child()
|
||||
bottles_expander_row: Adw.ExpanderRow = Gtk.Template.Child()
|
||||
bottles_data_action_row: Adw.ActionRow = Gtk.Template.Child()
|
||||
bottles_data_file_chooser_button: Gtk.Button = Gtk.Template.Child()
|
||||
|
||||
itch_expander_row = Gtk.Template.Child()
|
||||
itch_config_action_row = Gtk.Template.Child()
|
||||
itch_config_file_chooser_button = Gtk.Template.Child()
|
||||
itch_expander_row: Adw.ExpanderRow = Gtk.Template.Child()
|
||||
itch_config_action_row: Adw.ActionRow = Gtk.Template.Child()
|
||||
itch_config_file_chooser_button: Gtk.Button = Gtk.Template.Child()
|
||||
|
||||
legendary_expander_row = Gtk.Template.Child()
|
||||
legendary_config_action_row = Gtk.Template.Child()
|
||||
legendary_config_file_chooser_button = Gtk.Template.Child()
|
||||
legendary_expander_row: Adw.ExpanderRow = Gtk.Template.Child()
|
||||
legendary_config_action_row: Adw.ActionRow = Gtk.Template.Child()
|
||||
legendary_config_file_chooser_button: Gtk.Button = Gtk.Template.Child()
|
||||
|
||||
retroarch_expander_row = Gtk.Template.Child()
|
||||
retroarch_config_action_row = Gtk.Template.Child()
|
||||
retroarch_config_file_chooser_button = Gtk.Template.Child()
|
||||
retroarch_expander_row: Adw.ExpanderRow = Gtk.Template.Child()
|
||||
retroarch_config_action_row: Adw.ActionRow = Gtk.Template.Child()
|
||||
retroarch_config_file_chooser_button: Gtk.Button = Gtk.Template.Child()
|
||||
|
||||
flatpak_expander_row = Gtk.Template.Child()
|
||||
flatpak_system_data_action_row = Gtk.Template.Child()
|
||||
flatpak_system_data_file_chooser_button = Gtk.Template.Child()
|
||||
flatpak_user_data_action_row = Gtk.Template.Child()
|
||||
flatpak_user_data_file_chooser_button = Gtk.Template.Child()
|
||||
flatpak_import_launchers_switch = Gtk.Template.Child()
|
||||
flatpak_expander_row: Adw.ExpanderRow = Gtk.Template.Child()
|
||||
flatpak_system_data_action_row: Adw.ActionRow = Gtk.Template.Child()
|
||||
flatpak_system_data_file_chooser_button: Gtk.Button = Gtk.Template.Child()
|
||||
flatpak_user_data_action_row: Adw.ActionRow = Gtk.Template.Child()
|
||||
flatpak_user_data_file_chooser_button: Gtk.Button = Gtk.Template.Child()
|
||||
flatpak_import_launchers_switch: Adw.SwitchRow = Gtk.Template.Child()
|
||||
|
||||
desktop_switch = Gtk.Template.Child()
|
||||
desktop_switch: Adw.SwitchRow = Gtk.Template.Child()
|
||||
|
||||
sgdb_key_group = Gtk.Template.Child()
|
||||
sgdb_key_entry_row = Gtk.Template.Child()
|
||||
sgdb_switch = Gtk.Template.Child()
|
||||
sgdb_prefer_switch = Gtk.Template.Child()
|
||||
sgdb_animated_switch = Gtk.Template.Child()
|
||||
sgdb_fetch_button = Gtk.Template.Child()
|
||||
sgdb_stack = Gtk.Template.Child()
|
||||
sgdb_spinner = Gtk.Template.Child()
|
||||
sgdb_key_group: Adw.PreferencesGroup = Gtk.Template.Child()
|
||||
sgdb_key_entry_row: Adw.EntryRow = Gtk.Template.Child()
|
||||
sgdb_switch: Adw.SwitchRow = Gtk.Template.Child()
|
||||
sgdb_prefer_switch: Adw.SwitchRow = Gtk.Template.Child()
|
||||
sgdb_animated_switch: Adw.SwitchRow = Gtk.Template.Child()
|
||||
sgdb_fetch_button: Gtk.Button = Gtk.Template.Child()
|
||||
sgdb_stack: Gtk.Stack = Gtk.Template.Child()
|
||||
sgdb_spinner: Gtk.Spinner = Gtk.Template.Child()
|
||||
|
||||
danger_zone_group = Gtk.Template.Child()
|
||||
remove_all_games_list_box = Gtk.Template.Child()
|
||||
reset_list_box = Gtk.Template.Child()
|
||||
reset_group = Gtk.Template.Child()
|
||||
danger_zone_group: Adw.PreferencesGroup = Gtk.Template.Child()
|
||||
remove_all_games_list_box: Gtk.ListBox = Gtk.Template.Child()
|
||||
reset_list_box: Gtk.ListBox = Gtk.Template.Child()
|
||||
reset_group: Adw.PreferencesGroup = Gtk.Template.Child()
|
||||
|
||||
removed_games: set[Game] = set()
|
||||
warning_menu_buttons: dict = {}
|
||||
@@ -280,7 +282,7 @@ class CartridgesPreferences(Adw.PreferencesDialog):
|
||||
) -> None:
|
||||
self.file_chooser.select_folder(shared.win, None, callback, callback_data)
|
||||
|
||||
def undo_remove_all(self, *_args: Any) -> None:
|
||||
def undo_remove_all(self, *_args: Any) -> bool:
|
||||
shared.win.get_application().state = shared.AppState.UNDO_REMOVE_ALL_GAMES
|
||||
for game in self.removed_games:
|
||||
game.removed = False
|
||||
@@ -292,6 +294,8 @@ class CartridgesPreferences(Adw.PreferencesDialog):
|
||||
shared.win.get_application().state = shared.AppState.DEFAULT
|
||||
shared.win.create_source_rows()
|
||||
|
||||
return True
|
||||
|
||||
def remove_all_games(self, *_args: Any) -> None:
|
||||
shared.win.get_application().state = shared.AppState.REMOVE_ALL_GAMES
|
||||
shared.win.row_selected(None, shared.win.all_games_row_box.get_parent())
|
||||
|
||||
@@ -33,7 +33,7 @@ def create_dialog(
|
||||
dialog.add_response("dismiss", _("Dismiss"))
|
||||
|
||||
if extra_option:
|
||||
dialog.add_response(extra_option, _(extra_label))
|
||||
dialog.add_response(extra_option, extra_label or "")
|
||||
|
||||
dialog.choose(win)
|
||||
return dialog
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from typing import Any, Optional
|
||||
# pyright: reportAssignmentType=none
|
||||
|
||||
from sys import platform
|
||||
from typing import Any, Optional
|
||||
|
||||
from gi.repository import Adw, Gio, GLib, Gtk, Pango
|
||||
|
||||
@@ -32,52 +34,52 @@ from cartridges.utils.relative_date import relative_date
|
||||
class CartridgesWindow(Adw.ApplicationWindow):
|
||||
__gtype_name__ = "CartridgesWindow"
|
||||
|
||||
overlay_split_view = Gtk.Template.Child()
|
||||
navigation_view = Gtk.Template.Child()
|
||||
sidebar_navigation_page = Gtk.Template.Child()
|
||||
sidebar = Gtk.Template.Child()
|
||||
all_games_row_box = Gtk.Template.Child()
|
||||
all_games_no_label = Gtk.Template.Child()
|
||||
added_row_box = Gtk.Template.Child()
|
||||
added_games_no_label = Gtk.Template.Child()
|
||||
toast_overlay = Gtk.Template.Child()
|
||||
primary_menu_button = Gtk.Template.Child()
|
||||
show_sidebar_button = Gtk.Template.Child()
|
||||
details_view = Gtk.Template.Child()
|
||||
library_page = Gtk.Template.Child()
|
||||
library_view = Gtk.Template.Child()
|
||||
library = Gtk.Template.Child()
|
||||
scrolledwindow = Gtk.Template.Child()
|
||||
library_overlay = Gtk.Template.Child()
|
||||
notice_empty = Gtk.Template.Child()
|
||||
notice_no_results = Gtk.Template.Child()
|
||||
search_bar = Gtk.Template.Child()
|
||||
search_entry = Gtk.Template.Child()
|
||||
search_button = Gtk.Template.Child()
|
||||
overlay_split_view: Adw.OverlaySplitView = Gtk.Template.Child()
|
||||
navigation_view: Adw.NavigationView = Gtk.Template.Child()
|
||||
sidebar_navigation_page: Adw.NavigationPage = Gtk.Template.Child()
|
||||
sidebar: Gtk.ListBox = Gtk.Template.Child()
|
||||
all_games_row_box: Gtk.Box = Gtk.Template.Child()
|
||||
all_games_no_label: Gtk.Label = Gtk.Template.Child()
|
||||
added_row_box: Gtk.Box = Gtk.Template.Child()
|
||||
added_games_no_label: Gtk.Label = Gtk.Template.Child()
|
||||
toast_overlay: Adw.ToastOverlay = Gtk.Template.Child()
|
||||
primary_menu_button: Gtk.MenuButton = Gtk.Template.Child()
|
||||
show_sidebar_button: Gtk.Button = Gtk.Template.Child()
|
||||
details_view: Gtk.Overlay = Gtk.Template.Child()
|
||||
library_page: Adw.NavigationPage = Gtk.Template.Child()
|
||||
library_view: Adw.ToolbarView = Gtk.Template.Child()
|
||||
library: Gtk.FlowBox = Gtk.Template.Child()
|
||||
scrolledwindow: Gtk.ScrolledWindow = Gtk.Template.Child()
|
||||
library_overlay: Gtk.Overlay = Gtk.Template.Child()
|
||||
notice_empty: Adw.StatusPage = Gtk.Template.Child()
|
||||
notice_no_results: Adw.StatusPage = Gtk.Template.Child()
|
||||
search_bar: Gtk.SearchBar = Gtk.Template.Child()
|
||||
search_entry: Gtk.SearchEntry = Gtk.Template.Child()
|
||||
search_button: Gtk.ToggleButton = Gtk.Template.Child()
|
||||
|
||||
details_page = Gtk.Template.Child()
|
||||
details_view_toolbar_view = Gtk.Template.Child()
|
||||
details_view_cover = Gtk.Template.Child()
|
||||
details_view_spinner = Gtk.Template.Child()
|
||||
details_view_title = Gtk.Template.Child()
|
||||
details_view_blurred_cover = Gtk.Template.Child()
|
||||
details_view_play_button = Gtk.Template.Child()
|
||||
details_view_developer = Gtk.Template.Child()
|
||||
details_view_added = Gtk.Template.Child()
|
||||
details_view_last_played = Gtk.Template.Child()
|
||||
details_view_hide_button = Gtk.Template.Child()
|
||||
details_page: Adw.NavigationPage = Gtk.Template.Child()
|
||||
details_view_toolbar_view: Adw.ToolbarView = Gtk.Template.Child()
|
||||
details_view_cover: Gtk.Picture = Gtk.Template.Child()
|
||||
details_view_spinner: Gtk.Spinner = Gtk.Template.Child()
|
||||
details_view_title: Gtk.Label = Gtk.Template.Child()
|
||||
details_view_blurred_cover: Gtk.Picture = Gtk.Template.Child()
|
||||
details_view_play_button: Gtk.Button = Gtk.Template.Child()
|
||||
details_view_developer: Gtk.Label = Gtk.Template.Child()
|
||||
details_view_added: Gtk.ShortcutLabel = Gtk.Template.Child()
|
||||
details_view_last_played: Gtk.Label = Gtk.Template.Child()
|
||||
details_view_hide_button: Gtk.Button = Gtk.Template.Child()
|
||||
|
||||
hidden_library_page = Gtk.Template.Child()
|
||||
hidden_primary_menu_button = Gtk.Template.Child()
|
||||
hidden_library = Gtk.Template.Child()
|
||||
hidden_library_view = Gtk.Template.Child()
|
||||
hidden_scrolledwindow = Gtk.Template.Child()
|
||||
hidden_library_overlay = Gtk.Template.Child()
|
||||
hidden_notice_empty = Gtk.Template.Child()
|
||||
hidden_notice_no_results = Gtk.Template.Child()
|
||||
hidden_search_bar = Gtk.Template.Child()
|
||||
hidden_search_entry = Gtk.Template.Child()
|
||||
hidden_search_button = Gtk.Template.Child()
|
||||
hidden_library_page: Adw.NavigationPage = Gtk.Template.Child()
|
||||
hidden_primary_menu_button: Gtk.MenuButton = Gtk.Template.Child()
|
||||
hidden_library: Gtk.FlowBox = Gtk.Template.Child()
|
||||
hidden_library_view: Adw.ToolbarView = Gtk.Template.Child()
|
||||
hidden_scrolledwindow: Gtk.ScrolledWindow = Gtk.Template.Child()
|
||||
hidden_library_overlay: Gtk.Overlay = Gtk.Template.Child()
|
||||
hidden_notice_empty: Adw.StatusPage = Gtk.Template.Child()
|
||||
hidden_notice_no_results: Adw.StatusPage = Gtk.Template.Child()
|
||||
hidden_search_bar: Gtk.SearchBar = Gtk.Template.Child()
|
||||
hidden_search_entry: Gtk.SearchEntry = Gtk.Template.Child()
|
||||
hidden_search_button: Gtk.ToggleButton = Gtk.Template.Child()
|
||||
|
||||
game_covers: dict = {}
|
||||
toasts: dict = {}
|
||||
|
||||
Reference in New Issue
Block a user