From f2049ffb11750835849cfe3ef12cbdd84c1c764d Mon Sep 17 00:00:00 2001 From: eshanized Date: Sun, 29 Dec 2024 11:20:41 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20perf(advance):=20formatted?= =?UTF-8?q?=20strings=20for=20cleaner=20log=20output?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../snigdhaos-welcome/snigdhaos-welcome.py | 59 +++++++++++-------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/usr/share/snigdhaos-welcome/snigdhaos-welcome.py b/usr/share/snigdhaos-welcome/snigdhaos-welcome.py index 519845d..8c70fb4 100644 --- a/usr/share/snigdhaos-welcome/snigdhaos-welcome.py +++ b/usr/share/snigdhaos-welcome/snigdhaos-welcome.py @@ -227,37 +227,43 @@ class Main(Gtk.Window): def on_adv_install_clicked(self, widget): + """ + Handles the "Advanced Install" button click. Configures online installation settings + and launches the appropriate installer based on system state. + """ + # Check if the Pacman lockfile exists if not os.path.exists(self.pacman_lockfile): + # Update the button's style and label to reflect the enabled state widget.set_name("button_adv_install_enabled") - widget.get_child().set_markup( - "Online Installation" - ) - selected_bg_color = widget.get_style_context().lookup_color( - "theme_selected_bg_color" - ) - if selected_bg_color[0] is True: + widget.get_child().set_markup("Online Installation") + + # Retrieve the selected background color from the theme + selected_bg_color = widget.get_style_context().lookup_color("theme_selected_bg_color") + if selected_bg_color[0]: # If the color is successfully retrieved + # Convert the Gdk.Color to HEX format for custom CSS theme_bg_hex_color = self.convert_to_hex(selected_bg_color[1]) custom_css = css.replace("@theme_base_color_button", theme_bg_hex_color) self.style_provider.load_from_data(custom_css, len(custom_css)) + + # Reset the style for the "Easy Install" button self.button_easy_install.set_name("button_easy_install") + + # Configuration files for the advanced installation settings_adv_file = "/etc/calamares/settings-advanced.conf" system_update_file = "/etc/calamares/modules/packages-system-update.conf" - app_cmd = [ - "sudo", - "cp", - settings_adv_file, - "/etc/calamares/settings.conf", - ] + + # Copy the advanced settings configuration file + app_cmd = ["sudo", "cp", settings_adv_file, "/etc/calamares/settings.conf"] threading.Thread(target=self.run_app, args=(app_cmd,), daemon=True).start() - app_cmd = [ - "sudo", - "cp", - system_update_file, - "/etc/calamares/modules/packages.conf", - ] + + # Copy the system update configuration for online installation + app_cmd = ["sudo", "cp", system_update_file, "/etc/calamares/modules/packages.conf"] threading.Thread(target=self.run_app, args=(app_cmd,), daemon=True).start() + + # Check for EFI bootloader support efi_file_check = self.file_check("/sys/firmware/efi/fw_platform_size") - if efi_file_check is True: + if efi_file_check: + # If EFI is supported, display the bootloader selection dialog md = MessageDialogBootloader( title="Choose Bootloader", install_method="Online Installation", @@ -267,23 +273,24 @@ class Main(Gtk.Window): ) md.show_all() else: + # Launch the Calamares installer directly if not an EFI system subprocess.Popen([self.calamares_polkit, "-d"], shell=False) else: - print( - "[ERROR]: Pacman lockfile found %s, is another pacman process running ?" - % self.pacman_lockfile - ) + # Handle the case where a Pacman lockfile exists + print(f"[ERROR]: Pacman lockfile found {self.pacman_lockfile}, is another pacman process running?") + + # Display a warning dialog about the lockfile md = Gtk.MessageDialog( parent=self, flags=0, message_type=Gtk.MessageType.WARNING, buttons=Gtk.ButtonsType.OK, - text="Pacman lockfile found %s, is another pacman process running ?" - % self.pacman_lockfile, + text=f"Pacman lockfile found {self.pacman_lockfile}, is another pacman process running?", title="Warning", ) md.run() md.destroy() + def on_gp_clicked(self, widget): app_cmd = ["/usr/bin/gparted"] pacman_cmd = [