main.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. const char* user = std::getenv("USER");
  14. std::string safe_cache_dir = std::string("/tmp/gnome-vault-cache-") + (user ? user : "default");
  15. mkdir(safe_cache_dir.c_str(), 0777);
  16. setenv("XDG_CACHE_HOME", safe_cache_dir.c_str(), 1);
  17. const std::string app_id = "gnome-vault";
  18. g_set_prgname(app_id.c_str());
  19. g_set_application_name("GnomeSettingsVault");
  20. if (!gtk_init_check(&argc, &argv)) {
  21. std::cerr << "Bloody hell: GTK failed to initialize." << std::endl;
  22. return 1;
  23. }
  24. try {
  25. auto app = Gtk::Application::create(argc, argv, "com.equalmass.gnomevault");
  26. MainWindow window;
  27. return app->run(window);
  28. } catch (const Glib::Error& ex) {
  29. std::cerr << "GTK Error: " << ex.what() << std::endl;
  30. return 1;
  31. } catch (const std::exception& ex) {
  32. std::cerr << "Standard Exception: " << ex.what() << std::endl;
  33. return 1;
  34. }
  35. }