Skip to content

Commit

Permalink
implement deltas to improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
muhdsalm authored and taukakao committed Aug 1, 2024
1 parent 1ac4d55 commit 62c79b5
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 9 deletions.
1 change: 1 addition & 0 deletions vanilla_installer/defaults/conn_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(self, window, distro_info, key, step, **kwargs):
self.__key = key
self.__step = step
self.__step_num = step["num"]
self.delta = False

self.__ignore_callback = False

Expand Down
1 change: 1 addition & 0 deletions vanilla_installer/defaults/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ def __init__(self, window, distro_info, key, step, **kwargs):
self.__distro_info = distro_info
self.__key = key
self.__step = step
self.delta = False
self.__registry_disks = []
self.__selected_disks = []
self.__disks = DisksManager()
Expand Down
1 change: 1 addition & 0 deletions vanilla_installer/defaults/encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, window, distro_info, key, step, **kwargs):
self.__distro_info = distro_info
self.__key = key
self.__step = step
self.delta = False

self.btn_next.connect("clicked", self.__window.next)
self.use_encryption_switch.connect(
Expand Down
1 change: 1 addition & 0 deletions vanilla_installer/defaults/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, window, distro_info, key, step, **kwargs):
self.__distro_info = distro_info
self.__key = key
self.__step = step
self.delta = False

self.btn_next.connect("clicked", self.__window.next)
self.image_url_entry.connect(
Expand Down
12 changes: 10 additions & 2 deletions vanilla_installer/defaults/keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@ def __init__(self, window, distro_info, key, step, **kwargs):
self.__distro_info = distro_info
self.__key = key
self.__step = step
self.delta = True
self.__keymaps = KeyMaps()

self.__keyboard_rows = self.__generate_keyboard_list_widgets(
self.selected_keyboard
)


def gen_deltas(self):
for i, widget in enumerate(self.__keyboard_rows):
self.all_keyboards_group.append(widget)

Expand All @@ -103,6 +106,11 @@ def __init__(self, window, distro_info, key, step, **kwargs):
if "VANILLA_NO_APPLY_XKB" not in os.environ:
self.test_focus_controller.connect("enter", self.__apply_layout)


def del_deltas(self):
self.all_keyboards_group.remove_all()


def __keyboard_verify(self, *args):
if self.selected_keyboard != []:
self.btn_next.set_sensitive(True)
Expand Down Expand Up @@ -192,7 +200,7 @@ def __set_keyboard_layout(self, selected_keyboard):
self.__create_keyboard_layout_array(selected_keyboard)
),
)

def __create_keyboard_layout_array(self, selected_keyboard):
keyboard_layout_array = []
for i in selected_keyboard:
Expand Down
13 changes: 10 additions & 3 deletions vanilla_installer/defaults/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ def __init__(self, window, distro_info, key, step, **kwargs):
self.__key = key
self.__step = step
self.__language_rows = []

self.delta = True
self.__generate_language_list_widgets()
for widget in self.__language_rows:
self.all_languages_group.append(widget)

# signals
self.btn_next.connect("clicked", self.__window.next)
Expand All @@ -77,6 +75,15 @@ def __init__(self, window, distro_info, key, step, **kwargs):
self.search_controller.connect("key-released", self.__on_search_key_pressed)
self.entry_search_language.add_controller(self.search_controller)


def gen_deltas(self):
for widget in self.__language_rows:
self.all_languages_group.append(widget)


def del_deltas(self):
self.all_languages_group.remove_all()

def __language_verify(self, *args):
if self.selected_language["language_subtitle"] is not None:
self.btn_next.set_sensitive(True)
Expand Down
1 change: 1 addition & 0 deletions vanilla_installer/defaults/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def __init__(self, window, distro_info, key, step, **kwargs):
self.__step = step
self.__nm_client = NM.Client.new()
self.__step_num = step["num"]
self.delta = False

self.__devices = []
self.__wired_children = []
Expand Down
1 change: 1 addition & 0 deletions vanilla_installer/defaults/nvidia.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(self, window, distro_info, key, step, **kwargs):
self.__distro_info = distro_info
self.__key = key
self.__step = step
self.delta = False

