From 6bf3955fbdca00420e5dae6b08ee8350450c69f9 Mon Sep 17 00:00:00 2001 From: vilez Date: Wed, 5 Jun 2024 08:18:21 +0300 Subject: [PATCH 01/15] refactor: Remove redundant code --- src/Main.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Main.py b/src/Main.py index 9c6d8a7..d4dbd7e 100755 --- a/src/Main.py +++ b/src/Main.py @@ -188,7 +188,6 @@ def pre(): return None self.password_page = self.new_page_input( _("Enter new password"), after_userdata) - self.deck.set_visible_child(self.page_questions) def after_userdata(x): password1 = self.password_page.entry.get_text() @@ -264,7 +263,6 @@ def pre(): self.repair_page = self.new_page_listbox( _("Choose Partition for Filesystem Repair"), partition_names, partition_os, after_userdata) - self.deck.set_visible_child(self.page_questions) def after_userdata(widget, userdata): partition_for_repair = self.repair_page.listbox.get_selected_row().get_title() @@ -422,7 +420,6 @@ def pre(): part.operating_system for part in self.rootfs_list] self.rootfs_page = self.new_page_listbox( _("Select a root filesystem"), partition_names, partition_os, post, pending_func) - self.deck.set_visible_child(self.page_questions) return None self.rootfs = self.rootfs_list[0] return self.rootfs @@ -450,7 +447,6 @@ def pre(): elif len(users) > 1: self.users_page = self.new_page_listbox( _("Select a user"), users, None, after_userdata, pending_func) - self.deck.set_visible_child(self.page_questions) return None self.user = users[0] return self.user @@ -475,7 +471,6 @@ def pre(): elif len(mbrs) > 1: self.mbr_page = self.new_page_listbox( _("Select the Master Boot Record (MBR)"), mbrs, None, after_userdata, pending_func) - self.deck.set_visible_child(self.page_questions) return None self.mbr = mbrs[0] return self.mbr @@ -644,7 +639,9 @@ def on_questions_row_activated(widget): row.set_property('activatable', True) row.connect("activated", on_questions_row_activated) page.listbox.insert(row, -1) + self.carousel_questions.insert(page, -1) + self.deck.set_visible_child(self.page_questions) return page def new_page_input(self, label_text, btn_continue_clicked_signal): @@ -667,6 +664,7 @@ def input_change_event(widget): page.entry_second.connect("changed", input_change_event) page.button.connect('clicked', btn_continue_clicked_signal) self.carousel_questions.insert(page, -1) + self.deck.set_visible_child(self.page_questions) return page From e556b49272475d80891817922119d8b6278afba4 Mon Sep 17 00:00:00 2001 From: vilez Date: Wed, 5 Jun 2024 08:23:13 +0300 Subject: [PATCH 02/15] feat: show status page when status page content changes --- src/Main.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Main.py b/src/Main.py index d4dbd7e..048ccc9 100755 --- a/src/Main.py +++ b/src/Main.py @@ -339,7 +339,6 @@ def pre(): self.user = None def post(): - self.btn_close_logs.clicked() self.update_status_page(_("Chroot Process Successfully Concluded"), "emblem-ok-symbolic", _( "The chroot process has finished successfully"), True, True) @@ -351,6 +350,7 @@ def update_status_page(self, title, icon_name, description, stop_spinner=False, self.status_page.set_description(description) self.btn_go_mainpage.set_sensitive(enable_mainpage) self.spinner_loading.start() + self.btn_close_logs.clicked() if stop_spinner: self.spinner_loading.stop() @@ -370,21 +370,18 @@ def vte_command(self, command, post_func, ask_confirmation=True): except Exception as e: # write error to stderr sys.stderr.write(str(e) + "\n") - self.btn_close_logs.clicked() self.update_status_page( _("An error occured"), "dialog-error-symbolic", str(e), True, True) def vte_cb(self, Terminal, pid, error): Terminal.reset(True, True) if error != None or pid == -1: - self.btn_close_logs.clicked() self.update_status_page(_("An error occured"), "dialog-error-symbolic", _( "An error occurred before the command has been executed"), True, True) return def vte_exited(self, widget, status, post_func): exit_status = os.waitstatus_to_exitcode(status) - self.btn_close_logs.clicked() if exit_status != 0: self.update_status_page(_("An error occured"), "dialog-error-symbolic", _( "An error occured while executing the command. Please check the logs"), True, True) From eca5d4cbdb1afcb69c5f2df22ce9cd37ea6500e9 Mon Sep 17 00:00:00 2001 From: vilez Date: Wed, 5 Jun 2024 08:24:11 +0300 Subject: [PATCH 03/15] refactor: Update vte_command parameter name for clarity --- src/Main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Main.py b/src/Main.py index 048ccc9..e3a7947 100755 --- a/src/Main.py +++ b/src/Main.py @@ -354,9 +354,9 @@ def update_status_page(self, title, icon_name, description, stop_spinner=False, if stop_spinner: self.spinner_loading.stop() - def vte_command(self, command, post_func, ask_confirmation=True): + def vte_command(self, command, post_func, ask_user_confirm=True): try: - if ask_confirmation and not self.ask_confirmation(_("Are you sure you want to continue? This action is irreversible and may cause data loss.")): + if ask_user_confirm and not self.ask_confirmation(_("Are you sure you want to continue? This action is irreversible and may cause data loss.")): self.update_status_page(_("Operation Cancelled"), "dialog-warning-symbolic", _( "The operation has been cancelled by the user."), True, True) return From 09debb730cee049c90a99224ce9649c8d279c8b9 Mon Sep 17 00:00:00 2001 From: vilez Date: Wed, 5 Jun 2024 08:54:06 +0300 Subject: [PATCH 04/15] refactor: simplify pre-checks in row functions --- src/Main.py | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/Main.py b/src/Main.py index e3a7947..7c4a0e9 100755 --- a/src/Main.py +++ b/src/Main.py @@ -136,10 +136,9 @@ def row_init_func(self, pre_function): def on_row_reinstall_grub_activated(self, widget): def pre(): - if self.get_rootfs(widget, pre) == None: - return - if self.get_mbr(widget, pre) == None: + if self.get_rootfs(widget, pre) == None or self.get_mbr(widget, pre) == None: return + if os.path.exists("/sys/firmware/efi/efivars"): clear_efi = self.ask_confirmation( "Do you want to clear efivars?") @@ -148,6 +147,7 @@ def pre(): self.update_status_page(_("Reinstalling GRUB Bootloader"), "content-loading-symbolic", _( "We're reinstalling the GRUB boot loader to ensure your system can start up properly. This process may take a few moments. Once complete, your computer should boot into Pardus as usual."), False, False) + if self.rootfs.root_subvol == None: self.vte_command("env disk={} mbr={} clear_efi={} grub-reinstall".format( self.rootfs.name, self.mbr, clear_efi), post) @@ -165,8 +165,10 @@ def on_row_fix_broken_activated(self, widget): def pre(): if self.get_rootfs(widget, pre) == None: return + self.update_status_page(_("Fixing Broken Packages"), "content-loading-symbolic", _( "We're resolving issues with broken packages on your system to ensure everything works. This may take some time, but we're on it. Once complete, your system should be stable and ready for use."), False, False) + if self.rootfs.root_subvol == None: self.vte_command( "env disk={} fix-broken-packages".format(self.rootfs.name), post) @@ -182,19 +184,20 @@ def post(): def on_row_reset_password_activated(self, widget): def pre(): - if self.get_rootfs(widget, pre) == None: - return None - if self.get_user(widget, pre) == None: + if self.get_rootfs(widget, pre) == None or self.get_user(widget, pre) == None: return None + self.password_page = self.new_page_input( _("Enter new password"), after_userdata) def after_userdata(x): password1 = self.password_page.entry.get_text() password2 = self.password_page.entry_second.get_text() + self.deck.set_visible_child(self.page_loading) self.update_status_page(_("Resetting password"), "content-loading-symbolic", _( "We're resetting your password to provide access to your account. This process will only take a moment. Once complete, you'll be able to log in with your new password into your Pardus system."), False, False) + if self.rootfs.root_subvol == None: self.vte_command("env disk={} user={} pass1={} pass2={} reset-password".format( self.rootfs.name, self.user, password1, password2), post, False) @@ -212,8 +215,10 @@ def on_row_update_activated(self, widget): def pre(): if self.get_rootfs(widget, pre) == None: return + self.update_status_page(_("Updating Software Packages"), "content-loading-symbolic", _( "We're currently updating the software packages on your system to ensure you have the latest features and security enhancements. This process may take some time depending on the number of updates available. Please be patient."), False, False) + if self.rootfs.root_subvol == None: self.vte_command( "env disk={} full-upgrade".format(self.rootfs.name), post) @@ -229,12 +234,12 @@ def post(): def on_row_reinstall_activated(self, widget): def pre(): - if self.get_rootfs(widget, pre) == None: - return - if self.get_mbr(widget, pre) == None: + if self.get_rootfs(widget, pre) == None or self.get_mbr(widget, pre) == None: return + self.update_status_page(_("System Reinstallation"), "content-loading-symbolic", _( "We're performing a clean reinstall of your system to ensure a fresh start. This process will reset your system to its original state, removing all applications."), False, False) + if self.rootfs.root_subvol == None: self.vte_command( "env disk={} mbr={} pardus-reinstall".format(self.rootfs.name, self.mbr), post) @@ -252,6 +257,7 @@ def on_row_repair_filesystem_activated(self, widget): def pre(): self.update_status_page(_("Detecting Partitions"), "content-loading-symbolic", _( "We're scanning your system to locate available partitions."), False, False) + partitions = self.list_partitions() if len(partitions) == 0: self.update_status_page(_("Unable to Detect Partitions"), "dialog-error-symbolic", _( @@ -281,12 +287,12 @@ def post(): def on_row_reset_config_activated(self, widget): def pre(): self.deck.set_visible_child(self.page_loading) - if self.get_rootfs(widget, pre) == None: - return - if self.get_user(widget, pre) == None: + if self.get_rootfs(widget, pre) == None or self.get_user(widget, pre) == None: return + self.update_status_page(_("Resetting User Settings"), "content-loading-symbolic", _( "We're resetting your user configuration to its default state. This will revert any custom settings back to their original values. Please note that any personalized preferences will be lost. Once complete, your system will be refreshed and ready for use."), False, False) + if self.rootfs.root_subvol == None: self.vte_command( "env pardus-chroot /dev/{} su {} -c 'cd ; rm -rvf .dbus .cache .local .config'".format(self.rootfs.name, self.user), post) @@ -304,10 +310,12 @@ def on_row_dump_log_activated(self, widget): def pre(): if self.get_rootfs(widget, pre) == None: return + liveuser_home = self.run_command( 'grep "x:1000:" /etc/passwd | cut -f 6 -d ":"') self.update_status_page(_("Extracting System Logs"), "content-loading-symbolic", _( "We're collecting important system logs and placing them in the '{}' directory as you requested. These logs contain helpful information about your system's activity and any issues it may be experiencing. Depending on how much information there is, this might take a little time. Thanks for waiting while we gather this data.").format(liveuser_home), False, False) + if self.rootfs.root_subvol == None: self.vte_command( "env disk={} dump-info-log {}".format(self.rootfs.name, liveuser_home), post, False) @@ -325,10 +333,10 @@ def on_row_chroot_activated(self, widget): def pre(): self.update_status_page(_("Entering Chroot Environment"), "content-loading-symbolic", _( "We're accessing a special system environment called chroot at your request. This allows you to make changes as if you were working directly on your installed operating system. Please wait while we set up this environment to address your needs."), False, True) - if self.get_rootfs(widget, pre) == None: - return - if self.get_user(widget, pre) == None: + if self.get_rootfs(widget, pre) == None or self.get_user(widget, pre) == None: return + + # show terminal page self.btn_show_log.clicked() if self.rootfs.root_subvol == None: self.vte_command("env disk={} pardus-chroot /dev/{} su {} -".format( From 23781d7c4cf9255b7b5757b11f97bdf9a4ca1b37 Mon Sep 17 00:00:00 2001 From: vilez Date: Wed, 5 Jun 2024 08:56:08 +0300 Subject: [PATCH 05/15] refactor: Refactor code to remove redundant deck.set_visible_child() calls --- src/Main.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Main.py b/src/Main.py index 7c4a0e9..aae8d66 100755 --- a/src/Main.py +++ b/src/Main.py @@ -194,7 +194,6 @@ def after_userdata(x): password1 = self.password_page.entry.get_text() password2 = self.password_page.entry_second.get_text() - self.deck.set_visible_child(self.page_loading) self.update_status_page(_("Resetting password"), "content-loading-symbolic", _( "We're resetting your password to provide access to your account. This process will only take a moment. Once complete, you'll be able to log in with your new password into your Pardus system."), False, False) @@ -272,7 +271,6 @@ def pre(): def after_userdata(widget, userdata): partition_for_repair = self.repair_page.listbox.get_selected_row().get_title() - self.deck.set_visible_child(self.page_loading) self.update_status_page(_("Repairing Filesystem on {}").format(partition_for_repair), "content-loading-symbolic", _( "We're currently repairing the filesystem on the selected partition. This process may take some time, depending on the size and severity of the issues found. Please be patient while we work to restore the partition's functionality."), False, False) self.vte_command( @@ -286,7 +284,6 @@ def post(): def on_row_reset_config_activated(self, widget): def pre(): - self.deck.set_visible_child(self.page_loading) if self.get_rootfs(widget, pre) == None or self.get_user(widget, pre) == None: return @@ -433,7 +430,6 @@ def post(widget, pending_func): selected = self.rootfs_page.listbox.get_selected_row().get_title() self.rootfs = next( (x for x in self.rootfs_list if x.name == selected), None) - self.deck.set_visible_child(self.page_loading) self.update_status_page(_("Root Filesystem Chosen"), "emblem-ok-symbolic", _( "You've selected the root filesystem for further action."), False, False) if pending_func != None: @@ -458,7 +454,6 @@ def pre(): def after_userdata(widget, pending_func): self.user = self.users_page.listbox.get_selected_row().get_title() - self.deck.set_visible_child(self.page_loading) self.update_status_page(_("User Chosen"), "emblem-ok-symbolic", _( "You've selected a user for further action. This step is important for making changes specific to the chosen user."), False, False) if pending_func != None: @@ -482,7 +477,6 @@ def pre(): def after_userdata(widget, pending_func): self.mbr = self.mbr_page.listbox.get_selected_row().get_title() - self.deck.set_visible_child(self.page_loading) self.update_status_page(_("MBR chosen"), "emblem-ok-symbolic", _( "You've successfully selected the Master Boot Record (MBR). This selection is essential for configuring your system's boot process."), False, False) if pending_func != None: @@ -624,6 +618,9 @@ def new_page_listbox(self, label_text, row_titles, row_subtitles, btn_next_click def on_questions_row_activated(widget): page.button.set_sensitive(True) + def on_button_next_clicked(widget): + self.deck.set_visible_child(self.page_loading) + for child in self.carousel_questions.get_children(): self.carousel_questions.remove(child) @@ -633,6 +630,7 @@ def on_questions_row_activated(widget): raise ValueError( "row_titles and row_subtitles must have the same length") + page.button.connect('clicked', on_button_next_clicked) page.button.connect( 'clicked', btn_next_clicked_signal, btn_next_userdata) for title, subtitle in zip(row_titles, row_subtitles): @@ -664,9 +662,13 @@ def input_change_event(widget): if entry_text == entry_second_text and entry_text != "": page.warn_entry.set_visible(False) page.button.set_sensitive(True) + + def on_button_next_clicked(widget): + self.deck.set_visible_child(self.page_loading) page.entry.connect("changed", input_change_event) page.entry_second.connect("changed", input_change_event) + page.button.connect('clicked', on_button_next_clicked) page.button.connect('clicked', btn_continue_clicked_signal) self.carousel_questions.insert(page, -1) self.deck.set_visible_child(self.page_questions) From 846ca1faa7b3f23315b6f56d4fc194493da277dc Mon Sep 17 00:00:00 2001 From: vilez Date: Wed, 5 Jun 2024 09:16:17 +0300 Subject: [PATCH 06/15] style: set vte_terminal colors based on window colors --- src/Main.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Main.py b/src/Main.py index aae8d66..8775309 100755 --- a/src/Main.py +++ b/src/Main.py @@ -67,6 +67,11 @@ def __init__(self, *args, **kwargs): self.box_vte.add(self.vte_terminal) self.vte_terminal.show() self.vte_terminal.connect("child-exited", self.vte_exited) + style_context = self.window.get_style_context() + background_color= style_context.get_background_color(Gtk.StateFlags.NORMAL); + foreground_color= style_context.get_color(Gtk.StateFlags.NORMAL); + self.vte_terminal.set_color_background(background_color) + self.vte_terminal.set_color_foreground(foreground_color) self.dialog_about = self.builder.get_object("dialog_about") self.dialog_about.set_version(APPVERSION) From ebc6ae27b684e4d8da16d4618d6057653e383145 Mon Sep 17 00:00:00 2001 From: vilez Date: Wed, 5 Jun 2024 09:19:10 +0300 Subject: [PATCH 07/15] fix: remove spacing from page loading, so that the meaningless space on vte_terminal also disappears --- src/data/ui/AppWindow.ui | 1 - 1 file changed, 1 deletion(-) diff --git a/src/data/ui/AppWindow.ui b/src/data/ui/AppWindow.ui index f7e61f4..9c3cfd9 100644 --- a/src/data/ui/AppWindow.ui +++ b/src/data/ui/AppWindow.ui @@ -397,7 +397,6 @@ True False vertical - 25 True From 72c63d76f30eefd7649b8795c068ff6fb23ae4c2 Mon Sep 17 00:00:00 2001 From: vilez Date: Wed, 5 Jun 2024 10:04:29 +0300 Subject: [PATCH 08/15] style: update margin for footer label --- src/data/ui/AppWindow.ui | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data/ui/AppWindow.ui b/src/data/ui/AppWindow.ui index 9c3cfd9..3b27bab 100644 --- a/src/data/ui/AppWindow.ui +++ b/src/data/ui/AppWindow.ui @@ -238,6 +238,8 @@ True False + 5 + 5 TÜBİTAK ULAKBİM | 2024