From 74048d616e324c10717fceaf5d40bf8d5a1aed86 Mon Sep 17 00:00:00 2001 From: axtloss Date: Fri, 22 Jul 2022 16:20:34 +0200 Subject: [PATCH] Complete summary page --- src/functions/desktop_screen.py | 16 +++++++- src/functions/keyboard_screen.py | 14 ++++++- src/functions/misc_screen.py | 9 +++++ src/functions/partition_screen.py | 13 +++++++ src/functions/summary_screen.py | 59 +++++++++++++++++++++++++++++ src/functions/timezone_screen.py | 17 ++++++++- src/functions/user_screen.py | 14 +++++++ src/pages/summary_screen.blp | 63 ++++++++++++++++--------------- src/scripts/checkEFI.sh | 3 ++ src/scripts/meson.build | 1 + src/utils/disks.py | 5 +++ src/widgets/disk.py | 3 +- src/widgets/timezone.py | 4 ++ src/widgets/variant.py | 4 ++ src/window.py | 23 ++++++----- 15 files changed, 203 insertions(+), 45 deletions(-) create mode 100644 src/scripts/checkEFI.sh diff --git a/src/functions/desktop_screen.py b/src/functions/desktop_screen.py index 005b8d7..ee7504f 100644 --- a/src/functions/desktop_screen.py +++ b/src/functions/desktop_screen.py @@ -28,21 +28,33 @@ class DesktopScreen(Adw.Bin): list_desktops = Gtk.Template.Child() next_page_button = Gtk.Template.Child() + chosen_desktop = "" + move_to_summary = False + def __init__(self, window, main_carousel, next_page, application, **kwargs): super().__init__(**kwargs) self.window = window self.carousel = main_carousel self.next_page = next_page - self.list_desktops.connect("row-selected", self.selected_timezone) + self.list_desktops.connect("row-selected", self.selected_desktop) self.next_page_button.connect("clicked", self.carousel_next) def carousel_next(self, widget): + if self.move_to_summary: + self.window.summary_screen.initialize() + self.carousel.scroll_to(self.window.summary_screen, True) + else: + self.carousel.scroll_to(self.next_page, True) + + def carousel_next_summary(self, widget): + self.next_page.move_to_summary=True self.carousel.scroll_to(self.next_page, True) - def selected_timezone(self, widget, row): + def selected_desktop(self, widget, row): if row is not None: print(row.get_title()) + self.chosen_desktop = row.get_title() row.select_button.set_active(True) else: print("row is none!!") diff --git a/src/functions/keyboard_screen.py b/src/functions/keyboard_screen.py index d0e3098..795ed7c 100644 --- a/src/functions/keyboard_screen.py +++ b/src/functions/keyboard_screen.py @@ -42,6 +42,7 @@ class KeyboardScreen(Adw.Bin): layout = None variant = "" + move_to_summary = False def __init__(self, window, main_carousel, next_page, application, **kwargs): super().__init__(**kwargs) @@ -82,10 +83,21 @@ class KeyboardScreen(Adw.Bin): def selected_variant(self, widget, row): if row is not None or row is not self.variant_entry_search: self.variant = row - self.carousel.scroll_to(self.next_page, True) + self.carousel_next() else: print("row is none!! variant") + def carousel_next(self): + if self.move_to_summary: + self.window.summary_screen.initialize() + self.carousel.scroll_to(self.window.summary_screen, True) + else: + self.carousel.scroll_to(self.next_page, True) + + def carousel_next_summary(self, widget): + self.next_page.move_to_summary=True + self.carousel.scroll_to(self.next_page, True) + @staticmethod def filter_text(row, terms=None): try: diff --git a/src/functions/misc_screen.py b/src/functions/misc_screen.py index df6680b..df778ef 100644 --- a/src/functions/misc_screen.py +++ b/src/functions/misc_screen.py @@ -34,6 +34,7 @@ class MiscScreen(Adw.Bin): ipv_enabled = False crystal_theming_enabled = False timeshift_enabled = True + move_to_summary = False def __init__(self, window, main_carousel, next_page, application, **kwargs): super().__init__(**kwargs) @@ -47,4 +48,12 @@ class MiscScreen(Adw.Bin): self.ipv_enabled = self.ipv_switch.get_state() self.crystal_theming_enabled = self.theme_switch.get_state() self.timeshift_enabled = self.timeshift_switch.get_state() + if self.move_to_summary: + self.window.summary_screen.initialize() + self.carousel.scroll_to(self.window.summary_screen, True) + else: + self.carousel.scroll_to(self.next_page, True) + + def carousel_next_summary(self, widget): + self.next_page.move_to_summary=True self.carousel.scroll_to(self.next_page, True) diff --git a/src/functions/partition_screen.py b/src/functions/partition_screen.py index 4e581e9..d537d3d 100644 --- a/src/functions/partition_screen.py +++ b/src/functions/partition_screen.py @@ -28,12 +28,25 @@ class PartitionScreen(Adw.Bin): next_page_button = Gtk.Template.Child() #custom_partition = Gtk.Template.Child() + selected_partition = None + move_to_summary = False + def __init__(self, window, main_carousel, next_page, application, **kwargs): super().__init__(**kwargs) self.window = window self.carousel = main_carousel self.next_page = next_page self.next_page_button.connect("clicked", self.carousel_next) + self.partition_list.connect("row_selected", self.row_selected) + + def row_selected(self, widget, row): + if row is not None: + print(row.get_title()) + row.select_button.set_active(True) + self.selected_partition = row + else: + print("row is none!!") def carousel_next(self, widget): + self.window.summary_screen.initialize() self.carousel.scroll_to(self.next_page, True) diff --git a/src/functions/summary_screen.py b/src/functions/summary_screen.py index 7820b6d..c7f38da 100644 --- a/src/functions/summary_screen.py +++ b/src/functions/summary_screen.py @@ -17,6 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +from jade_gui.utils import disks from gi.repository import Gtk, Adw from gettext import gettext as _ @@ -24,5 +25,63 @@ from gettext import gettext as _ class SummaryScreen(Adw.Bin): __gtype_name__ = "SummaryScreen" + timezone_label = Gtk.Template.Child() + timezone_button = Gtk.Template.Child() + keyboard_label = Gtk.Template.Child() + keyboard_button = Gtk.Template.Child() + username_label = Gtk.Template.Child() + username_button = Gtk.Template.Child() + sudo_label = Gtk.Template.Child() + sudo_button = Gtk.Template.Child() + root_label = Gtk.Template.Child() + root_button = Gtk.Template.Child() + desktop_label = Gtk.Template.Child() + desktop_button = Gtk.Template.Child() + partition_label = Gtk.Template.Child() + partition_button = Gtk.Template.Child() + uefi_label = Gtk.Template.Child() + ipv_label = Gtk.Template.Child() + ipv_button = Gtk.Template.Child() + timeshift_label = Gtk.Template.Child() + timeshift_button = Gtk.Template.Child() + theme_label = Gtk.Template.Child() + theme_button = Gtk.Template.Child() + #unakite_label = Gtk.Template.Child() + def __init__(self, window, main_carousel, next_page, application, **kwargs): super().__init__(**kwargs) + self.window = window + + def initialize(self): + self.timezone_button.connect("clicked", self.window.nextPage) + self.keyboard_button.connect("clicked", self.window.timezone_screen.carousel_next_summary) + self.username_button.connect("clicked", self.window.keyboard_screen.carousel_next_summary) + self.sudo_button.connect("clicked", self.window.keyboard_screen.carousel_next_summary) + self.root_button.connect("clicked", self.window.keyboard_screen.carousel_next_summary) + self.desktop_button.connect("clicked", self.window.user_screen.carousel_next_summary) + self.partition_button.connect("clicked", self.window.desktop_screen.carousel_next_summary) + self.ipv_button.connect("clicked", self.window.desktop_screen.carousel_next_summary) + self.timeshift_button.connect("clicked", self.window.desktop_screen.carousel_next_summary) + self.theme_button.connect("clicked", self.window.desktop_screen.carousel_next_summary) + + self.timezone_label.set_title(self.window.timezone_screen.chosen_timezone.region+"/"+self.window.timezone_screen.chosen_timezone.location) + self.timezone_label.set_subtitle(self.window.timezone_screen.chosen_timezone.locale) + + self.keyboard_label.set_title(self.window.keyboard_screen.layout.country) + self.keyboard_label.set_subtitle(self.window.keyboard_screen.variant.variant) + + self.username_label.set_title(self.window.user_screen.username) + self.sudo_label.set_title("sudo enabled" if self.window.user_screen.sudo_enabled else "sudo disabled") + self.root_label.set_title("root enabled" if self.window.user_screen.root_enabled else "root disabled") + + self.desktop_label.set_title(self.window.desktop_screen.chosen_desktop) + + self.partition_label.set_title(self.window.partition_screen.selected_partition.disk) + self.partition_label.set_subtitle(self.window.partition_screen.selected_partition.disk_size) + self.uefi_label.set_title("UEFI" if disks.get_uefi() else "Legacy BIOS") + + self.ipv_label.set_title("ipv6 enabled" if self.window.misc_screen.ipv_enabled else "ipv6 disabled") + self.timeshift_label.set_title("timeshift enabled" if self.window.misc_screen.timeshift_enabled else "timeshift disabled") + self.theme_label.set_title("Crystal theming enabled" if self.window.misc_screen.crystal_theming_enabled else "Crystal theming disabled") + #self.unakite_label.set_title("Unakite enabled "+"enabled" if self.window.misc_screen.) + diff --git a/src/functions/timezone_screen.py b/src/functions/timezone_screen.py index ba6df34..1701b39 100644 --- a/src/functions/timezone_screen.py +++ b/src/functions/timezone_screen.py @@ -32,6 +32,9 @@ class TimezoneScreen(Adw.Bin): timezone_entry_search = Gtk.Template.Child() timezone_search = Gtk.Template.Child() + chosen_timezone = None + move_to_summary = False + def __init__(self, window, main_carousel, next_page, application, **kwargs): super().__init__(**kwargs) self.window = window @@ -46,10 +49,22 @@ class TimezoneScreen(Adw.Bin): print(row) if row is not None or row is not self.timezone_search: print(row.get_title()) - self.carousel.scroll_to(self.next_page, True) + self.chosen_timezone = row + self.carousel_next() else: print("row is none!!") + def carousel_next(self): + if self.move_to_summary: + self.window.summary_screen.initialize() + self.carousel.scroll_to(self.window.summary_screen, True) + else: + self.carousel.scroll_to(self.next_page, True) + + def carousel_next_summary(self): + self.next_page.move_to_summary=True + self.carousel.scroll_to(self.next_page, True) + def search_timezones(self, *args): terms = self.timezone_entry_search.get_text() self.list_timezones.set_filter_func(self.filter_timezones, terms) diff --git a/src/functions/user_screen.py b/src/functions/user_screen.py index 692146d..530824f 100644 --- a/src/functions/user_screen.py +++ b/src/functions/user_screen.py @@ -33,6 +33,11 @@ class UserScreen(Adw.Bin): enable_root_switch = Gtk.Template.Child() next_page_button = Gtk.Template.Child() + username = "" + sudo_enabled = True + root_enabled = True + move_to_summary = False + def __init__(self, window, main_carousel, next_page, application, **kwargs): super().__init__(**kwargs) self.window = window @@ -60,6 +65,7 @@ class UserScreen(Adw.Bin): print("Valid username!") self.username_entry.remove_css_class('error') self.next_page.set_sensitive(True) + self.username = input def enable_root_user(self, widget, switch_state): print("root") @@ -94,4 +100,12 @@ class UserScreen(Adw.Bin): self.password_confirmation.add_css_class('error') def carousel_next(self, widget): + if self.move_to_summary: + self.window.summary_screen.initialize() + self.carousel.scroll_to(self.window.summary_screen, True) + else: + self.carousel.scroll_to(self.next_page, True) + + def carousel_next_summary(self, widget): + self.next_page.move_to_summary=True self.carousel.scroll_to(self.next_page, True) diff --git a/src/pages/summary_screen.blp b/src/pages/summary_screen.blp index c1bd8c7..25c6f8a 100644 --- a/src/pages/summary_screen.blp +++ b/src/pages/summary_screen.blp @@ -17,17 +17,11 @@ template SummaryScreen : Adw.Bin { Adw.PreferencesGroup { title: "Timezone and Locale"; Gtk.ListBox timezone_listbox { + selection-mode: none; Adw.ActionRow timezone_label { title: "region/location"; - Gtk.Button { - valign: center; - halign: center; - icon-name: "document-edit-symbolic"; - } - } - Adw.ActionRow locale_label { - title: "locale"; - Gtk.Button { + subtitle: "locale"; + Gtk.Button timezone_button { valign: center; halign: center; icon-name: "document-edit-symbolic"; @@ -39,10 +33,11 @@ template SummaryScreen : Adw.Bin { Adw.PreferencesGroup { title: "Keyboard Layout"; Gtk.ListBox keyboard_listbox { + selection-mode: none; Adw.ActionRow keyboard_label { title: "layout"; subtitle: "keymap"; - Gtk.Button { + Gtk.Button keyboard_button { valign: center; halign: center; icon-name: "document-edit-symbolic"; @@ -54,9 +49,10 @@ template SummaryScreen : Adw.Bin { Adw.PreferencesGroup { title: "User Settings"; Gtk.ListBox user_listbox { + selection-mode: none; Adw.ActionRow username_label { title: "username"; - Gtk.Button { + Gtk.Button username_button { valign: center; halign: center; icon-name: "document-edit-symbolic"; @@ -64,7 +60,7 @@ template SummaryScreen : Adw.Bin { } Adw.ActionRow sudo_label { title: "sudo enabled/disabled"; - Gtk.Button { + Gtk.Button sudo_button { valign: center; halign: center; icon-name: "document-edit-symbolic"; @@ -72,7 +68,7 @@ template SummaryScreen : Adw.Bin { } Adw.ActionRow root_label { title: "root enabled/disabled"; - Gtk.Button { + Gtk.Button root_button { valign: center; halign: center; icon-name: "document-edit-symbolic"; @@ -82,19 +78,28 @@ template SummaryScreen : Adw.Bin { } } Adw.PreferencesGroup { - title: "Partition Settings"; - Gtk.ListBox partition_listbox { - Adw.ActionRow partition_label { - title: "selected install partition"; - Gtk.Button { + title: "Desktop"; + Gtk.ListBox desktop_listbox { + selection-mode: none; + Adw.ActionRow desktop_label { + title: "desktop"; + Gtk.Button desktop_button { valign: center; halign: center; icon-name: "document-edit-symbolic"; } } - Adw.ActionRow disksize_label { - title: "size of disk"; - Gtk.Button { + styles ["boxed-list"] + } + } + Adw.PreferencesGroup { + title: "Partition Settings"; + Gtk.ListBox partition_listbox { + selection-mode: none; + Adw.ActionRow partition_label { + title: "selected install partition"; + subtitle: "Disk size"; + Gtk.Button partition_button { valign: center; halign: center; icon-name: "document-edit-symbolic"; @@ -102,11 +107,6 @@ template SummaryScreen : Adw.Bin { } Adw.ActionRow uefi_label { title: "legacy bios/uefi"; - Gtk.Button { - valign: center; - halign: center; - icon-name: "document-edit-symbolic"; - } } styles ["boxed-list"] } @@ -114,9 +114,10 @@ template SummaryScreen : Adw.Bin { Adw.PreferencesGroup { title: "Miscellaneous Settings"; Gtk.ListBox misc_listbox { + selection-mode: none; Adw.ActionRow ipv_label { title: "ipv6 enabled/disabled"; - Gtk.Button { + Gtk.Button ipv_button { valign: center; halign: center; icon-name: "document-edit-symbolic"; @@ -124,7 +125,7 @@ template SummaryScreen : Adw.Bin { } Adw.ActionRow timeshift_label { title: "timeshift enabled/disabled"; - Gtk.Button { + Gtk.Button timeshift_button { valign: center; halign: center; icon-name: "document-edit-symbolic"; @@ -132,20 +133,20 @@ template SummaryScreen : Adw.Bin { } Adw.ActionRow theme_label { title: "crystal theming enaled/disabled"; - Gtk.Button { + Gtk.Button theme_button { valign: center; halign: center; icon-name: "document-edit-symbolic"; } } - Adw.ActionRow unakite_label { + /*Adw.ActionRow unakite_label { title: "unakite enaled/disabled"; Gtk.Button { valign: center; halign: center; icon-name: "document-edit-symbolic"; } - } + }*/ styles ["boxed-list"] } } diff --git a/src/scripts/checkEFI.sh b/src/scripts/checkEFI.sh new file mode 100644 index 0000000..413c450 --- /dev/null +++ b/src/scripts/checkEFI.sh @@ -0,0 +1,3 @@ + +#!/usr/bin/bash +flatpak-spawn --host [ -d /sys/firmware/efi ] && echo UEFI || echo BIOS \ No newline at end of file diff --git a/src/scripts/meson.build b/src/scripts/meson.build index e6ad6ca..741e828 100644 --- a/src/scripts/meson.build +++ b/src/scripts/meson.build @@ -4,5 +4,6 @@ scriptsdir = join_paths(pkgdatadir, 'jade_gui/scripts') jade_gui_sources = [ 'getDisks.sh', 'getDiskSize.sh', + 'checkEFI.sh', ] install_data(jade_gui_sources, install_dir: scriptsdir) \ No newline at end of file diff --git a/src/utils/disks.py b/src/utils/disks.py index 861a2c7..a98a0c6 100644 --- a/src/utils/disks.py +++ b/src/utils/disks.py @@ -28,3 +28,8 @@ def get_disk_size(disk: str): size=command.stdout.decode('utf-8').strip('\n') print(disk+":"+size) return str(math.floor(int(size)/1000**3))+" GB" + +def get_uefi(): + command=subprocess.run(["bash", "-c", "bash -- /app/share/jade_gui/jade_gui/scripts/checkEFI.sh"], capture_output=True) + isEfi=True if command.stdout.decode('utf-8').strip('\n') == "UEFI" else False + return isEfi diff --git a/src/widgets/disk.py b/src/widgets/disk.py index 462b3de..dc76b84 100644 --- a/src/widgets/disk.py +++ b/src/widgets/disk.py @@ -28,7 +28,8 @@ class DiskEntry(Adw.ActionRow): def __init__(self, window, disk, disk_size, button_group, application, **kwargs): super().__init__(**kwargs) - self.window = window + self.disk = disk + self.disk_size = disk self.set_title(disk) self.set_subtitle(disk_size) self.select_button.set_group(button_group) diff --git a/src/widgets/timezone.py b/src/widgets/timezone.py index de31906..71adea7 100644 --- a/src/widgets/timezone.py +++ b/src/widgets/timezone.py @@ -31,6 +31,10 @@ class TimezoneEntry(Adw.ActionRow): def __init__(self, window, region, location, locale, application, **kwargs): super().__init__(**kwargs) + self.region = region + self.location = location + self.locale = locale + self.set_title(region+"/"+location) self.time_label.set_text(self.calculate_time(location=location, region=region)) diff --git a/src/widgets/variant.py b/src/widgets/variant.py index bdcb78c..3aa85c7 100644 --- a/src/widgets/variant.py +++ b/src/widgets/variant.py @@ -27,6 +27,10 @@ class KeyboardVariant(Adw.ActionRow): def __init__(self, window, variant, country, country_shorthand, **kwargs): super().__init__(**kwargs) + self.variant = variant + self.country = country + self.country_shorthand = country_shorthand + self.set_title(variant) self.set_subtitle(country+" - "+country_shorthand) diff --git a/src/window.py b/src/window.py index db4f5da..c564994 100644 --- a/src/window.py +++ b/src/window.py @@ -74,31 +74,34 @@ class JadeGuiWindow(Gtk.ApplicationWindow): self.carousel.append(self.finished_screen) ### Widgets for first page (welcome screen) #self.quit_button.connect("clicked", self.confirmQuit) + #self.summary_screen.connect_buttons() self.next_button.connect("clicked", self.nextPage) ### --------- ### Test timezones for i in locations: for locale in i: - print(locale.region) - print(locale.location) - print(locale.locales) + # print(locale.region) + # print(locale.location) + # print(locale.locales) self.timezone_screen.list_timezones.append(TimezoneEntry(window=self, region=locale.region, location=locale.location, locale=locale.locales, **kwargs)) ### --------- ### Test layouts for keymap in keymaps: - print(keymap.layout) - print(keymap.backend_layout) + #print(keymap.layout) + #print(keymap.backend_layout) self.keyboard_screen.list_keyboard_layouts.append(KeyboardLayout(window=self, country=keymap.layout, country_shorthand=keymap.backend_layout, variants=keymap.variant, **kwargs)) ### --------- ### Test desktops onyx = DesktopEntry(window=self, desktop="Onyx", button_group=None, **kwargs) # Manually specifying onyx since the other entries need a button group to attach to self.desktop_screen.list_desktops.append(onyx) + self.desktop_screen.chosen_desktop = self.desktop_screen.list_desktops.get_row_at_index(0).get_title() + self.desktop_screen.list_desktops.select_row(onyx) for desktop in desktops: if desktop != "Onyx": - print(desktop) + #print(desktop) self.desktop_screen.list_desktops.append(DesktopEntry(window=self, desktop=desktop, button_group=onyx.select_button, **kwargs)) ### --------- @@ -106,11 +109,13 @@ class JadeGuiWindow(Gtk.ApplicationWindow): available_disks = disks.get_disks() firstdisk = DiskEntry(window=self, disk=available_disks[0], disk_size=disks.get_disk_size(available_disks[0]), button_group=None, **kwargs) self.partition_screen.partition_list.append(firstdisk) - print(available_disks[0]) - print(available_disks) + self.partition_screen.selected_partition = self.partition_screen.partition_list.get_row_at_index(0) + self.partition_screen.partition_list.select_row(firstdisk) + #print(available_disks[0]) + #print(available_disks) for disk in available_disks: if disk != available_disks[0]: - print(disk) + #print(disk) self.partition_screen.partition_list.append(DiskEntry(window=self, disk=disk, disk_size=disks.get_disk_size(disk), button_group=firstdisk.select_button, **kwargs)) ### ---------