self.btn_yes.connect("clicked", self.use_proprietary_drivers)
self.btn_no.connect("clicked", self.use_open_drivers)
Expand Down
1 change: 1 addition & 0 deletions vanilla_installer/defaults/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, window, distro_info, key, step, **kwargs):
self.__distro_info = distro_info
self.__key = key
self.__step = step
self.delta = False

self.__build_ui()

Expand Down
19 changes: 15 additions & 4 deletions vanilla_installer/defaults/timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ def __init__(self, window, distro_info, key, step, **kwargs):
self.__key = key
self.__step = step
self.__step_num = step["num"]

self.__expanders = []
self.__tz_entries = []
self.__generate_timezone_list_widgets()
self.delta = True

# signals
self.btn_next.connect("clicked", self.__window.next)
Expand All @@ -98,6 +95,20 @@ def __init__(self, window, distro_info, key, step, **kwargs):
self.search_controller.connect("key-released", self.__on_search_key_pressed)
self.entry_search_timezone.add_controller(self.search_controller)


def gen_deltas(self):
self.__expanders = []
self.__tz_entries = []
self.__generate_timezone_list_widgets()


def del_deltas(self):
self.__tz_entries = []
for i in self.__expanders:
self.all_timezones_group.remove(i)
self.__expanders = []


def timezone_verify(self, carousel=None, idx=None):
if idx is not None and idx != self.__step_num:
return
Expand Down
1 change: 1 addition & 0 deletions vanilla_installer/defaults/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(self, window, distro_info, key, step, **kwargs):
self.__distro_info = distro_info
self.__key = key
self.__step = step
self.delta = False

self.btn_yes.connect("clicked", self.use_vm_tools_fn)
self.btn_no.connect("clicked", self.skip_vm_tools_fn)
Expand Down
1 change: 1 addition & 0 deletions vanilla_installer/defaults/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(self, window, distro_info, key, step, **kwargs):
self.__distro_info = distro_info
self.__key = key
self.__step = step
self.delta = False

distro_name = self.__distro_info.get("name", "Vanilla OS")
distro_logo = self.__distro_info.get("logo", "org.vanillaos.Installer-flower")
Expand Down
1 change: 1 addition & 0 deletions vanilla_installer/views/confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class VanillaConfirm(Adw.Bin):

def __init__(self, window, **kwargs):
super().__init__(**kwargs)
self.delta = False

def update(self, finals):
try:
Expand Down
1 change: 1 addition & 0 deletions vanilla_installer/views/done.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, window, **kwargs):
super().__init__(**kwargs)
self.__window = window
self.__log = None
self.delta = False

self.status_page.set_description(
_("Restart your device to enjoy your {} experience.").format(
Expand Down
1 change: 1 addition & 0 deletions vanilla_installer/views/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(self, window, tour: dict, **kwargs):
self.__font.set_weight(Pango.Weight.NORMAL)
self.__font.set_stretch(Pango.Stretch.NORMAL)
self.style_manager = Adw.StyleManager().get_default()
self.delta = False

self.__build_ui()
self.__on_setup_terminal_colors()
Expand Down
12 changes: 12 additions & 0 deletions vanilla_installer/windows/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ def next(self, widget=None, fn=None, *args):
logger.info("Going to next page")

cur_index = self.carousel.get_position()
page = self.carousel.get_nth_page(cur_index)
if page.delta:
logger.info(f"Removing deltas of page {int(cur_index)}")
page.del_deltas()
logger.info(f"Next page is {int(cur_index + 1)}")

if fn is not None:
Expand All @@ -154,15 +158,23 @@ def next(self, widget=None, fn=None, *args):

page = self.carousel.get_nth_page(cur_index + 1)
self.carousel.scroll_to(page, True)
if page.delta:
logger.info(f"Generating deltas of page {int(cur_index + 1)}")
page.gen_deltas()

def back(self, *args):
logger.info("Going to previous page")

cur_index = self.carousel.get_position()
page = self.carousel.get_nth_page(cur_index)
if page.delta:
page.del_deltas()
logger.info(f"Previous page is {int(cur_index - 1)}")

page = self.carousel.get_nth_page(cur_index - 1)
self.carousel.scroll_to(page, True)
if page.delta:
page.gen_deltas()

def toast(self, message, timeout=3):
toast = Adw.Toast.new(message)
Expand Down

0 comments on commit 62c79b5

Please sign in to comment.