- CPack DEB configuration (cmake/Packaging.cmake): dependencies from dpkg-shlibdeps, udisks2 recommended, strip. - AppStream metadata, installed with the desktop file and the icons; tools/release.sh adds each release to it. - tools/appimage.sh: AppImage of the GTK interface and openpu-cli with linuxdeploy and its GTK plugin (x86_64 and aarch64). - Release workflow: .deb, AppImage and openpu-cli tarball for x86_64 and arm64, attached to the release of a vX.Y.Z tag, or kept as artifacts on a manual run. tools/release.sh edits the release when the workflow created it first. - The GTK interface finds its translations next to the executable (../share/locale), for relocatable installs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WDASLCiN764v685boRVYar
52 lines
1.8 KiB
C++
52 lines
1.8 KiB
C++
// SPDX-License-Identifier: MIT
|
|
#include "main_window.hpp"
|
|
|
|
#include "openpu/storage.hpp"
|
|
|
|
#include <clocale>
|
|
#include <cstdlib>
|
|
#include <filesystem>
|
|
#include <string>
|
|
#include <system_error>
|
|
#include <glibmm/i18n.h>
|
|
#include <gtkmm/application.h>
|
|
|
|
namespace {
|
|
|
|
/// Translations directory: OPENPU_LOCALEDIR (build tree), else <prefix>/share/locale next to the
|
|
/// executable when it exists (relocatable installs such as the AppImage), else the configured one.
|
|
std::string localeDir()
|
|
{
|
|
if (const char* dir = std::getenv("OPENPU_LOCALEDIR")) // NOLINT(concurrency-mt-unsafe): no thread yet
|
|
return dir;
|
|
std::error_code ec;
|
|
const auto exe = std::filesystem::read_symlink("/proc/self/exe", ec);
|
|
if (!ec) {
|
|
const auto dir = exe.parent_path().parent_path() / "share" / "locale";
|
|
if (std::filesystem::is_directory(dir, ec))
|
|
return dir.string();
|
|
}
|
|
return OPENPU_LOCALEDIR;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
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
|
|
bindtextdomain(GETTEXT_PACKAGE, localeDir().c_str());
|
|
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);
|
|
}
|