Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archinstall/lib/menu/global_menu.py11
-rw-r--r--archinstall/lib/menu/selection_menu.py16
-rw-r--r--examples/guided.py9
3 files changed, 27 insertions, 9 deletions
diff --git a/archinstall/lib/menu/global_menu.py b/archinstall/lib/menu/global_menu.py
index fba0ce29..0c7c1c20 100644
--- a/archinstall/lib/menu/global_menu.py
+++ b/archinstall/lib/menu/global_menu.py
@@ -43,8 +43,7 @@ class GlobalMenu(GeneralMenu):
Selector(
_('Select Archinstall language'),
lambda x: self._select_archinstall_language('English'),
- default='English',
- enabled=True)
+ default='English')
self._menu_options['keyboard-layout'] = \
Selector(_('Select keyboard layout'), lambda preset: select_language('us',preset), default='us')
self._menu_options['mirror-region'] = \
@@ -153,24 +152,20 @@ class GlobalMenu(GeneralMenu):
lambda preset: self._select_ntp(preset),
default=True)
self._menu_options['__separator__'] = \
- Selector(
- '',
- enabled=True)
+ Selector('')
self._menu_options['save_config'] = \
Selector(
_('Save configuration'),
lambda preset: save_config(self._data_store),
- enabled=True,
no_store=True)
self._menu_options['install'] = \
Selector(
self._install_text(),
exec_func=lambda n,v: True if len(self._missing_configs()) == 0 else False,
preview_func=self._prev_install_missing_config,
- enabled=True,
no_store=True)
- self._menu_options['abort'] = Selector(_('Abort'), exec_func=lambda n,v:exit(1), enabled=True)
+ self._menu_options['abort'] = Selector(_('Abort'), exec_func=lambda n,v:exit(1))
def _update_install_text(self, name :str = None, result :Any = None):
text = self._install_text()
diff --git a/archinstall/lib/menu/selection_menu.py b/archinstall/lib/menu/selection_menu.py
index ca48fda2..37e54685 100644
--- a/archinstall/lib/menu/selection_menu.py
+++ b/archinstall/lib/menu/selection_menu.py
@@ -181,6 +181,7 @@ class GeneralMenu:
;type preview_size: float (range 0..1)
"""
+ self._enabled_order = []
self._translation = Translation.load_nationalization()
self.is_context_mgr = False
self._data_store = data_store if data_store is not None else {}
@@ -239,10 +240,15 @@ class GeneralMenu:
if arg is not None:
self._menu_options[selector_name].set_current_selection(arg)
+ def _update_enabled_order(self, selector_name: str):
+ self._enabled_order.append(selector_name)
+
def enable(self, selector_name :str, omit_if_set :bool = False , mandatory :bool = False):
""" activates menu options """
if self._menu_options.get(selector_name, None):
self._menu_options[selector_name].set_enabled(True)
+ self._update_enabled_order(selector_name)
+
if mandatory:
self._menu_options[selector_name].set_mandatory(True)
self.synch(selector_name,omit_if_set)
@@ -372,7 +378,15 @@ class GeneralMenu:
if self._verify_selection_enabled(name):
enabled_menus[name] = selection
- return enabled_menus
+ # sort the enabled menu by the order we enabled them in
+ # we'll add the entries that have been enabled via the selector constructor at the top
+ enabled_keys = [i for i in enabled_menus.keys() if i not in self._enabled_order]
+ # and then we add the ones explicitly enabled by the enable function
+ enabled_keys += [i for i in self._enabled_order if i in enabled_menus.keys()]
+
+ ordered_menus = {k: enabled_menus[k] for k in enabled_keys}
+
+ return ordered_menus
def option(self,name :str) -> Selector:
# TODO check inexistent name
diff --git a/examples/guided.py b/examples/guided.py
index 56e05ef9..8e6acc64 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -39,6 +39,9 @@ def ask_user_questions():
archinstall.SysCommand('timedatectl set-ntp true')
global_menu = archinstall.GlobalMenu(data_store=archinstall.arguments)
+
+ global_menu.enable('archinstall-language')
+
global_menu.enable('keyboard-layout')
# Set which region to download packages from during the installation
@@ -91,6 +94,12 @@ def ask_user_questions():
global_menu.enable('additional-repositories')
+ global_menu.enable('__separator__')
+
+ global_menu.enable('save_config')
+ global_menu.enable('install')
+ global_menu.enable('abort')
+
global_menu.run()