MainWindow.hpp 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. protected:
  29. // Intercept the window manager close signal
  30. bool on_delete_event(GdkEventAny* any_event) override;
  31. private:
  32. Gtk::HeaderBar m_HeaderBar;
  33. Gtk::Box m_MainLayout;
  34. Gtk::Notebook m_Notebook;
  35. Gtk::ScrolledWindow m_ScrolledWindow;
  36. Gtk::TextView m_LogView;
  37. Glib::RefPtr<Gtk::TextBuffer> m_RefTextBuffer;
  38. Gtk::Box m_BottomBox;
  39. Gtk::Label m_StatusLabel;
  40. Gtk::CheckButton m_CheckDebugMode;
  41. Gtk::Box m_VBoxBackup;
  42. Gtk::Label m_LabelBackupInstruction;
  43. Gtk::Entry m_EntryVaultName;
  44. Gtk::Button m_ButtonSelectDest;
  45. Gtk::Label m_LabelBackupPath;
  46. Gtk::CheckButton m_CheckThemesBackup;
  47. Gtk::CheckButton m_CheckIconsBackup;
  48. Gtk::CheckButton m_CheckWallpapersBackup;
  49. Gtk::CheckButton m_CheckExtensionsBackup;
  50. Gtk::CheckButton m_CheckDconfBackup;
  51. Gtk::Button m_ButtonBackup;
  52. Gtk::Box m_VBoxRestore;
  53. Gtk::Label m_LabelRestoreInstruction;
  54. Gtk::Button m_ButtonSelectVault;
  55. Gtk::Label m_LabelSelectedVault;
  56. Gtk::CheckButton m_CheckThemesRestore;
  57. Gtk::CheckButton m_CheckIconsRestore;
  58. Gtk::CheckButton m_CheckWallpapersRestore;
  59. Gtk::CheckButton m_CheckExtensionsRestore;
  60. Gtk::CheckButton m_CheckDconfRestore;
  61. Gtk::CheckButton m_CheckDryRunRestore;
  62. Gtk::Button m_ButtonRestore;
  63. Glib::Dispatcher m_Dispatcher;
  64. std::mutex m_LogMutex;
  65. std::queue<std::string> m_LogQueue;
  66. std::atomic<bool> m_WorkerRunning;
  67. std::atomic<bool> m_JobSuccess;
  68. std::atomic<bool> m_IsDebugMode;
  69. std::atomic<bool> m_LastJobWasRestore;
  70. std::string m_SelectedVaultPath;
  71. std::string m_TargetBackupPath;
  72. void on_button_select_dest_clicked();
  73. void on_button_backup_clicked();
  74. void on_button_restore_clicked();
  75. void on_button_select_vault_clicked();
  76. void on_dispatcher_ping();
  77. void add_log_ui(const std::string& message);
  78. void set_ui_locked(bool locked);
  79. void queue_log(const std::string& message);
  80. void scan_vault_contents(const std::string& path);
  81. void run_backup_job(JobConfig config, std::string home_dir);
  82. void run_restore_job(JobConfig config, std::string home_dir);
  83. bool create_tar_archive(const std::string& source_dir, const std::string& out_filename, bool strip_path);
  84. bool extract_tar_archive(const std::string& archive_path, const std::string& dest_dir, bool dry_run, bool use_absolute);
  85. std::string get_wallpaper_directory();
  86. void send_notification(const std::string& title, const std::string& body);
  87. };