about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--fungus-proton-manager.py12
-rw-r--r--fungus-run.py11
-rw-r--r--fungus/__init__.py6
-rw-r--r--fungus/add_game_dialog.py4
-rw-r--r--fungus/constants.py2
-rw-r--r--fungus/dialogs.py20
-rw-r--r--fungus/game_launcher.py17
-rw-r--r--fungus/game_model.py13
-rw-r--r--fungus/proton_manager.py13
-rw-r--r--fungus/run_manager.py6
10 files changed, 53 insertions, 51 deletions
diff --git a/fungus-proton-manager.py b/fungus-proton-manager.py
index 1c57aa6..3e8a991 100644
--- a/fungus-proton-manager.py
+++ b/fungus-proton-manager.py
@@ -3,8 +3,20 @@
 
 import argparse
 import os
+import sys
 import threading
 
+IS_RPM_BUILD = "@IS_RPM_BUILD@"
+PYTHON_SITE_PACKAGES = "@PYTHON_SITE_PACKAGES@"
+
+# only for custom builds, use system paths for RPM packages
+if IS_RPM_BUILD == "true":
+    pass
+else:
+    base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+    dev_site_packages = os.path.join(base_dir, PYTHON_SITE_PACKAGES)
+    sys.path.insert(0, dev_site_packages)
+
 import gi  # type: ignore
 
 gi.require_version("Gtk", "3.0")
diff --git a/fungus-run.py b/fungus-run.py
index ab97922..7c0bc89 100644
--- a/fungus-run.py
+++ b/fungus-run.py
@@ -4,10 +4,15 @@ import argparse
 import os
 import sys
 
+IS_RPM_BUILD = "@IS_RPM_BUILD@"
+PYTHON_SITE_PACKAGES = "@PYTHON_SITE_PACKAGES@"
+
 # only for custom builds, use system paths for RPM packages
-base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-dev_site_packages = os.path.join(base_dir, "lib", "python3.*", "site-packages")
-if os.path.exists(dev_site_packages):
+if IS_RPM_BUILD == "true":
+    pass
+else:
+    base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+    dev_site_packages = os.path.join(base_dir, PYTHON_SITE_PACKAGES)
     sys.path.insert(0, dev_site_packages)
 
 from fungus.logger import set_level
