Proper automatic/manual partitioning switch
This commit is contained in:
74
iridium_installer/ui/pages/install_mode.py
Normal file
74
iridium_installer/ui/pages/install_mode.py
Normal file
@@ -0,0 +1,74 @@
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "4.0")
|
||||
gi.require_version("Adw", "1")
|
||||
from gi.repository import Adw, Gtk
|
||||
|
||||
|
||||
class InstallModePage(Adw.Bin):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.mode = "automatic"
|
||||
|
||||
# Main Layout
|
||||
clamp = Adw.Clamp()
|
||||
clamp.set_maximum_size(600)
|
||||
self.set_child(clamp)
|
||||
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
box.set_spacing(24)
|
||||
box.set_valign(Gtk.Align.CENTER) # Vertically Center
|
||||
box.set_margin_top(24)
|
||||
box.set_margin_bottom(24)
|
||||
clamp.set_child(box)
|
||||
|
||||
# Title
|
||||
title = Gtk.Label(label="Installation Type")
|
||||
title.add_css_class("title-1")
|
||||
box.append(title)
|
||||
|
||||
descr = Gtk.Label(label="How would you like to install Iridium OS?")
|
||||
descr.set_wrap(True)
|
||||
box.append(descr)
|
||||
|
||||
# Selection Group
|
||||
group = Adw.PreferencesGroup()
|
||||
box.append(group)
|
||||
|
||||
# Automatic
|
||||
self.auto_row = Adw.ActionRow()
|
||||
self.auto_row.set_title("Automatic")
|
||||
self.auto_row.set_subtitle(
|
||||
"Erase the selected disk and install Iridium. (Recommended)"
|
||||
)
|
||||
self.auto_row.set_icon_name("drive-harddisk-solidstate-symbolic")
|
||||
group.add(self.auto_row)
|
||||
|
||||
self.auto_radio = Gtk.CheckButton()
|
||||
self.auto_radio.set_active(True)
|
||||
self.auto_radio.connect("toggled", self.on_mode_toggled, "automatic")
|
||||
self.auto_row.add_suffix(self.auto_radio)
|
||||
self.auto_row.set_activatable_widget(self.auto_radio)
|
||||
|
||||
# Manual
|
||||
self.manual_row = Adw.ActionRow()
|
||||
self.manual_row.set_title("Manual Partitioning")
|
||||
self.manual_row.set_subtitle(
|
||||
"Create or resize partitions yourself. For advanced users."
|
||||
)
|
||||
self.manual_row.set_icon_name("preferences-system-symbolic")
|
||||
group.add(self.manual_row)
|
||||
|
||||
self.manual_radio = Gtk.CheckButton()
|
||||
self.manual_radio.set_group(self.auto_radio)
|
||||
self.manual_radio.connect("toggled", self.on_mode_toggled, "manual")
|
||||
self.manual_row.add_suffix(self.manual_radio)
|
||||
self.manual_row.set_activatable_widget(self.manual_radio)
|
||||
|
||||
def on_mode_toggled(self, button, mode_name):
|
||||
if button.get_active():
|
||||
self.mode = mode_name
|
||||
|
||||
def get_mode(self):
|
||||
return self.mode
|
||||
@@ -90,11 +90,12 @@ class PartitioningPage(Adw.Bin):
|
||||
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
box.set_spacing(24)
|
||||
box.set_valign(Gtk.Align.CENTER)
|
||||
box.set_margin_top(24)
|
||||
box.set_margin_bottom(24)
|
||||
clamp.set_child(box)
|
||||
|
||||
title = Gtk.Label(label="Disk Configuration")
|
||||
title = Gtk.Label(label="Manual Partitioning")
|
||||
title.add_css_class("title-1")
|
||||
box.append(title)
|
||||
|
||||
@@ -375,3 +376,6 @@ class PartitioningPage(Adw.Bin):
|
||||
add_menu_item("Create Partition", "list-add-symbolic")
|
||||
|
||||
popover.popup()
|
||||
|
||||
def get_config(self):
|
||||
return {"partitions": self.partitions}
|
||||
|
||||
@@ -22,6 +22,7 @@ class StoragePage(Adw.Bin):
|
||||
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
box.set_spacing(24)
|
||||
box.set_valign(Gtk.Align.CENTER)
|
||||
box.set_margin_top(24)
|
||||
box.set_margin_bottom(24)
|
||||
clamp.set_child(box)
|
||||
|
||||
@@ -4,6 +4,7 @@ gi.require_version("Gtk", "4.0")
|
||||
gi.require_version("Adw", "1")
|
||||
from gi.repository import Adw, Gtk
|
||||
|
||||
from .pages.install_mode import InstallModePage
|
||||
from .pages.partitioning import PartitioningPage
|
||||
from .pages.storage import StoragePage
|
||||
from .pages.user import UserPage
|
||||
@@ -64,12 +65,14 @@ class InstallerWindow(Adw.ApplicationWindow):
|
||||
# Initialize Pages
|
||||
self.welcome_page = WelcomePage()
|
||||
self.storage_page = StoragePage()
|
||||
self.install_mode_page = InstallModePage()
|
||||
self.partitioning_page = PartitioningPage()
|
||||
self.user_page = UserPage()
|
||||
|
||||
# Add Pages
|
||||
self.add_page(self.welcome_page, "welcome")
|
||||
self.add_page(self.storage_page, "storage")
|
||||
self.add_page(self.install_mode_page, "install_mode")
|
||||
self.add_page(self.partitioning_page, "partitioning")
|
||||
self.add_page(self.user_page, "user")
|
||||
|
||||
@@ -96,27 +99,53 @@ class InstallerWindow(Adw.ApplicationWindow):
|
||||
self.next_button.add_css_class("suggested-action")
|
||||
|
||||
def on_back_clicked(self, button):
|
||||
if self.current_page_index > 0:
|
||||
self.current_page_index -= 1
|
||||
self.stack.set_visible_child_name(self.page_ids[self.current_page_index])
|
||||
self.update_buttons()
|
||||
current_page = self.page_ids[self.current_page_index]
|
||||
prev_page = self.page_ids[self.current_page_index - 1]
|
||||
|
||||
if current_page == "user":
|
||||
mode = self.install_mode_page.get_mode()
|
||||
if mode == "automatic":
|
||||
# Skip partitioning
|
||||
self.current_page_index = self.page_ids.index("install_mode")
|
||||
else:
|
||||
self.current_page_index -= 1
|
||||
else:
|
||||
if self.current_page_index > 0:
|
||||
self.current_page_index -= 1
|
||||
|
||||
self.stack.set_visible_child_name(self.page_ids[self.current_page_index])
|
||||
self.update_buttons()
|
||||
|
||||
def on_next_clicked(self, button):
|
||||
# Logic before transition
|
||||
current_page_name = self.page_ids[self.current_page_index]
|
||||
|
||||
if current_page_name == "storage":
|
||||
# Pass selected disk to partitioning page
|
||||
selected_disk = self.storage_page.get_selected_disk()
|
||||
if selected_disk:
|
||||
self.partitioning_page.load_partitions(selected_disk)
|
||||
else:
|
||||
# Optionally handle no disk selected (alert user)
|
||||
pass
|
||||
|
||||
if self.current_page_index < len(self.page_ids) - 1:
|
||||
self.current_page_index += 1
|
||||
next_index = self.current_page_index + 1
|
||||
|
||||
if current_page_name == "install_mode":
|
||||
mode = self.install_mode_page.get_mode()
|
||||
if mode == "automatic":
|
||||
# Skip partitioning page
|
||||
next_index = self.page_ids.index("user")
|
||||
else:
|
||||
# Go to partitioning page
|
||||
next_index = self.page_ids.index("partitioning")
|
||||
|
||||
if current_page_name == "user":
|
||||
print("Install process triggered!")
|
||||
print(f"Disk: {self.storage_page.get_selected_disk()}")
|
||||
mode = self.install_mode_page.get_mode()
|
||||
print(f"Mode: {mode}")
|
||||
if mode == "manual":
|
||||
print(f"Partitioning: {self.partitioning_page.get_config()}")
|
||||
return
|
||||
|
||||
if next_index < len(self.page_ids):
|
||||
self.current_page_index = next_index
|
||||
self.stack.set_visible_child_name(self.page_ids[self.current_page_index])
|
||||
self.update_buttons()
|
||||
else:
|
||||
print("Install process triggered!")
|
||||
|
||||
Reference in New Issue
Block a user