v1.8.78: auto-updater — Gitea releases check, download, apply
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -124,6 +124,45 @@ class SetupTab(ctk.CTkFrame):
|
||||
btn.pack(side="left", padx=2)
|
||||
self._interval_buttons[seconds] = btn
|
||||
|
||||
# ── Updates section ─────────────────────────
|
||||
update_frame = ctk.CTkFrame(self._scroll)
|
||||
update_frame.pack(fill="x", padx=20, pady=(5, 5))
|
||||
|
||||
self.update_title = ctk.CTkLabel(
|
||||
update_frame, text=t("update_mode"),
|
||||
font=ctk.CTkFont(size=14, weight="bold"), anchor="w"
|
||||
)
|
||||
self.update_title.pack(fill="x", padx=15, pady=(10, 5))
|
||||
|
||||
update_row = ctk.CTkFrame(update_frame, fg_color="transparent")
|
||||
update_row.pack(fill="x", padx=15, pady=(0, 10))
|
||||
|
||||
self._update_mode_buttons: dict[str, ctk.CTkButton] = {}
|
||||
current_mode = store.get_update_mode()
|
||||
update_modes = [
|
||||
("notify-only", "update_mode_notify"),
|
||||
("auto-download", "update_mode_download"),
|
||||
("full-auto", "update_mode_auto"),
|
||||
]
|
||||
for mode, key in update_modes:
|
||||
is_active = (mode == current_mode)
|
||||
btn = ctk.CTkButton(
|
||||
update_row, text=t(key), width=120, height=28,
|
||||
fg_color="#3b82f6" if is_active else "#6b7280",
|
||||
hover_color="#2563eb" if is_active else "#4b5563",
|
||||
command=lambda m=mode: self._set_update_mode(m)
|
||||
)
|
||||
btn.pack(side="left", padx=2)
|
||||
self._update_mode_buttons[mode] = btn
|
||||
|
||||
# Check for updates button
|
||||
self._check_updates_btn = ctk.CTkButton(
|
||||
update_row, text=t("update_check"), width=140, height=28,
|
||||
fg_color="#3b82f6", hover_color="#2563eb",
|
||||
command=self._check_updates,
|
||||
)
|
||||
self._check_updates_btn.pack(side="right")
|
||||
|
||||
# ── Configuration section ─────────────────────
|
||||
config_frame = ctk.CTkFrame(self._scroll)
|
||||
config_frame.pack(fill="x", padx=20, pady=(5, 5))
|
||||
@@ -212,6 +251,38 @@ class SetupTab(ctk.CTkFrame):
|
||||
# Initial status check
|
||||
self._refresh_status()
|
||||
|
||||
def _set_update_mode(self, mode: str):
|
||||
self.store.set_update_mode(mode)
|
||||
for m, btn in self._update_mode_buttons.items():
|
||||
if m == mode:
|
||||
btn.configure(fg_color="#3b82f6", hover_color="#2563eb")
|
||||
else:
|
||||
btn.configure(fg_color="#6b7280", hover_color="#4b5563")
|
||||
self._log(f"{t('update_mode')}: {t('update_mode_notify') if mode == 'notify-only' else t('update_mode_download') if mode == 'auto-download' else t('update_mode_auto')}")
|
||||
|
||||
def _check_updates(self):
|
||||
self._check_updates_btn.configure(state="disabled", text=t("update_checking"))
|
||||
|
||||
def _do():
|
||||
try:
|
||||
# Access updater via the app (grandparent of tab)
|
||||
app = self.winfo_toplevel()
|
||||
if hasattr(app, "updater"):
|
||||
info = app.updater.check_now()
|
||||
if info:
|
||||
self.after(0, lambda: self._log(t("update_available").format(version=info["version"])))
|
||||
self.after(0, lambda: app._handle_update_event("available", info, None))
|
||||
else:
|
||||
self.after(0, lambda: self._log(t("update_no_updates")))
|
||||
else:
|
||||
self.after(0, lambda: self._log("Updater not available"))
|
||||
except Exception as e:
|
||||
self.after(0, lambda: self._log(f"Error: {e}"))
|
||||
finally:
|
||||
self.after(0, lambda: self._check_updates_btn.configure(state="normal", text=t("update_check")))
|
||||
|
||||
threading.Thread(target=_do, daemon=True).start()
|
||||
|
||||
def _set_interval(self, seconds: int):
|
||||
self.store.set_check_interval(seconds)
|
||||
for s, btn in self._interval_buttons.items():
|
||||
|
||||
Reference in New Issue
Block a user