48{
50
52 const std::string cssName = (theme == "dark")
53 ? "BastionGuard-dark.css"
54 : "BastionGuard.css";
55
56 const std::string local = "data/" + cssName;
57 const std::string installed = std::string(
DATA_DIR) +
"/" + cssName;
58
59 std::string used;
60
61 try {
62 if (std::filesystem::exists(local)) {
64 used = local;
65 } else if (std::filesystem::exists(installed)) {
67 used = installed;
68 } else {
69 const std::string fallback_local = "data/BastionGuard.css";
70 const std::string fallback_installed = std::string(
DATA_DIR) +
"/BastionGuard.css";
71 if (std::filesystem::exists(fallback_local)) {
73 used = fallback_local;
74 } else if (std::filesystem::exists(fallback_installed)) {
75 global_css->load_from_path(fallback_installed);
76 used = fallback_installed;
77 } else {
78 std::cerr << "⚠ Nessun file CSS trovato:\n"
79 << " " << local << "\n " << installed
80 << std::endl;
81 return;
82 }
83 }
84
85 Gtk::StyleContext::add_provider_for_display(
86 Gdk::Display::get_default(),
88 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
89
90 std::cout <<
_(
"[CSS] Tema '") << theme
91 <<
_(
"' caricato da: ") << used << std::endl;
92
93 } catch (const Glib::Error& ex) {
94 std::cerr <<
_(
"❌ Errore CSS: ") << ex.what() << std::endl;
95 }
96}
Glib::RefPtr< Gtk::CssProvider > global_css
static std::string read_saved_theme()