gtk: interface GTK4, préférences, versions, traductions, licence MIT

- interface gtkmm-4 : véhicules, ajout par VIN, mises à jour, dossier,
  téléchargement avec reprise et arrêt, choix de la clé, confirmation,
  écriture avec progression, fin avec guide d'installation ; travail
  dans un thread, résultats renvoyés via Glib::Dispatcher
- préférences : dossier de téléchargement, langue (système par défaut),
  recherche automatique de nouvelle version d'OpenPU
- recherche de nouvelle version (releases GitHub, format tags Gitea
  accepté) avec ouverture de la page dans le navigateur ;
  openpu-cli app-update
- versions : project(VERSION) + git describe régénéré à chaque build,
  openpu-cli --version, À propos, User-Agent, CHANGELOG, tools/release.sh
  (étiquette annotée, push vers tous les remotes, release GitHub)
- traductions gettext : textes anglais, fr.po complet (96 chaînes),
  extracteur de secours sans xgettext
- core : module job (téléchargement licence/fw/carte), liens des guides
  PDF, ordre des véhicules conservé (ordered_json)
- licence MIT (LICENSE, en-têtes SPDX) ; dépôt principal sur GitHub
- validé dans WSLg : parcours complet jusqu'à l'écriture d'une clé loop
  (FAT32 propre, fichiers téléchargés supprimés)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WDASLCiN764v685boRVYar
