main.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * GnomeSettingsVault - A high-integrity GNOME configuration backup utility.
  3. * Copyright (C) 2026 Nicole Portas, nicole@equalmass.com
  4. */
  5. #include "MainWindow.hpp"
  6. #include <gtkmm/application.h>
  7. #include <gtk/gtk.h>
  8. #include <iostream>
  9. #include <cstdlib>
  10. #include <sys/stat.h>
  11. #include <string>
  12. int main(int argc, char *argv[]) {
  13. // --- Environment Hijack for Fontconfig ---
  14. // This prevents font cache collisions in restricted environments
  15. const char* user = std::getenv("USER");
  16. std::string safe_cache_dir = std::string("/tmp/gnome-vault-cache-") + (user ? user : "default");
  17. mkdir(safe_cache_dir.c_str(), 0777);
  18. setenv("XDG_CACHE_HOME", safe_cache_dir.c_str(), 1);
  19. // --- Identity Setup ---
  20. // IMPORTANT: This string MUST match the 'StartupWMClass' in your .desktop file
  21. // and ideally the 'Exec' binary name to ensure the icon pins correctly.
  22. const std::string app_id = "gnome-vault";
  23. g_set_prgname(app_id.c_str());
  24. g_set_application_name("GnomeSettingsVault");
  25. if (!gtk_init_check(&argc, &argv)) {
  26. std::cerr << "Bloody hell: GTK failed to initialize." << std::endl;
  27. return 1;
  28. }
  29. try {
  30. // We use a reverse-DNS style ID for the Application object,
  31. // but the WMClass is handled by the prgname set above.
  32. auto app = Gtk::Application::create(argc, argv, "com.equalmass.gnomevault");
  33. MainWindow window;
  34. // Final hammer blow to ensure the window is identified correctly
  35. window.set_wmclass(app_id, "GnomeSettingsVault");
  36. return app->run(window);
  37. } catch (const Glib::Error& ex) {
  38. std::cerr << "GTK Error: " << ex.what() << std::endl;
  39. return 1;
  40. } catch (const std::exception& ex) {
  41. std::cerr << "Standard Exception: " << ex.what() << std::endl;
  42. return 1;
  43. }
  44. }