feat(installer): step-by-step wizard with next/back navigation
Anaconda is a hub & spoke installer: a MENU where the user picks which screen to enter, in any order. That assumes you already know what you are doing -- the opposite of what FWS is for. The Summary hub no longer shows its grid of tiles; it chains its screens one by one, like the Windows installer: Language -> Internet -> Date & time -> Destination -> Desktop -> User -> Root password -> Summary -> Installation Consequences addressed here: - The desktop default was "command line only", on a screen that was neither mandatory nor visited by most users: the installation SUCCEEDED but left a console-only system -- a black screen on reboot, experienced as "the OS does not install". The screen is now part of the flow and defaults to KDE Plasma. - Navigation was inconsistent: hub screens carried a single "Done" button in the TOP LEFT while standalone screens have their buttons at the bottom right. That button is moved into a bottom-right bar identical to the standalone one, renamed "Suivant", and joined by a "Précédent" button. - Going back works from the last screen all the way to the first, including out of the hub, so a wrong language -- hence a wrong keyboard layout -- is no longer final. Leaving the hub and coming back would normally rebuild a fresh hub and lose every entry, so the hub instance is cached and reused. - Going back applies nothing: the Destination screen's apply() reconfigures partitioning. - Screens now slide horizontally, right to left going forward. - The keyboard chosen on the first screen is applied to the running X server with setxkbmap. Anaconda 45 only pushes it to systemd-localed, which expects a compositor to listen -- there is none under the live session's Openbox/Xorg, so the whole installer stayed in QWERTY US and Wi-Fi and account passwords were typed blind. The redundant screens (second keyboard choice, Anaconda's own network screen, language support) are removed through Anaconda's supported "hidden_spokes" option rather than by patching it. Everything is behind try/except: should any of it fail, the classic hub comes back and the installation stays possible. Signed-off-by: nocode <suzuku295@gmail.com>
This commit is contained in:
1 parent
557470ed60
commit
59bc828f9d
8 files changed
+706
-4
No files matched your search
@@ -0,0 +1,24 @@
|
|||||||
|
# FWS — écrans d'Anaconda retirés du parcours d'installation.
|
||||||
|
#
|
||||||
|
# « hidden_spokes » est le mécanisme PRÉVU par Anaconda pour masquer un écran
|
||||||
|
# (pyanaconda/ui/common.py, collect_spokes) : le spoke n'est ni instancié ni
|
||||||
|
# affiché. Aucun patch du paquet anaconda n'est nécessaire, et les fichiers de
|
||||||
|
# /etc/anaconda/conf.d/ sont lus APRÈS le profil produit → ils gagnent.
|
||||||
|
#
|
||||||
|
# KeyboardSpoke : le 2e choix de clavier (« dispositions supplémentaires »).
|
||||||
|
# La disposition est déjà fixée par la langue/région choisie
|
||||||
|
# au TOUT PREMIER écran, et appliquée immédiatement au live
|
||||||
|
# (cf. fws_wizard.py) → ce second écran ne fait que semer le
|
||||||
|
# doute. Retiré à la demande.
|
||||||
|
# NetworkSpoke : doublon de l'écran « Connexion à Internet » de FWS
|
||||||
|
# (fws_network.py, 2e étape). L'écran d'Anaconda est celui
|
||||||
|
# qui avait été jugé illisible — dans un parcours linéaire il
|
||||||
|
# serait IMPOSÉ à l'utilisateur.
|
||||||
|
# LangsupportSpoke: « prise en charge des langues » = paquets de langue à
|
||||||
|
# installer. Sans effet ici : le payload LiveOS recopie une
|
||||||
|
# image, il n'installe aucun paquet.
|
||||||
|
[User Interface]
|
||||||
|
hidden_spokes =
|
||||||
|
KeyboardSpoke
|
||||||
|
NetworkSpoke
|
||||||
|
LangsupportSpoke
|
||||||
+10
-2
@@ -49,9 +49,16 @@ class FWSDesktopSpoke(NormalSpoke):
|
|||||||
"""Identifiant unique de cet écran."""
|
"""Identifiant unique de cet écran."""
|
||||||
return "fws-desktop-selection"
|
return "fws-desktop-selection"
|
||||||
|
|
||||||
|
# Défaut = KDE Plasma, PAS « cli ». Avec « cli » pré-coché, tout
|
||||||
|
# utilisateur qui validait cet écran sans y toucher (ou, dans l'ancien menu,
|
||||||
|
# qui n'ouvrait jamais la tuile) obtenait une install RÉUSSIE mais sans
|
||||||
|
# aucun bureau : console noire au redémarrage, vécu comme « l'OS ne
|
||||||
|
# s'installe pas ». FWS remplace Windows → le défaut doit être un bureau.
|
||||||
|
_DEFAULT_CHOICE = "kde"
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
NormalSpoke.__init__(self, *args)
|
NormalSpoke.__init__(self, *args)
|
||||||
self._choice = "cli"
|
self._choice = self._DEFAULT_CHOICE
|
||||||
self._radios = {}
|
self._radios = {}
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
@@ -69,7 +76,8 @@ class FWSDesktopSpoke(NormalSpoke):
|
|||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
# Coche le bouton correspondant au choix courant.
|
# Coche le bouton correspondant au choix courant.
|
||||||
rb = self._radios.get(self._choice) or self._radios.get("cli")
|
rb = (self._radios.get(self._choice)
|
||||||
|
or self._radios.get(self._DEFAULT_CHOICE))
|
||||||
if rb is not None:
|
if rb is not None:
|
||||||
rb.set_active(True)
|
rb.set_active(True)
|
||||||
|
|
||||||
|
|||||||
+13
@@ -147,6 +147,19 @@ class FWSNetworkStandaloneSpoke(StandaloneSpoke):
|
|||||||
# apply() AVANT la transition (marqueur Wi-Fi vers la cible).
|
# apply() AVANT la transition (marqueur Wi-Fi vers la cible).
|
||||||
self.window.connect("continue-clicked", self._on_continue_clicked)
|
self.window.connect("continue-clicked", self._on_continue_clicked)
|
||||||
|
|
||||||
|
# « Précédent » → retour à l'écran de langue. Sans lui, une langue (donc
|
||||||
|
# une disposition clavier) mal choisie au 1er écran est DÉFINITIVE :
|
||||||
|
# la file d'actions du GUI est à sens unique. Le mécanisme de retour vit
|
||||||
|
# dans fws_wizard (il a déjà la main sur les internes du GUI) ; ici on ne
|
||||||
|
# fait que poser le bouton. Rien n'est appliqué en reculant — la
|
||||||
|
# connexion Wi-Fi est déjà établie par NetworkManager et son marqueur
|
||||||
|
# posé par _connect_done, donc rien à perdre.
|
||||||
|
try:
|
||||||
|
from pyanaconda.ui.gui.spokes.fws_wizard import add_back_button
|
||||||
|
add_back_button(self, "WelcomeLanguageSpoke")
|
||||||
|
except Exception: # pylint: disable=broad-except
|
||||||
|
log.exception("FWS: bouton « Précédent » non ajouté à l'écran réseau.")
|
||||||
|
|
||||||
def _on_continue_clicked(self, *_args):
|
def _on_continue_clicked(self, *_args):
|
||||||
self.apply()
|
self.apply()
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -305,7 +305,9 @@ class FWSRecapSpoke(StandaloneSpoke):
|
|||||||
self._back_button = Gtk.Button.new_with_mnemonic("_Précédent")
|
self._back_button = Gtk.Button.new_with_mnemonic("_Précédent")
|
||||||
self._back_button.connect("clicked", self._on_back_clicked)
|
self._back_button.connect("clicked", self._on_back_clicked)
|
||||||
button_box.add(self._back_button)
|
button_box.add(self._back_button)
|
||||||
button_box.reorder_child(self._back_button, 0)
|
# [Quitter, Lancer l'installation, Précédent] -> Précédent au MILIEU,
|
||||||
|
# même disposition que sur les autres écrans de l'assistant.
|
||||||
|
button_box.reorder_child(self._back_button, 1)
|
||||||
if self._gui is None or self._hub is None:
|
if self._gui is None or self._hub is None:
|
||||||
# Références introuvables (flux inattendu) : bouton grisé plutôt
|
# Références introuvables (flux inattendu) : bouton grisé plutôt
|
||||||
# qu'une navigation cassée — l'install reste possible.
|
# qu'une navigation cassée — l'install reste possible.
|
||||||
|
|||||||
+647
@@ -0,0 +1,647 @@
|
|||||||
|
# FWS — Installation « pas à pas » (façon Windows) au lieu du menu d'Anaconda.
|
||||||
|
#
|
||||||
|
# CE QUE ÇA CHANGE
|
||||||
|
# ----------------
|
||||||
|
# Anaconda est un installateur « hub & spoke » : un MENU (le hub Résumé) où
|
||||||
|
# l'utilisateur choisit lui-même dans quel écran entrer, dans l'ordre qu'il veut,
|
||||||
|
# puis clique « Commencer l'installation ». Ce modèle suppose qu'on sait déjà ce
|
||||||
|
# qu'on fait — l'inverse de ce que vise FWS. Ici le hub n'affiche plus sa grille
|
||||||
|
# de tuiles : il ENCHAÎNE ses écrans un par un, comme l'installateur de Windows.
|
||||||
|
#
|
||||||
|
# Langue → Connexion à Internet → Date et heure → Destination →
|
||||||
|
# Bureau → Compte utilisateur → Mot de passe administrateur →
|
||||||
|
# Récapitulatif → Installation
|
||||||
|
#
|
||||||
|
# (Les deux premiers et les deux derniers écrans sont déjà des « standalone
|
||||||
|
# spokes » — welcome.py, fws_network.py, fws_recap.py, installation_progress —
|
||||||
|
# donc déjà linéaires. Ce module s'occupe du bloc du milieu, celui du hub.)
|
||||||
|
#
|
||||||
|
# Les écrans retirés du parcours (2e choix de clavier, réseau d'Anaconda,
|
||||||
|
# support des langues) ne sont PAS gérés ici : ils le sont par le mécanisme
|
||||||
|
# officiel « hidden_spokes » dans /etc/anaconda/conf.d/10-fws-ui.conf.
|
||||||
|
#
|
||||||
|
# CLAVIER APPLIQUÉ TOUT DE SUITE
|
||||||
|
# ------------------------------
|
||||||
|
# La disposition choisie au 1er écran n'était appliquée qu'au système INSTALLÉ :
|
||||||
|
# Anaconda 45 la pousse à systemd-localed, qui se contente d'écrire la config et
|
||||||
|
# de prévenir le compositeur (gnome-kiosk chez Fedora). FWS lance l'installateur
|
||||||
|
# sous Openbox/Xorg : personne n'écoute → tout l'installateur restait en QWERTY
|
||||||
|
# US et le mot de passe Wi-Fi ou le mot de passe du compte se tapaient à
|
||||||
|
# l'aveugle. On applique donc la disposition au serveur X en cours avec
|
||||||
|
# setxkbmap, dès que l'utilisateur valide le 1er écran.
|
||||||
|
#
|
||||||
|
# POURQUOI DES PATCHS À CHAUD (et pas un patch du paquet anaconda)
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
# Anaconda importe TOUS les .py de ce dossier au démarrage (util.collect) pour
|
||||||
|
# découvrir les spokes. Déposer ce fichier via l'overlay airootfs suffit donc à
|
||||||
|
# exécuter ce code — AUCUN rebuild du paquet anaconda (même principe que
|
||||||
|
# fws_desktop.py / fws_network.py / fws_recap.py). Le hub, lui, n'est pas
|
||||||
|
# « collecté » : GraphicalUserInterface._list_hubs() renvoie la classe SummaryHub
|
||||||
|
# en dur, AVANT la collecte des spokes. On ne peut donc pas la remplacer, mais on
|
||||||
|
# peut la modifier : quand ce module est importé, la classe existe déjà et
|
||||||
|
# aucune INSTANCE n'a encore été créée. C'est exactement la fenêtre utilisée ici.
|
||||||
|
#
|
||||||
|
# __all__ = [] : util.collect() respecte __all__ — ce module n'expose donc aucun
|
||||||
|
# écran (sans quoi les classes importées ici seraient prises pour des spokes et
|
||||||
|
# ajoutées au parcours en double).
|
||||||
|
#
|
||||||
|
# ⚠ S'appuie sur les internes du GUI d'anaconda 45.8 (comme fws_recap.py) : à
|
||||||
|
# revérifier à chaque montée de version d'anaconda. Tout est sous try/except —
|
||||||
|
# en cas d'échec, on retombe sur le hub classique, l'installation reste possible.
|
||||||
|
# ⚠ Chemin couplé à la version de Python d'Arch (3.14), comme les autres spokes.
|
||||||
|
|
||||||
|
import gi
|
||||||
|
|
||||||
|
gi.require_version("Gtk", "3.0")
|
||||||
|
from gi.repository import Gtk
|
||||||
|
|
||||||
|
from pyanaconda.anaconda_loggers import get_module_logger
|
||||||
|
|
||||||
|
log = get_module_logger(__name__)
|
||||||
|
|
||||||
|
__all__ = []
|
||||||
|
|
||||||
|
# Ordre des écrans du hub dans l'assistant, par nom de classe. Un spoke absent
|
||||||
|
# de cette liste (extension, addon) est simplement placé à la fin : il reste
|
||||||
|
# atteignable, l'assistant ne perd jamais un écran.
|
||||||
|
_WIZARD_ORDER = (
|
||||||
|
"DatetimeSpoke", # Date et heure
|
||||||
|
"StorageSpoke", # Destination de l'installation (disque)
|
||||||
|
"FWSDesktopSpoke", # Bureau FWS
|
||||||
|
"UserSpoke", # Compte utilisateur + nom de machine
|
||||||
|
"PasswordSpoke", # Mot de passe administrateur (root)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Le bouton du coin haut-gauche des écrans d'Anaconda s'appelle « Terminé » :
|
||||||
|
# dans un assistant, c'est le bouton « suivant ».
|
||||||
|
_NEXT_LABEL = "_Suivant"
|
||||||
|
_BACK_LABEL = "_Précédent"
|
||||||
|
_DONE_BUTTON_NAME = "anaconda-spoke-window-done"
|
||||||
|
|
||||||
|
_WAIT_MSG = "Analyse du matériel en cours, l'écran suivant s'ouvre tout seul…"
|
||||||
|
|
||||||
|
# Écran standalone situé JUSTE AVANT le bloc du hub : c'est là que « Précédent »
|
||||||
|
# doit mener depuis la première étape de l'assistant. De là, son propre bouton
|
||||||
|
# « Précédent » ramène à l'écran de langue — donc au choix du clavier, qui en
|
||||||
|
# découle. La chaîne de retour est ainsi complète du dernier écran au premier.
|
||||||
|
_PREVIOUS_STANDALONE = "FWSNetworkStandaloneSpoke"
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Clavier : appliquer au X du live la disposition déduite de la langue
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
def _apply_live_keyboard():
|
||||||
|
"""Pousse la disposition clavier choisie dans le serveur X de l'installateur."""
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from pyanaconda.modules.common.constants.services import LOCALIZATION
|
||||||
|
|
||||||
|
proxy = LOCALIZATION.get_proxy()
|
||||||
|
|
||||||
|
# SetXKeyboardDefaults() calcule la disposition à partir de la locale (patch
|
||||||
|
# FWS du paquet anaconda : fr_CH → ch(fr) et non fr(oss)). C'était le spoke
|
||||||
|
# Clavier qui l'appelait ; il est masqué chez nous, donc plus personne ne le
|
||||||
|
# faisait → XLayouts vide, et /root/anaconda-ks.cfg sans « --xlayouts= »
|
||||||
|
# pour le %post du kickstart.
|
||||||
|
try:
|
||||||
|
proxy.SetXKeyboardDefaults()
|
||||||
|
except Exception: # pylint: disable=broad-except
|
||||||
|
log.debug("FWS: SetXKeyboardDefaults indisponible", exc_info=True)
|
||||||
|
|
||||||
|
layouts = list(proxy.XLayouts or [])
|
||||||
|
if not layouts:
|
||||||
|
log.debug("FWS: aucune disposition clavier à appliquer.")
|
||||||
|
return
|
||||||
|
|
||||||
|
from pyanaconda.keyboard import parse_layout_variant
|
||||||
|
|
||||||
|
pairs = []
|
||||||
|
for layout_variant in layouts:
|
||||||
|
try:
|
||||||
|
pairs.append(parse_layout_variant(layout_variant))
|
||||||
|
except Exception: # pylint: disable=broad-except
|
||||||
|
continue
|
||||||
|
if not pairs:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Pas de serveur X (mode texte, RDP…) : rien à faire, la config système
|
||||||
|
# écrite par localed suffit alors.
|
||||||
|
if not os.environ.get("DISPLAY"):
|
||||||
|
return
|
||||||
|
|
||||||
|
setxkbmap = shutil.which("setxkbmap")
|
||||||
|
if not setxkbmap:
|
||||||
|
log.warning("FWS: setxkbmap absent — clavier du live laissé en l'état "
|
||||||
|
"(paquet xorg-setxkbmap manquant ?)")
|
||||||
|
return
|
||||||
|
|
||||||
|
cmd = [setxkbmap, "-model", "pc105",
|
||||||
|
"-layout", ",".join(layout for layout, _v in pairs),
|
||||||
|
"-variant", ",".join(variant for _l, variant in pairs)]
|
||||||
|
if len(pairs) > 1:
|
||||||
|
# Deux dispositions (la native + « us » quand elle ne fait pas d'ASCII) :
|
||||||
|
# même bascule que celle qu'Anaconda configure pour le système installé.
|
||||||
|
cmd += ["-option", "grp:alt_shift_toggle"]
|
||||||
|
|
||||||
|
rc = subprocess.run(cmd, check=False, capture_output=True,
|
||||||
|
timeout=15).returncode
|
||||||
|
log.info("FWS: clavier du live → %s (setxkbmap rc=%s)", layouts, rc)
|
||||||
|
|
||||||
|
|
||||||
|
def _hook_welcome_spoke():
|
||||||
|
"""Applique le clavier dès la validation du 1er écran (langue)."""
|
||||||
|
from pyanaconda.ui.gui.spokes import welcome as welcome_module
|
||||||
|
|
||||||
|
spoke_class = welcome_module.WelcomeLanguageSpoke
|
||||||
|
if getattr(spoke_class, "_fws_keyboard_hooked", False):
|
||||||
|
return
|
||||||
|
|
||||||
|
original_apply = spoke_class.apply
|
||||||
|
|
||||||
|
def apply(self):
|
||||||
|
original_apply(self)
|
||||||
|
try:
|
||||||
|
_apply_live_keyboard()
|
||||||
|
except Exception: # pylint: disable=broad-except
|
||||||
|
log.exception("FWS: application du clavier au live impossible.")
|
||||||
|
|
||||||
|
spoke_class.apply = apply
|
||||||
|
spoke_class._fws_keyboard_hooked = True
|
||||||
|
log.info("FWS: clavier du live branché sur l'écran de langue.")
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Assistant : le hub Résumé enchaîne ses écrans au lieu de les proposer
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
def _really_hide(widget):
|
||||||
|
try:
|
||||||
|
from pyanaconda.ui.gui.utils import really_hide
|
||||||
|
really_hide(widget)
|
||||||
|
except Exception: # pylint: disable=broad-except
|
||||||
|
widget.set_no_show_all(True)
|
||||||
|
widget.hide()
|
||||||
|
|
||||||
|
|
||||||
|
def _really_show(widget):
|
||||||
|
try:
|
||||||
|
from pyanaconda.ui.gui.utils import really_show
|
||||||
|
really_show(widget)
|
||||||
|
except Exception: # pylint: disable=broad-except
|
||||||
|
widget.set_no_show_all(False)
|
||||||
|
widget.show()
|
||||||
|
|
||||||
|
|
||||||
|
def _build_nav_bar(spoke, on_back):
|
||||||
|
"""Barre de navigation « Précédent / Suivant » en BAS À DROITE.
|
||||||
|
|
||||||
|
Les écrans « standalone » (Langue, Connexion, Récapitulatif) ont déjà leurs
|
||||||
|
boutons en bas à droite : AnacondaStandaloneWindow crée lui-même un
|
||||||
|
GtkButtonBox en layout END (spacing 12, marges 6) packé en fin de main_box.
|
||||||
|
Les écrans du hub, eux, n'ont qu'un bouton « Terminé » en HAUT À GAUCHE
|
||||||
|
(SpokeWindow.c l'attache dans la grille de navigation). D'un écran à l'autre
|
||||||
|
la navigation sautait donc d'un coin à l'autre de la fenêtre.
|
||||||
|
|
||||||
|
On reconstruit ici la MÊME barre que les écrans standalone, et on y
|
||||||
|
DÉMÉNAGE le bouton d'origine — le même objet, donc le même signal
|
||||||
|
« button-clicked » qui pilote spoke_done : on ne réimplémente pas la
|
||||||
|
validation, on la déplace.
|
||||||
|
"""
|
||||||
|
if getattr(spoke, "_fws_navbar", None) is not None:
|
||||||
|
return
|
||||||
|
|
||||||
|
window = spoke.window
|
||||||
|
|
||||||
|
done = None
|
||||||
|
for child in window.get_nav_area().get_children():
|
||||||
|
if child.get_name() == _DONE_BUTTON_NAME:
|
||||||
|
done = child
|
||||||
|
break
|
||||||
|
|
||||||
|
box = Gtk.ButtonBox(orientation=Gtk.Orientation.HORIZONTAL)
|
||||||
|
box.set_layout(Gtk.ButtonBoxStyle.END)
|
||||||
|
box.set_spacing(12)
|
||||||
|
box.set_margin_start(6)
|
||||||
|
box.set_margin_end(6)
|
||||||
|
box.set_margin_bottom(6)
|
||||||
|
|
||||||
|
back = Gtk.Button.new_with_mnemonic(_BACK_LABEL)
|
||||||
|
back.connect("clicked", lambda _button: on_back(spoke))
|
||||||
|
box.add(back)
|
||||||
|
|
||||||
|
if done is not None:
|
||||||
|
# La variable Python garde une référence forte : le retrait du GtkGrid
|
||||||
|
# ne peut donc pas détruire le bouton avant qu'on le rattache.
|
||||||
|
window.get_nav_area().remove(done)
|
||||||
|
done.set_use_underline(True)
|
||||||
|
done.set_label(_NEXT_LABEL)
|
||||||
|
box.add(done)
|
||||||
|
|
||||||
|
window.get_main_box().pack_start(box, False, True, 0)
|
||||||
|
box.show_all()
|
||||||
|
spoke._fws_navbar = box
|
||||||
|
spoke._fws_back_button = back
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Transitions : l'assistant glisse de DROITE À GAUCHE (retour : l'inverse)
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Anaconda anime selon la métaphore hub & spoke : on « descend » dans un écran
|
||||||
|
# (UNDER_UP) et on « remonte » au menu (OVER_DOWN). Dans un assistant linéaire
|
||||||
|
# ça n'a plus de sens — on veut le glissement horizontal des installateurs.
|
||||||
|
# MainWindow fixe le type de transition JUSTE avant de changer d'écran ; on
|
||||||
|
# réimplémente donc ces trois méthodes (2 lignes chacune) avec un type
|
||||||
|
# surchargeable par l'assistant.
|
||||||
|
_pending_transition = None
|
||||||
|
|
||||||
|
|
||||||
|
def _set_transition(kind):
|
||||||
|
"""Impose le type de la PROCHAINE transition ('next', 'back' ou 'none')."""
|
||||||
|
global _pending_transition # pylint: disable=global-statement
|
||||||
|
_pending_transition = kind
|
||||||
|
|
||||||
|
|
||||||
|
def _take_transition(default):
|
||||||
|
global _pending_transition # pylint: disable=global-statement
|
||||||
|
kind = _pending_transition or default
|
||||||
|
_pending_transition = None
|
||||||
|
return {
|
||||||
|
"next": Gtk.StackTransitionType.SLIDE_LEFT, # le nouvel écran arrive par la droite
|
||||||
|
"back": Gtk.StackTransitionType.SLIDE_RIGHT,
|
||||||
|
"none": Gtk.StackTransitionType.NONE,
|
||||||
|
}[kind]
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Retour arrière entre écrans « standalone » (Connexion → Langue)
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
# Les écrans standalone ne sont pas dans la file du hub : la file d'actions du
|
||||||
|
# GUI (_actions, une liste de CLASSES) est CONSOMMÉE à chaque écran, il n'y a
|
||||||
|
# donc aucun chemin de retour. Pour reculer il faut (a) retrouver l'INSTANCE de
|
||||||
|
# l'écran précédent — MainWindow la garde dans _stack_contents, tout écran déjà
|
||||||
|
# affiché reste dans la pile — et (b) réinsérer sa classe en tête de _actions
|
||||||
|
# pour que « Continuer » ré-enchaîne normalement. C'est le mécanisme déjà
|
||||||
|
# utilisé par le « Précédent » du récapitulatif, factorisé ici.
|
||||||
|
_gui = None # instance de GraphicalUserInterface, capturée à la volée
|
||||||
|
_hub_instances = {} # classe de hub -> instance réutilisée (cf. _patch_main_window)
|
||||||
|
|
||||||
|
|
||||||
|
def go_back_to_standalone(current, target_class_name):
|
||||||
|
"""Revient à un écran standalone DÉJÀ AFFICHÉ. True si la navigation a eu lieu."""
|
||||||
|
from pyanaconda.ui.gui import MainWindow
|
||||||
|
|
||||||
|
gui = _gui
|
||||||
|
if gui is None:
|
||||||
|
log.warning("FWS: interface introuvable, « Précédent » impossible.")
|
||||||
|
return False
|
||||||
|
|
||||||
|
main_window = MainWindow.get()
|
||||||
|
target = None
|
||||||
|
for obj in getattr(main_window, "_stack_contents", ()):
|
||||||
|
if type(obj).__name__ == target_class_name:
|
||||||
|
target = obj
|
||||||
|
break
|
||||||
|
if target is None:
|
||||||
|
log.warning("FWS: écran « %s » absent de la pile, « Précédent » impossible.",
|
||||||
|
target_class_name)
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Réinsère l'écran cible en tête de file : la file est en train de pointer
|
||||||
|
# sur l'écran COURANT (il n'est dépilé qu'au passage au suivant), donc
|
||||||
|
# insérer en 0 redonne exactement l'état d'avant.
|
||||||
|
if not gui._actions or gui._actions[0] is not type(target):
|
||||||
|
gui._actions.insert(0, type(target))
|
||||||
|
|
||||||
|
current.exited.emit(current)
|
||||||
|
target.refresh()
|
||||||
|
if hasattr(target.window, "set_may_continue"):
|
||||||
|
# Quitter un écran désarme son bouton « Continuer » : on le réarme,
|
||||||
|
# sinon l'écran de retour est un cul-de-sac.
|
||||||
|
target.window.set_may_continue(True)
|
||||||
|
_set_transition("back")
|
||||||
|
main_window.setCurrentAction(target)
|
||||||
|
target.entered.emit(target)
|
||||||
|
gui._currentAction = target
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def add_back_button(spoke, target_class_name):
|
||||||
|
"""Ajoute « Précédent » à la barre de boutons d'un écran standalone.
|
||||||
|
|
||||||
|
La barre existe déjà (AnacondaStandaloneWindow la crée avec Quitter et
|
||||||
|
Continuer) : on insère le bouton ENTRE les deux, pour que « Précédent » et
|
||||||
|
« Continuer » soient côte à côte comme sur les écrans de l'assistant.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
button_box = spoke.window.get_quit_button().get_parent()
|
||||||
|
except Exception: # pylint: disable=broad-except
|
||||||
|
log.warning("FWS: barre de boutons introuvable, « Précédent » non ajouté.")
|
||||||
|
return None
|
||||||
|
|
||||||
|
button = Gtk.Button.new_with_mnemonic(_BACK_LABEL)
|
||||||
|
button.connect("clicked",
|
||||||
|
lambda _b: go_back_to_standalone(spoke, target_class_name))
|
||||||
|
button_box.add(button)
|
||||||
|
# [Quitter, Continuer, Précédent] -> [Quitter, Précédent, Continuer]
|
||||||
|
button_box.reorder_child(button, 1)
|
||||||
|
button.show()
|
||||||
|
return button
|
||||||
|
|
||||||
|
|
||||||
|
def _patch_main_window():
|
||||||
|
from pyanaconda.ui.gui import GraphicalUserInterface, MainWindow
|
||||||
|
|
||||||
|
if getattr(MainWindow, "_fws_transitions_patched", False):
|
||||||
|
return
|
||||||
|
|
||||||
|
# Capture de l'interface : _instantiateAction est appelée pour CHAQUE écran,
|
||||||
|
# y compris le premier. Plus fiable que de remonter la pile d'appels.
|
||||||
|
#
|
||||||
|
# ET mise en cache du HUB. _on_continue_clicked recrée TOUJOURS l'écran
|
||||||
|
# suivant à partir de sa classe : sans cache, revenir du hub vers un écran
|
||||||
|
# standalone puis avancer reconstruirait un hub NEUF — donc tous les spokes
|
||||||
|
# ré-instanciés, un nouveau scan des disques, un Timer de plus dans
|
||||||
|
# Hub._hubs_collection et surtout les saisies de l'utilisateur perdues.
|
||||||
|
# On renvoie l'instance déjà connue : ses signaux sont déjà connectés (on
|
||||||
|
# NE repasse pas par l'original, donc pas de double connect_after), son
|
||||||
|
# refresh() la remet à jour, et l'assistant y retrouve son état.
|
||||||
|
from pyanaconda.ui.gui.hubs.summary import SummaryHub
|
||||||
|
|
||||||
|
original_instantiate = GraphicalUserInterface._instantiateAction
|
||||||
|
|
||||||
|
def _instantiateAction(self, actionClass): # noqa: N803 (nom imposé)
|
||||||
|
global _gui # pylint: disable=global-statement
|
||||||
|
_gui = self
|
||||||
|
cached = _hub_instances.get(actionClass)
|
||||||
|
if cached is not None:
|
||||||
|
return cached
|
||||||
|
action = original_instantiate(self, actionClass)
|
||||||
|
if action is not None and actionClass is SummaryHub:
|
||||||
|
_hub_instances[actionClass] = action
|
||||||
|
return action
|
||||||
|
|
||||||
|
GraphicalUserInterface._instantiateAction = _instantiateAction
|
||||||
|
|
||||||
|
def setCurrentAction(self, standalone): # noqa: N802 (nom imposé par anaconda)
|
||||||
|
self._stack.set_transition_type(_take_transition("next"))
|
||||||
|
self._current_action = standalone
|
||||||
|
self._setVisibleChild(standalone)
|
||||||
|
|
||||||
|
def enterSpoke(self, spoke): # noqa: N802
|
||||||
|
self._stack.set_transition_type(_take_transition("next"))
|
||||||
|
self._setVisibleChild(spoke)
|
||||||
|
|
||||||
|
def returnToHub(self): # noqa: N802
|
||||||
|
self._stack.set_transition_type(_take_transition("back"))
|
||||||
|
self._setVisibleChild(self._current_action)
|
||||||
|
|
||||||
|
MainWindow.setCurrentAction = setCurrentAction
|
||||||
|
MainWindow.enterSpoke = enterSpoke
|
||||||
|
MainWindow.returnToHub = returnToHub
|
||||||
|
MainWindow._fws_transitions_patched = True
|
||||||
|
log.info("FWS: transitions d'écran en glissement horizontal.")
|
||||||
|
|
||||||
|
|
||||||
|
def _install_wizard():
|
||||||
|
from pyanaconda.ui.gui.hubs.summary import SummaryHub
|
||||||
|
from pyanaconda.ui.gui.utils import gtk_call_once
|
||||||
|
|
||||||
|
if getattr(SummaryHub, "_fws_wizard_installed", False):
|
||||||
|
return
|
||||||
|
|
||||||
|
original_create_box = SummaryHub._createBox
|
||||||
|
original_refresh = SummaryHub.refresh
|
||||||
|
original_update_spokes = SummaryHub._update_spokes
|
||||||
|
|
||||||
|
def _wizard_steps(self):
|
||||||
|
"""Écrans du hub, dans l'ordre de l'assistant."""
|
||||||
|
steps = []
|
||||||
|
for spoke in self._spokes.values():
|
||||||
|
# Les spokes « indirects » (partitionnement manuel, blivet-gui) ne
|
||||||
|
# s'atteignent que depuis un autre écran, et un spoke insensible
|
||||||
|
# n'est pas utilisable : ni l'un ni l'autre n'est une étape.
|
||||||
|
if getattr(spoke, "indirect", False):
|
||||||
|
continue
|
||||||
|
if getattr(spoke, "selector", None) is None:
|
||||||
|
continue
|
||||||
|
if not getattr(spoke, "sensitive", True):
|
||||||
|
continue
|
||||||
|
steps.append(spoke)
|
||||||
|
|
||||||
|
def rank(spoke):
|
||||||
|
name = type(spoke).__name__
|
||||||
|
try:
|
||||||
|
return (_WIZARD_ORDER.index(name), name)
|
||||||
|
except ValueError:
|
||||||
|
return (len(_WIZARD_ORDER), name)
|
||||||
|
|
||||||
|
steps.sort(key=rank)
|
||||||
|
return steps
|
||||||
|
|
||||||
|
def _hide_menu(self):
|
||||||
|
"""Masque la grille de tuiles : l'assistant remplace le menu."""
|
||||||
|
for child in self.window.get_spoke_area().get_children():
|
||||||
|
_really_hide(child)
|
||||||
|
|
||||||
|
def _show_menu(self):
|
||||||
|
"""Filet de sécurité : rend le menu classique (cf. _finish)."""
|
||||||
|
for child in self.window.get_spoke_area().get_children():
|
||||||
|
_really_show(child)
|
||||||
|
|
||||||
|
def _createBox(self):
|
||||||
|
# refresh() est rejouée à chaque retour sur le hub (bouton « Précédent »
|
||||||
|
# du récapitulatif). Sans ce garde-fou, _createBox ré-instancierait TOUS
|
||||||
|
# les spokes et empilerait une seconde grille par-dessus la première.
|
||||||
|
if getattr(self, "_fws_box_built", False):
|
||||||
|
return
|
||||||
|
self._fws_box_built = True
|
||||||
|
original_create_box(self)
|
||||||
|
self._fws_hide_menu()
|
||||||
|
|
||||||
|
def refresh(self):
|
||||||
|
original_refresh(self)
|
||||||
|
if getattr(self, "_fws_disabled", False):
|
||||||
|
return
|
||||||
|
if not getattr(self, "_fws_steps", None):
|
||||||
|
self._fws_steps = _wizard_steps(self)
|
||||||
|
self._fws_index = 0
|
||||||
|
self._fws_pass = 0
|
||||||
|
elif getattr(self, "_fws_resume_index", None) is not None:
|
||||||
|
# On arrive PAR L'AVANT depuis l'écran standalone précédent (l'
|
||||||
|
# utilisateur avait reculé hors du hub) : on reprend à l'étape
|
||||||
|
# demandée, donc la première.
|
||||||
|
self._fws_index = self._fws_resume_index
|
||||||
|
else:
|
||||||
|
# On revient sur le hub : c'est le « Précédent » du récapitulatif.
|
||||||
|
# On rouvre la DERNIÈRE étape, pas la première — sinon l'utilisateur
|
||||||
|
# devrait retraverser tout l'assistant pour corriger un détail.
|
||||||
|
self._fws_index = max(0, len(self._fws_steps) - 1)
|
||||||
|
self._fws_resume_index = None
|
||||||
|
# idle_add : laisse la transition d'écran du GUI se terminer
|
||||||
|
# (setCurrentAction puis entered.emit) avant d'entrer dans une étape.
|
||||||
|
gtk_call_once(self._fws_enter_current)
|
||||||
|
|
||||||
|
def _enter_current(self):
|
||||||
|
"""Affiche l'étape courante (ou termine si on est au bout)."""
|
||||||
|
if getattr(self, "_fws_disabled", False):
|
||||||
|
return
|
||||||
|
steps = self._fws_steps
|
||||||
|
|
||||||
|
if self._fws_index >= len(steps):
|
||||||
|
self._fws_finish()
|
||||||
|
return
|
||||||
|
if self._fws_index < 0:
|
||||||
|
self._fws_index = 0
|
||||||
|
|
||||||
|
spoke = steps[self._fws_index]
|
||||||
|
if not spoke.ready:
|
||||||
|
# L'analyse des disques n'est pas finie : on attend sans bloquer,
|
||||||
|
# _update_spokes (timer du hub, 100 ms) nous rappellera. Le message
|
||||||
|
# n'est posé qu'UNE fois : la barre d'info s'anime à chaque
|
||||||
|
# set_info, elle clignoterait 10 fois par seconde.
|
||||||
|
if getattr(self, "_fws_pending", None) is not spoke:
|
||||||
|
self._fws_pending = spoke
|
||||||
|
self.set_info(_WAIT_MSG)
|
||||||
|
return
|
||||||
|
|
||||||
|
self._fws_pending = None
|
||||||
|
self.clear_info()
|
||||||
|
_build_nav_bar(spoke, self._fws_go_back)
|
||||||
|
# Même chemin que le clic sur une tuile : refresh + enterSpoke + signal
|
||||||
|
# « entered », et _inSpoke passe à True. On passe None comme
|
||||||
|
# « selector » : la tuile est masquée, lui donner le focus n'aurait
|
||||||
|
# aucun sens (et GTK râlerait sur un widget non affiché).
|
||||||
|
self._on_spoke_clicked(None, None, spoke)
|
||||||
|
|
||||||
|
def _go_back(self, spoke):
|
||||||
|
"""« Précédent » : revient à l'écran d'avant SANS rien appliquer.
|
||||||
|
|
||||||
|
Pas de apply()/execute() ici, volontairement : reculer ne doit rien
|
||||||
|
déclencher (l'apply() de l'écran Destination reconfigure le
|
||||||
|
partitionnement). Les saisies restent dans les widgets, et c'est
|
||||||
|
« Suivant » qui validera au passage suivant.
|
||||||
|
"""
|
||||||
|
if not self._inSpoke:
|
||||||
|
return
|
||||||
|
spoke.exited.emit(spoke)
|
||||||
|
self._inSpoke = False
|
||||||
|
|
||||||
|
if self._fws_index > 0:
|
||||||
|
self._fws_index -= 1
|
||||||
|
_set_transition("back")
|
||||||
|
self._fws_enter_current()
|
||||||
|
return
|
||||||
|
|
||||||
|
# Première étape : on sort du hub pour revenir à l'écran standalone
|
||||||
|
# d'avant (Connexion à Internet), d'où l'utilisateur peut encore
|
||||||
|
# reculer jusqu'à la langue et donc au clavier. Au retour, l'assistant
|
||||||
|
# reprendra à cette même première étape.
|
||||||
|
self._fws_resume_index = 0
|
||||||
|
if go_back_to_standalone(self, _PREVIOUS_STANDALONE):
|
||||||
|
return
|
||||||
|
# Écran précédent introuvable : on se contente de rouvrir l'étape,
|
||||||
|
# jamais d'écran vide.
|
||||||
|
self._fws_resume_index = None
|
||||||
|
_set_transition("none")
|
||||||
|
self._fws_enter_current()
|
||||||
|
|
||||||
|
def spoke_done(self, spoke):
|
||||||
|
"""« Suivant » : valide l'écran et passe au suivant.
|
||||||
|
|
||||||
|
Réimplémentation FIDÈLE de Hub.spoke_done (anaconda 45.8) à une
|
||||||
|
différence près : au lieu de retourner au menu (main_window.returnToHub)
|
||||||
|
on enchaîne sur l'étape suivante. Appeler l'original puis avancer
|
||||||
|
provoquait DEUX transitions de pile à la suite — un aller-retour visible
|
||||||
|
par le menu vide entre chaque écran.
|
||||||
|
"""
|
||||||
|
if not self._inSpoke:
|
||||||
|
return
|
||||||
|
|
||||||
|
if spoke.changed and (not spoke.skipTo or (spoke.skipTo and spoke.applyOnSkip)):
|
||||||
|
spoke.apply()
|
||||||
|
spoke.execute()
|
||||||
|
|
||||||
|
spoke.exited.emit(spoke)
|
||||||
|
self._inSpoke = False
|
||||||
|
|
||||||
|
for other in self._spokes.values():
|
||||||
|
if not other.indirect:
|
||||||
|
self._updateCompleteness(other, update_continue=False)
|
||||||
|
self._updateContinue()
|
||||||
|
|
||||||
|
# Un spoke peut demander un saut direct vers un autre écran (le
|
||||||
|
# partitionnement manuel le fait) : on respecte la demande.
|
||||||
|
if spoke.skipTo and spoke.skipTo in self._spokes:
|
||||||
|
destination = spoke.skipTo
|
||||||
|
spoke.skipTo = None
|
||||||
|
_set_transition("next")
|
||||||
|
self._on_spoke_clicked(None, None, self._spokes[destination])
|
||||||
|
return
|
||||||
|
|
||||||
|
if getattr(self, "_fws_disabled", False):
|
||||||
|
self.main_window.returnToHub()
|
||||||
|
return
|
||||||
|
|
||||||
|
self._fws_index += 1
|
||||||
|
_set_transition("next")
|
||||||
|
self._fws_enter_current()
|
||||||
|
|
||||||
|
def _finish(self):
|
||||||
|
"""Fin du parcours : lancer la suite, ou réparer ce qui manque."""
|
||||||
|
if self.continuePossible:
|
||||||
|
self.window.set_may_continue(True)
|
||||||
|
gtk_call_once(self.window.emit, "continue-clicked")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Il manque une information obligatoire (disque non configuré, aucun
|
||||||
|
# compte…). On renvoie UNE fois sur la première étape fautive, puis on
|
||||||
|
# rend le menu classique : l'utilisateur ne doit jamais se retrouver
|
||||||
|
# coincé dans une boucle d'écrans.
|
||||||
|
missing = [i for i, spoke in enumerate(self._fws_steps)
|
||||||
|
if spoke.mandatory and not spoke.completed]
|
||||||
|
if missing and getattr(self, "_fws_pass", 0) < 1:
|
||||||
|
self._fws_pass = getattr(self, "_fws_pass", 0) + 1
|
||||||
|
self._fws_index = missing[0]
|
||||||
|
_set_transition("back")
|
||||||
|
self._fws_enter_current()
|
||||||
|
return
|
||||||
|
|
||||||
|
log.warning("FWS: parcours incomplet — retour au menu classique.")
|
||||||
|
self._fws_disabled = True
|
||||||
|
self._fws_show_menu()
|
||||||
|
|
||||||
|
def _update_spokes(self):
|
||||||
|
keep_going = original_update_spokes(self)
|
||||||
|
pending = getattr(self, "_fws_pending", None)
|
||||||
|
if pending is not None and not self._inSpoke and pending.ready:
|
||||||
|
self._fws_enter_current()
|
||||||
|
return keep_going
|
||||||
|
|
||||||
|
SummaryHub._fws_hide_menu = _hide_menu
|
||||||
|
SummaryHub._fws_show_menu = _show_menu
|
||||||
|
SummaryHub._fws_enter_current = _enter_current
|
||||||
|
SummaryHub._fws_go_back = _go_back
|
||||||
|
SummaryHub._fws_finish = _finish
|
||||||
|
SummaryHub._createBox = _createBox
|
||||||
|
SummaryHub.refresh = refresh
|
||||||
|
SummaryHub.spoke_done = spoke_done
|
||||||
|
SummaryHub._update_spokes = _update_spokes
|
||||||
|
SummaryHub._fws_wizard_installed = True
|
||||||
|
log.info("FWS: hub Résumé converti en assistant pas à pas.")
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
_hook_welcome_spoke()
|
||||||
|
except Exception: # pylint: disable=broad-except
|
||||||
|
log.exception("FWS: clavier immédiat non branché (écran de langue inchangé).")
|
||||||
|
|
||||||
|
try:
|
||||||
|
_patch_main_window()
|
||||||
|
except Exception: # pylint: disable=broad-except
|
||||||
|
log.exception("FWS: transitions d'écran laissées telles quelles.")
|
||||||
|
|
||||||
|
try:
|
||||||
|
_install_wizard()
|
||||||
|
except Exception: # pylint: disable=broad-except
|
||||||
|
log.exception("FWS: assistant pas à pas non installé — menu classique conservé.")
|
||||||
@@ -69,7 +69,6 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">False</property>
|
<property name="receives-default">False</property>
|
||||||
<property name="active">True</property>
|
|
||||||
<property name="draw-indicator">True</property>
|
<property name="draw-indicator">True</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
@@ -98,6 +97,7 @@
|
|||||||
<property name="label" translatable="yes">KDE Plasma</property>
|
<property name="label" translatable="yes">KDE Plasma</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
|
<property name="active">True</property>
|
||||||
<property name="receives-default">False</property>
|
<property name="receives-default">False</property>
|
||||||
<property name="draw-indicator">True</property>
|
<property name="draw-indicator">True</property>
|
||||||
<property name="group">radio_cli</property>
|
<property name="group">radio_cli</property>
|
||||||
|
|||||||
@@ -93,6 +93,10 @@ xorg-server
|
|||||||
xorg-xinit
|
xorg-xinit
|
||||||
xorg-xrandr
|
xorg-xrandr
|
||||||
xorg-xsetroot
|
xorg-xsetroot
|
||||||
|
# setxkbmap : applique IMMÉDIATEMENT au serveur X du live la disposition
|
||||||
|
# clavier choisie au 1er écran de l'installateur (localed n'agit que sur
|
||||||
|
# la config, pas sur le X en cours) — cf. fws_wizard.py.
|
||||||
|
xorg-setxkbmap
|
||||||
openbox
|
openbox
|
||||||
ttf-dejavu
|
ttf-dejavu
|
||||||
# Terminal X : debug de l'installateur + entrée « Terminals » du menu Openbox.
|
# Terminal X : debug de l'installateur + entrée « Terminals » du menu Openbox.
|
||||||
|
|||||||
@@ -93,6 +93,10 @@ zram-generator
|
|||||||
xorg-xinit
|
xorg-xinit
|
||||||
xorg-xrandr
|
xorg-xrandr
|
||||||
xorg-xsetroot
|
xorg-xsetroot
|
||||||
|
# setxkbmap : applique IMMÉDIATEMENT au serveur X du live la disposition
|
||||||
|
# clavier choisie au 1er écran de l'installateur (localed n'agit que sur
|
||||||
|
# la config, pas sur le X en cours) — cf. fws_wizard.py.
|
||||||
|
xorg-setxkbmap
|
||||||
openbox
|
openbox
|
||||||
ttf-dejavu
|
ttf-dejavu
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user