This commit is contained in:
yann64andClaude Opus 5.5 committed 2026-11-28 19:54:04 +01:00
1 parent 6a7a2f1ee9
commit 384aaf78c6
62 files changed
+3029 -20

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTKMM REQUIRED IMPORTED_TARGET gtkmm-4.0>=4.10)
include(GNUInstallDirs)
add_executable(openpu
main.cpp
main_window.cpp
)
target_link_libraries(openpu PRIVATE openpu_core PkgConfig::GTKMM openpu_warnings)
target_compile_definitions(openpu PRIVATE
GETTEXT_PACKAGE="openpu"
OPENPU_LOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}")
# gtkmm headers trigger -Wshadow/-Wconversion noise we cannot fix.
target_compile_options(openpu PRIVATE -Wno-shadow -Wno-conversion)
install(TARGETS openpu RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES io.github.openpu.OpenPU.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
@@ -0,0 +1,12 @@
[Desktop Entry]
Type=Application
Name=OpenPU
GenericName=Head unit updates
GenericName[fr]=Mises à jour de l'autoradio
Comment=Download firmware and map updates for Peugeot head units and prepare the USB stick
Comment[fr]=Télécharger les mises à jour système et cartographie des autoradios Peugeot et préparer la clé USB
Exec=openpu
Icon=io.github.openpu.OpenPU
Terminal=false
Categories=Utility;GTK;
Keywords=Peugeot;NAC;RCC;GPS;map;firmware;USB;
+30
View File
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: MIT
#include "main_window.hpp"
#include "openpu/storage.hpp"
#include <clocale>
#include <cstdlib>
#include <glibmm/i18n.h>
#include <gtkmm/application.h>
int main(int argc, char* argv[])
{
// A language chosen in the settings overrides the session language (gettext reads LANGUAGE).
try {
const auto settings = openpu::Settings::load(openpu::paths::configDir() / "config.json");
if (!settings.language.empty())
(void)setenv("LANGUAGE", settings.language.c_str(), 1); // NOLINT(concurrency-mt-unsafe): no thread yet
} catch (const openpu::StorageError&) {
// dismissed: the window reports unreadable settings itself
}
(void)std::setlocale(LC_ALL, ""); // NOLINT(concurrency-mt-unsafe): no thread yet
// OPENPU_LOCALEDIR lets a build-tree binary find its translations.
const char* localeDir = std::getenv("OPENPU_LOCALEDIR"); // NOLINT(concurrency-mt-unsafe)
bindtextdomain(GETTEXT_PACKAGE, localeDir != nullptr ? localeDir : OPENPU_LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
auto app = Gtk::Application::create("io.github.openpu.OpenPU");
return app->make_window_and_run<openpu::gtk::MainWindow>(argc, argv);
}
File diff suppressed because it is too large. Load diff
+141
View File
@@ -0,0 +1,141 @@
// SPDX-License-Identifier: MIT
#pragma once
#include "ui_queue.hpp"
#include "openpu/api_client.hpp"
#include "openpu/app_update.hpp"
#include "openpu/job.hpp"
#include "openpu/storage.hpp"
#include "openpu/usb.hpp"
#include <gtkmm.h>
#include <memory>
#include <optional>
#include <thread>
namespace openpu::gtk {
class MainWindow : public Gtk::ApplicationWindow {
public:
MainWindow();
~MainWindow() override;
MainWindow(const MainWindow&) = delete;
MainWindow& operator=(const MainWindow&) = delete;
private:
// pages
void buildVehiclesPage();
void buildAddPage();
void buildUpdatesPage();
void buildDownloadPage();
void buildUsbPage();
void buildWritePage();
void buildDonePage();
void show(const char* page);
// vehicles
void refreshVehicles();
std::optional<Vehicle> selectedVehicle() const;
void onAddVehicle();
void onRemoveVehicle();
void onCheckUpdates();
// updates / download
void showUpdates(const AvailableUpdates& updates);
void onChooseFolder();
void onStartDownload();
void startDownload(const DownloadPlan& plan);
void onDownloadProgress(const JobProgress& p);
void onDownloaded(const DownloadedFiles& files);
// usb
void enterUsbPage();
void refreshDrives();
void onPrepareUsb();
void startWrite(const UsbDrive& drive);
void onWriteProgress(const UsbProgress& p);
void onWritten();
// helpers
template <typename F>
void runAsync(F&& work);
void joinWorker();
void showError(const Glib::ustring& title, const Glib::ustring& detail);
void showAbout();
void showPreferences();
void checkAppUpdate(bool manual);
void offerAppUpdate(const AppRelease& release);
void saveVehicles();
void updateDownloadDirLabel();
std::string language() const;
UiQueue ui_;
std::unique_ptr<Transport> transport_;
std::unique_ptr<ApiClient> api_;
std::unique_ptr<UsbBackend> usb_;
VehicleStore store_;
Settings settings_;
std::filesystem::path settingsFile_;
std::thread worker_;
std::thread updateThread_; // OpenPU new-version check, independent of the main flow
bool updateCheckRunning_ = false;
CancelToken cancel_;
// flow state
std::optional<Vehicle> current_;
AvailableUpdates updates_;
DownloadedFiles files_;
std::vector<UsbDrive> drives_;
std::uint64_t payload_ = 0;
// widgets
Gtk::HeaderBar header_;
Gtk::Button back_;
Gtk::MenuButton menu_;
Gtk::Label* prefsDirLabel_ = nullptr; // download folder shown in the open preferences window
Gtk::Stack stack_;
Gtk::Box vehiclesPage_{Gtk::Orientation::VERTICAL, 12};
Gtk::ListBox vehicleList_;
Gtk::Label vehiclesEmpty_;
Gtk::Button addButton_, removeButton_, checkButton_;
Gtk::Box addPage_{Gtk::Orientation::VERTICAL, 12};
Gtk::Entry vinEntry_, nameEntry_;
Gtk::Label addStatus_;
Gtk::Spinner addSpinner_;
Gtk::Button addConfirm_;
Gtk::Box updatesPage_{Gtk::Orientation::VERTICAL, 12};
Gtk::Label updatesTitle_, updatesStatus_;
Gtk::Spinner updatesSpinner_;
Gtk::CheckButton firmwareCheck_, mapCheck_;
Gtk::Label downloadDirLabel_;
Gtk::Button chooseDir_, downloadButton_, guideButton_;
Gtk::Box downloadPage_{Gtk::Orientation::VERTICAL, 12};
Gtk::Label downloadTitle_;
Gtk::Label licenseLabel_, firmwareLabel_, mapLabel_;
Gtk::ProgressBar firmwareBar_, mapBar_;
Gtk::Label etaLabel_;
Gtk::Button cancelDownload_;
Gtk::Box usbPage_{Gtk::Orientation::VERTICAL, 12};
Gtk::Label usbInfo_;
Gtk::DropDown driveDrop_;
Glib::RefPtr<Gtk::StringList> driveModel_;
Gtk::Button refreshDrives_, prepareButton_;
Gtk::Label usbStatus_;
Gtk::Box writePage_{Gtk::Orientation::VERTICAL, 12};
Gtk::Label writeStep_, writeDetail_;
Gtk::ProgressBar writeBar_;
Gtk::Button cancelWrite_;
Gtk::Box donePage_{Gtk::Orientation::VERTICAL, 12};
Gtk::Label doneText_;
Gtk::Button doneGuide_, doneButton_;
};
} // namespace openpu::gtk
+43
View File
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: MIT
#pragma once
#include <deque>
#include <functional>
#include <glibmm/dispatcher.h>
#include <mutex>
namespace openpu::gtk {
/// Runs closures posted from worker threads on the GTK main loop.
/// Must be constructed on the main thread (Glib::Dispatcher requirement).
class UiQueue {
public:
UiQueue() { dispatcher_.connect([this] { drain(); }); }
void post(std::function<void()> fn)
{
{
std::scoped_lock lock(mutex_);
queue_.push_back(std::move(fn));
}
dispatcher_.emit();
}
private:
void drain()
{
std::deque<std::function<void()>> local;
{
std::scoped_lock lock(mutex_);
local.swap(queue_);
}
for (auto& fn : local)
fn();
}
Glib::Dispatcher dispatcher_;
std::mutex mutex_;
std::deque<std::function<void()>> queue_;
};
} // namespace openpu::gtk