diff --git a/fungus/__init__.py b/fungus/__init__.py
index 088687d..9ae5253 100644
--- a/fungus/__init__.py
+++ b/fungus/__init__.py
@@ -13,7 +13,7 @@ __all__ = [
     "SandboxWarningDialog",
     "SettingsDialog",
     "app_dir",
-    "config_file_dir",
+    "config_file_path",
     "desktop_dir",
     "envar_dir",
     "format_title",
@@ -52,7 +52,7 @@ def __getattr__(name):
     # Fall back to module-level constants
     from fungus.constants import (
         app_dir,
-        config_file_dir,
+        config_file_path,
         desktop_dir,
         envar_dir,
         fungus_launcher_dir,
@@ -64,7 +64,7 @@ def __getattr__(name):
 
     _constants = {
         "app_dir": app_dir,
-        "config_file_dir": config_file_dir,
+        "config_file_path": config_file_path,
         "desktop_dir": desktop_dir,
         "envar_dir": envar_dir,
         "fungus_launcher_dir": fungus_launcher_dir,
diff --git a/fungus/add_game_dialog.py b/fungus/add_game_dialog.py
index 65af71b..2db1d9c 100644
--- a/fungus/add_game_dialog.py
+++ b/fungus/add_game_dialog.py
@@ -404,10 +404,6 @@ class AddGame(EntryTooltipMixin, Gtk.Dialog):
         self.tab_box2.show_all()
         self.show_all()
 
-    def on_image_clicked(self, widget, event):
-        """Show the icon context menu on right-click."""
-        self.menu.popup_at_pointer(event)
-
     def populate_combobox_with_runners(self):
         """Fill the Proton runner combobox with available runners."""
         from fungus.utils import populate_combobox_with_runners as _pop
diff --git a/fungus/constants.py b/fungus/constants.py
index 1e69850..90dc34e 100644
--- a/fungus/constants.py
+++ b/fungus/constants.py
@@ -22,7 +22,7 @@ def get_desktop_dir():
 # ── User config / data paths ────────────────────────────────────────────
 fungus_launcher_dir = PathManager.user_config('fungus-launcher')
 icons_dir = PathManager.user_config('fungus-launcher/icons')
-config_file_dir = PathManager.user_config('fungus-launcher/config.ini')
+config_file_path = PathManager.user_config('fungus-launcher/config.ini')
 envar_dir = PathManager.user_config('fungus-launcher/envar.txt')
 share_dir = PathManager.user_data()
 
diff --git a/fungus/dialogs.py b/fungus/dialogs.py
index 72bf5fe..56c47e3 100644
--- a/fungus/dialogs.py
+++ b/fungus/dialogs.py
@@ -242,26 +242,6 @@ def create_error_dialog(
         sys.exit()
 
 
-class SteamRuntimeWarningDialog(Gtk.MessageDialog):
-    """Warn the user that the UMU Steam Runtime is not available."""
 
-    def __init__(self):
-        super().__init__(
-            parent=None,
-            flags=Gtk.DialogFlags.MODAL,
-            message_type=Gtk.MessageType.WARNING,
-            buttons=Gtk.ButtonsType.OK,
-            text="Steam Runtime not available",
-        )
-        self.format_secondary_text(
-            "The UMU Steam Runtime directory was not found. "
-            "Games using UMU-Launcher will not be able to run.\n\n"
-            "Please open Settings → UMU-Launcher and update the runtime."
-        )
-        self.set_resizable(False)
-        self.set_icon_from_file(fungus_png)
-        subprocess.Popen(["canberra-gtk-play", "-i", "dialog-warning"])
-        self.run()
-        self.destroy()
 
 
diff --git a/fungus/game_launcher.py b/fungus/game_launcher.py
index fb0806d..68efca6 100644
--- a/fungus/game_launcher.py
+++ b/fungus/game_launcher.py
@@ -38,9 +38,14 @@ log = get_logger(__name__)
 
 @dataclass
 class LaunchHandle:
-    """Handle for a launched process (for GLib watches)."""
+    """Handle for a launched process (for GLib watches).
 
-    process: subprocess.Popen
+    ``process`` is ``None`` when launch was skipped due to validation
+    failure (missing Steam Runtime, missing Proton, spawn error).  In
+    those cases the GTK adapter has already been notified via callbacks.
+    """
+
+    process: subprocess.Popen | None
     pid: int
 
 
@@ -366,7 +371,7 @@ class GameLauncher:
                 self._on_splash_close()
             if self._on_steam_runtime_missing:
                 self._on_steam_runtime_missing()
-            return LaunchHandle(subprocess.Popen([]), 0)  # dummy
+            return LaunchHandle(None, 0)
 
         if proton_dir and not self._check_proton_path():
             if not has_proton_installed():
@@ -374,13 +379,13 @@ class GameLauncher:
                     self._on_splash_close()
                 if self._on_proton_missing:
                     self._on_proton_missing()
-                return LaunchHandle(subprocess.Popen([]), 0)  # dummy
+                return LaunchHandle(None, 0)
 
             if self._on_splash_close:
                 self._on_splash_close()
             if self._on_proton_path_missing:
                 self._on_proton_path_missing(proton_dir)
-            return LaunchHandle(subprocess.Popen([]), 0)  # dummy
+            return LaunchHandle(None, 0)
 
         # ── Load env file ───────────────────────────────────────────
         self.env_from_file = self.load_env_from_file(envar_dir)
@@ -427,7 +432,7 @@ class GameLauncher:
             )
             if self._on_spawn_error:
                 self._on_spawn_error(error_msg)
-            return LaunchHandle(subprocess.Popen([]), 0)  # dummy
+            return LaunchHandle(None, 0)
 
         if self._on_process_started:
             self._on_process_started()
diff --git a/fungus/game_model.py b/fungus/game_model.py
index 3930811..2f114bc 100644
--- a/fungus/game_model.py
+++ b/fungus/game_model.py
@@ -5,8 +5,6 @@ import json
 import os
 import tempfile
 from dataclasses import dataclass, field
-from typing import TYPE_CHECKING
-
 # ── Game data model ─────────────────────────────────────────────────────
 
 
@@ -192,17 +190,12 @@ class GameLibrary:
         Returns a list of ``Game`` objects.  If the same ``gameid`` appears
         in multiple files, the first occurrence wins and a warning is logged.
         """
-        if TYPE_CHECKING:
+        try:
             from fungus.logger import get_logger
 
             log = get_logger(__name__)
-        else:
-            try:
-                from fungus.logger import get_logger
-
-                log = get_logger(__name__)
-            except ImportError:
-                log = None  # type: ignore[assignment]
+        except ImportError:
+            log = None  # type: ignore[assignment]
 
         games: list[Game] = []
         seen: dict[str, str] = {}  # gameid -> filename
diff --git a/fungus/proton_manager.py b/fungus/proton_manager.py
index e726cfc..23f0c86 100644
--- a/fungus/proton_manager.py
+++ b/fungus/proton_manager.py
@@ -419,9 +419,10 @@ def download_and_extract(
         button_update_callback("Extracting...")
 
     while pending_callback and pending_callback():
-        pass
+        time.sleep(0.01)
 
     mode = "r:xz" if tar_file_path.endswith(".tar.xz") else "r:gz"
+    temp_dir = None  # cleaned up on failure
 
     try:
         with tarfile.open(tar_file_path, mode) as tar:
@@ -472,6 +473,16 @@ def download_and_extract(
             message_callback("Error during extraction")
         if button_update_callback:
             button_update_callback("Download")
+        # Clean up temp files on failure
+        try:
+            os.remove(tar_file_path)
+        except OSError:
+            pass
+        if temp_dir:
+            try:
+                shutil.rmtree(temp_dir)
+            except OSError:
+                pass
     finally:
         if button_enable_callback:
             button_enable_callback()
diff --git a/fungus/run_manager.py b/fungus/run_manager.py
index 03df048..e87e073 100644
--- a/fungus/run_manager.py
+++ b/fungus/run_manager.py
@@ -189,9 +189,9 @@ def handle_command(
 
     handle: LaunchHandle = launcher.start()
 
-    # If start() returned a dummy handle, validation failed — the
-    # appropriate error dialog is already shown via callbacks.
-    if handle.process and handle.process.stdout is not None:
+    # If start() returned a handle with process=None, validation failed —
+    # the appropriate error dialog is already shown via callbacks.
+    if handle.process is not None:
         # ── Attach GLib I/O watches ───────────────────────────────
         def make_io_handler(is_stderr: bool):
             """Create an I/O line handler for the given stream."""