import gi gi.require_version("Gtk", "4.0") gi.require_version("Adw", "1") from gi.repository import Adw, Gtk class ModulesPage(Adw.Bin): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.nvidia_drivers = False self.chromebook_audio = False self.android_apps = False self.module_titles = { "nvidia_drivers": "Proprietary NVIDIA Drivers", "chromebook_audio": "Chromebook Audio Fixes", "android_apps": "Android Apps Support", } # 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) box.set_margin_top(24) box.set_margin_bottom(24) clamp.set_child(box) # Title title = Gtk.Label(label="Additional Modules") title.add_css_class("title-1") box.append(title) descr = Gtk.Label( label="Select additional components you would like to install. (Internet connection required)" ) descr.set_wrap(True) box.append(descr) dont_worry = Gtk.Label(label="Don't worry, you can always install them later.") dont_worry.set_wrap(True) box.append(dont_worry) # Preferences Group self.modules_group = Adw.PreferencesGroup() self.modules_group.set_title("Optional Features") box.append(self.modules_group) # NVIDIA Drivers self.add_module_row( self.module_titles["nvidia_drivers"], "Install proprietary drivers for NVIDIA graphics cards for better performance.", "nvidia_drivers", ) # Chromebook Audio self.add_module_row( self.module_titles["chromebook_audio"], "Install additional audio drivers for Chromebook devices.", "chromebook_audio", ) # Android Apps self.add_module_row( self.module_titles["android_apps"], "Install Waydroid to run Android applications on Iridium OS.", "android_apps", ) def add_module_row(self, title, subtitle, attr_name): row = Adw.ActionRow() row.set_title(title) row.set_subtitle(subtitle) switch = Gtk.Switch() switch.set_valign(Gtk.Align.CENTER) # Set initial state switch.set_active(getattr(self, attr_name)) # Connect signal switch.connect("notify::active", self.on_switch_toggled, attr_name) row.add_suffix(switch) self.modules_group.add(row) def on_switch_toggled(self, switch, gparam, attr_name): setattr(self, attr_name, switch.get_active()) def get_modules(self): enabled_modules = [] if self.nvidia_drivers: enabled_modules.append(self.module_titles["nvidia_drivers"]) if self.chromebook_audio: enabled_modules.append(self.module_titles["chromebook_audio"]) if self.android_apps: enabled_modules.append(self.module_titles["android_apps"]) return enabled_modules