Hook up GUI Install button to backend logic

This commit is contained in:
2026-02-03 16:34:36 +01:00
parent 2377b0269a
commit 33d989cfad

View File

@@ -196,26 +196,97 @@ class InstallerWindow(Adw.ApplicationWindow):
modules = self.modules_page.get_modules() modules = self.modules_page.get_modules()
user_info = self.user_page.get_user_info() user_info = self.user_page.get_user_info()
partitions_config = {}
if mode == "manual":
partitions_config = self.partitioning_page.get_config()
elif mode == "automatic":
partitions = calculate_auto_partitions(disk)
partitions_config = {"partitions": partitions}
if self.mock_mode: if self.mock_mode:
print("!!! MOCK MODE ENABLED - NO CHANGES WILL BE MADE !!!") print("!!! MOCK MODE ENABLED - NO CHANGES WILL BE MADE !!!")
print(f"Target Disk: {disk}") print(f"Target Disk: {disk}")
print(f"Mode: {mode}") print(f"Mode: {mode}")
print(f"Modules: {modules}") print(f"Modules: {modules}")
print(f"User: {user_info}") print(f"User: {user_info}")
print(f"Partition Config: {partitions_config}")
print("Simulation complete.") print("Simulation complete.")
# Show success in UI even in mock
self.show_finish_page("Mock Installation Complete!")
else: else:
print("NOT IMPLEMENTED") from ..backend.disk import auto_partition_disk, mount_partitions
from ..backend.os_install import install_minimal_os, configure_system
# Simple progress UI transition
self.show_progress_page("Installing Iridium OS...")
# We should really run this in a thread to keep UI responsive,
# but for "barely bootable" requirement and simplicity:
try:
# Step 1: Partitioning
print("Step 1: Partitioning...")
parts = auto_partition_disk(disk)
# Step 2: Mounting
print("Step 2: Mounting...")
mount_root = "/mnt"
mount_partitions(parts, mount_root)
# Step 3: OS Installation
print("Step 3: OS Installation...")
install_minimal_os(mount_root)
# Step 4: Configure
print("Step 4: Configuration...")
configure_system(mount_root, parts)
self.show_finish_page("Installation Successful!")
except Exception as e:
print(f"Installation failed: {e}")
self.show_finish_page(f"Installation Failed: {e}", success=False)
return return
def show_progress_page(self, message):
prog_page = Adw.StatusPage()
prog_page.set_title(message)
prog_page.set_description("Please wait while we set up your system.")
spinner = Gtk.Spinner()
spinner.set_size_request(32, 32)
spinner.set_halign(Gtk.Align.CENTER)
spinner.start()
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
box.append(spinner)
prog_page.set_child(box)
name = "progress_install"
self.stack.add_named(prog_page, name)
self.stack.set_visible_child_name(name)
# Hide navigation buttons during install
self.bottom_bar.set_visible(False)
def show_finish_page(self, message, success=True):
finish_page = Adw.StatusPage()
finish_page.set_title(message)
if success:
finish_page.set_icon_name("emblem-ok-symbolic")
finish_page.set_description("You can now restart your computer.")
btn_label = "Restart"
else:
finish_page.set_icon_name("dialog-error-symbolic")
finish_page.set_description("An error occurred during installation.")
btn_label = "Close"
btn = Gtk.Button(label=btn_label)
btn.set_halign(Gtk.Align.CENTER)
btn.add_css_class("suggested-action")
btn.connect("clicked", lambda b: self.close())
finish_page.set_child(btn)
name = "finish_install"
self.stack.add_named(finish_page, name)
self.stack.set_visible_child_name(name)
# Make bottom bar visible but maybe just with a close button if we didn't have the child btn
# self.bottom_bar.set_visible(True)
# self.next_button.set_label("Finish")
if next_index < len(self.page_ids): if next_index < len(self.page_ids):
self.current_page_index = next_index self.current_page_index = next_index
self.stack.set_visible_child_name(self.page_ids[self.current_page_index]) self.stack.set_visible_child_name(self.page_ids[self.current_page_index])