Skip to content
API Documentation
BastionGuard™
StyleProvider.cpp File Reference

Go to the source code of this file.

Macros

#define DATA_DIR   "/usr/share/BastionGuard/data"

Functions

void load_style ()

Macro Definition Documentation

◆ DATA_DIR

#define DATA_DIR   "/usr/share/BastionGuard/data"

Definition at line 30 of file StyleProvider.cpp.

Function Documentation

◆ load_style()

void load_style ( )

Definition at line 33 of file StyleProvider.cpp.

33 {
34 auto css = Gtk::CssProvider::create();
35
36 std::string local = "data/BastionGuard.css";
37 std::string installed = std::string(DATA_DIR) + "/BastionGuard.css";
38
39 try {
40 if (std::filesystem::exists(local)) {
41 css->load_from_path(local);
42 std::cout << _("✔ CSS caricato da ") << local << std::endl;
43 } else if (std::filesystem::exists(installed)) {
44 css->load_from_path(installed);
45 std::cout << _("✔ CSS caricato da ") << installed << std::endl;
46 } else {
47 std::cerr << _("⚠ Nessun file CSS trovato:\n")
48 << " " << local << "\n " << installed << std::endl;
49 }
50
51 Gtk::StyleContext::add_provider_for_display(
52 Gdk::Display::get_default(),
53 css,
54 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
55 );
56 } catch (const Glib::Error& ex) {
57 std::cerr << _("❌ Errore CSS: ") << ex.what() << std::endl;
58 }
59}
#define _(s)
#define DATA_DIR
Definition Resource.hpp:28

References _, DATA_DIR, and load_style().