fix: fix Aur detection packages
This commit is contained in:
66
lib/ui.py
66
lib/ui.py
@ -20,6 +20,7 @@ class UpdaterWindow(Adw.ApplicationWindow):
|
||||
self.set_resizable(True)
|
||||
|
||||
self._pending_rows: list[Adw.ActionRow] = []
|
||||
self._aur_rows: list[Adw.ActionRow] = []
|
||||
self._recent_rows: list[Adw.ActionRow] = []
|
||||
|
||||
self._build_ui()
|
||||
@ -68,6 +69,21 @@ class UpdaterWindow(Adw.ApplicationWindow):
|
||||
|
||||
main_box.append(self.pending_group)
|
||||
|
||||
# Groupe "Mises à jour AUR"
|
||||
self.aur_group = Adw.PreferencesGroup()
|
||||
self.aur_group.set_title("Mises à jour AUR")
|
||||
self.aur_group.set_description(
|
||||
"Ces paquets seront installés automatiquement lors de la prochaine session"
|
||||
)
|
||||
|
||||
self.install_aur_btn = Gtk.Button.new_with_label("Installer maintenant")
|
||||
self.install_aur_btn.add_css_class("suggested-action")
|
||||
self.install_aur_btn.add_css_class("pill")
|
||||
self.install_aur_btn.connect("clicked", self._on_install_aur_clicked)
|
||||
self.aur_group.set_header_suffix(self.install_aur_btn)
|
||||
|
||||
main_box.append(self.aur_group)
|
||||
|
||||
# Groupe "Récemment installées"
|
||||
self.recent_group = Adw.PreferencesGroup()
|
||||
self.recent_group.set_title("Récemment installées")
|
||||
@ -185,6 +201,7 @@ class UpdaterWindow(Adw.ApplicationWindow):
|
||||
def _update_ui(self, state: dict):
|
||||
status = state.get("status", "idle")
|
||||
pending = state.get("pending_restart", [])
|
||||
pending_aur = state.get("pending_aur", [])
|
||||
history = state.get("installed_history", [])
|
||||
last_check = state.get("last_check")
|
||||
errors = state.get("errors", [])
|
||||
@ -240,10 +257,13 @@ class UpdaterWindow(Adw.ApplicationWindow):
|
||||
pass
|
||||
self.status_sub_lbl.set_text(sub)
|
||||
|
||||
# ── Bouton "Installer maintenant" ────────────────────────────────
|
||||
# ── Bouton "Installer maintenant" (officiel) ─────────────────────
|
||||
can_install = status in ("idle", "error") and bool(pending)
|
||||
self.install_now_btn.set_sensitive(can_install)
|
||||
|
||||
# ── Bouton "Installer maintenant" (AUR) ──────────────────────────
|
||||
self.install_aur_btn.set_sensitive(bool(pending_aur))
|
||||
|
||||
# ── Liste des paquets en attente de redémarrage ──────────────────
|
||||
for row in self._pending_rows:
|
||||
self.pending_group.remove(row)
|
||||
@ -263,6 +283,25 @@ class UpdaterWindow(Adw.ApplicationWindow):
|
||||
|
||||
self.pending_group.set_visible(bool(pending))
|
||||
|
||||
# ── Liste des paquets AUR en attente ─────────────────────────────
|
||||
for row in self._aur_rows:
|
||||
self.aur_group.remove(row)
|
||||
self._aur_rows.clear()
|
||||
|
||||
for pkg in pending_aur:
|
||||
row = Adw.ActionRow()
|
||||
row.set_title(GLib.markup_escape_text(pkg.get("name", "")))
|
||||
row.set_subtitle(
|
||||
f"{pkg.get('old_version', '')} → {pkg.get('new_version', '')}"
|
||||
)
|
||||
icon = Gtk.Image.new_from_icon_name("application-x-addon-symbolic")
|
||||
icon.add_css_class("accent")
|
||||
row.add_prefix(icon)
|
||||
self.aur_group.add(row)
|
||||
self._aur_rows.append(row)
|
||||
|
||||
self.aur_group.set_visible(bool(pending_aur))
|
||||
|
||||
# ── Historique des installations récentes ────────────────────────
|
||||
for row in self._recent_rows:
|
||||
self.recent_group.remove(row)
|
||||
@ -321,6 +360,10 @@ class UpdaterWindow(Adw.ApplicationWindow):
|
||||
self.install_now_btn.set_sensitive(False)
|
||||
threading.Thread(target=self._send_install_pending, daemon=True).start()
|
||||
|
||||
def _on_install_aur_clicked(self, _btn):
|
||||
self.install_aur_btn.set_sensitive(False)
|
||||
threading.Thread(target=self._send_install_aur, daemon=True).start()
|
||||
|
||||
def _send_install_pending(self):
|
||||
try:
|
||||
s = sock_module.socket(sock_module.AF_UNIX, sock_module.SOCK_STREAM)
|
||||
@ -342,6 +385,27 @@ class UpdaterWindow(Adw.ApplicationWindow):
|
||||
)
|
||||
GLib.idle_add(self.install_now_btn.set_sensitive, True)
|
||||
|
||||
def _send_install_aur(self):
|
||||
try:
|
||||
s = sock_module.socket(sock_module.AF_UNIX, sock_module.SOCK_STREAM)
|
||||
s.settimeout(5)
|
||||
s.connect(str(SOCKET_PATH))
|
||||
s.sendall(json.dumps({"action": "install_aur"}).encode())
|
||||
s.recv(1024)
|
||||
s.close()
|
||||
except PermissionError:
|
||||
GLib.idle_add(
|
||||
self._show_toast,
|
||||
"Permission refusée — êtes-vous dans le groupe wheel ?",
|
||||
)
|
||||
GLib.idle_add(self.install_aur_btn.set_sensitive, True)
|
||||
except Exception as e:
|
||||
GLib.idle_add(
|
||||
self._show_toast,
|
||||
f"Impossible de contacter le service : {e}",
|
||||
)
|
||||
GLib.idle_add(self.install_aur_btn.set_sensitive, True)
|
||||
|
||||
def _send_check_now(self):
|
||||
try:
|
||||
s = sock_module.socket(sock_module.AF_UNIX, sock_module.SOCK_STREAM)
|
||||
|
||||
Reference in New Issue
Block a user