MainWindow.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * GnomeSettingsVault - A GNOME configuration backup utility v0.3.4
  3. */
  4. #pragma once
  5. #include <gtkmm.h>
  6. #include <giomm.h>
  7. #include <string>
  8. #include <fstream>
  9. #include <thread>
  10. #include <mutex>
  11. #include <queue>
  12. #include <atomic>
  13. struct JobConfig {
  14. bool themes;
  15. bool icons;
  16. bool wallpapers;
  17. bool extensions;
  18. bool dconf;
  19. bool dry_run;
  20. std::string vault_name;
  21. std::string custom_restore_path;
  22. std::string backup_save_path;
  23. };
  24. class MainWindow : public Gtk::Window {
  25. public:
  26. MainWindow();
  27. virtual ~MainWindow();
  28. private:
  29. Gtk::HeaderBar m_HeaderBar;
  30. Gtk::Box m_MainLayout;
  31. Gtk::Notebook m_Notebook;
  32. Gtk::ScrolledWindow m_ScrolledWindow;
  33. Gtk::TextView m_LogView;
  34. Glib::RefPtr<Gtk::TextBuffer> m_RefTextBuffer;
  35. Gtk::Box m_BottomBox;
  36. Gtk::Label m_StatusLabel;
  37. Gtk::CheckButton m_CheckDebugMode;
  38. Gtk::Box m_VBoxBackup;
  39. Gtk::Label m_LabelBackupInstruction;
  40. Gtk::Entry m_EntryVaultName;
  41. Gtk::Button m_ButtonSelectDest;
  42. Gtk::Label m_LabelBackupPath;
  43. Gtk::CheckButton m_CheckThemesBackup;
  44. Gtk::CheckButton m_CheckIconsBackup;
  45. Gtk::CheckButton m_CheckWallpapersBackup;
  46. Gtk::CheckButton m_CheckExtensionsBackup;
  47. Gtk::CheckButton m_CheckDconfBackup;
  48. Gtk::Button m_ButtonBackup;
  49. Gtk::Box m_VBoxRestore;
  50. Gtk::Label m_LabelRestoreInstruction;
  51. Gtk::Button m_ButtonSelectVault;
  52. Gtk::Label m_LabelSelectedVault;
  53. Gtk::CheckButton m_CheckThemesRestore;
  54. Gtk::CheckButton m_CheckIconsRestore;
  55. Gtk::CheckButton m_CheckWallpapersRestore;
  56. Gtk::CheckButton m_CheckExtensionsRestore;
  57. Gtk::CheckButton m_CheckDconfRestore;
  58. Gtk::CheckButton m_CheckDryRunRestore;
  59. Gtk::Button m_ButtonRestore;
  60. Glib::Dispatcher m_Dispatcher;
  61. std::mutex m_LogMutex;
  62. std::queue<std::string> m_LogQueue;
  63. std::atomic<bool> m_WorkerRunning;
  64. std::atomic<bool> m_JobSuccess;
  65. std::atomic<bool> m_IsDebugMode;
  66. std::atomic<bool> m_LastJobWasRestore;
  67. std::string m_SelectedVaultPath;
  68. std::string m_TargetBackupPath;
  69. void on_button_select_dest_clicked();
  70. void on_button_backup_clicked();
  71. void on_button_restore_clicked();
  72. void on_button_select_vault_clicked();
  73. void on_dispatcher_ping();
  74. void add_log_ui(const std::string& message);
  75. void set_ui_locked(bool locked);
  76. void queue_log(const std::string& message);
  77. void scan_vault_contents(const std::string& path);
  78. void run_backup_job(JobConfig config, std::string home_dir);
  79. void run_restore_job(JobConfig config, std::string home_dir);
  80. bool create_tar_archive(const std::string& source_dir, const std::string& out_filename, bool strip_path);
  81. bool extract_tar_archive(const std::string& archive_path, const std::string& dest_dir, bool dry_run, bool use_absolute);
  82. std::string get_wallpaper_directory();
  83. void send_notification(const std::string& title, const std::string& body);
  84. };