# shared.py.in # # Copyright 2022-2023 kramo # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # SPDX-License-Identifier: GPL-3.0-or-later import os from enum import IntEnum, auto from pathlib import Path from gi.repository import Gdk, Gio, GLib class AppState(IntEnum): DEFAULT = auto() LOAD_FROM_DISK = auto() IMPORT = auto() REMOVE_ALL_GAMES = auto() UNDO_REMOVE_ALL_GAMES = auto() APP_ID = "@APP_ID@" VERSION = "@VERSION@" PREFIX = "@PREFIX@" PROFILE = "@PROFILE@" TIFF_COMPRESSION = "@TIFF_COMPRESSION@" SPEC_VERSION = 1.5 # The version of the game_id.json spec schema = Gio.Settings.new(APP_ID) state_schema = Gio.Settings.new(APP_ID + ".State") home = Path.home() data_dir = Path(GLib.get_user_data_dir()) config_dir = Path(GLib.get_user_config_dir()) cache_dir = Path(GLib.get_user_cache_dir()) flatpak_dir = home / ".var" / "app" games_dir = data_dir / "cartridges" / "games" covers_dir = data_dir / "cartridges" / "covers" appdata_dir = Path(os.getenv("appdata") or "C:\\Users\\Default\\AppData\\Roaming") local_appdata_dir = Path( os.getenv("csidl_local_appdata") or "C:\\Users\\Default\\AppData\\Local" ) programfiles32_dir = Path(os.getenv("programfiles(x86)") or "C:\\Program Files (x86)") try: scale_factor = max( monitor.get_scale_factor() for monitor in Gdk.Display.get_default().get_monitors() ) except AttributeError: # If shared.py is imported by the search provider pass else: image_size = (200 * scale_factor, 300 * scale_factor) # pylint: disable=invalid-name win = None importer = None import_time = None store = None log_files = None