MainWindow.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * GnomeSettingsVault - A GNOME configuration backup utility.
  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. };
  23. class MainWindow : public Gtk::Window {
  24. public:
  25. MainWindow();
  26. virtual ~MainWindow();
  27. private:
  28. Gtk::HeaderBar m_HeaderBar;
  29. Gtk::Box m_MainLayout;
  30. Gtk::Notebook m_Notebook;
  31. Gtk::ScrolledWindow m_ScrolledWindow;
  32. Gtk::TextView m_LogView;
  33. Glib::RefPtr<Gtk::TextBuffer> m_RefTextBuffer;
  34. Gtk::Box m_BottomBox;
  35. Gtk::Label m_StatusLabel;
  36. Gtk::CheckButton m_CheckDebugMode;
  37. Gtk::Box m_VBoxBackup;
  38. Gtk::Label m_LabelBackupInstruction;
  39. Gtk::CheckButton m_CheckThemesBackup;
  40. Gtk::CheckButton m_CheckIconsBackup;
  41. Gtk::CheckButton m_CheckWallpapersBackup;
  42. Gtk::CheckButton m_CheckExtensionsBackup;
  43. Gtk::CheckButton m_CheckDconfBackup;
  44. Gtk::Button m_ButtonBackup;
  45. Gtk::Box m_VBoxRestore;
  46. Gtk::Label m_LabelRestoreInstruction;
  47. Gtk::Button m_ButtonSelectVault;
  48. Gtk::Label m_LabelSelectedVault;
  49. Gtk::CheckButton m_CheckThemesRestore;
  50. Gtk::CheckButton m_CheckIconsRestore;
  51. Gtk::CheckButton m_CheckWallpapersRestore;
  52. Gtk::CheckButton m_CheckExtensionsRestore;
  53. Gtk::CheckButton m_CheckDconfRestore;
  54. Gtk::CheckButton m_CheckDryRunRestore;
  55. Gtk::Button m_ButtonRestore;
  56. Glib::Dispatcher m_Dispatcher;
  57. std::mutex m_LogMutex;
  58. std::queue<std::string> m_LogQueue;
  59. std::atomic<bool> m_WorkerRunning;
  60. std::atomic<bool> m_JobSuccess;
  61. std::atomic<bool> m_IsDebugMode;
  62. std::atomic<bool> m_LastJobWasRestore;
  63. std::string m_SelectedVaultPath;
  64. void on_button_backup_clicked();
  65. void on_button_restore_clicked();
  66. void on_button_select_vault_clicked();
  67. void on_dispatcher_ping();
  68. void add_log_ui(const std::string& message);
  69. void set_ui_locked(bool locked);
  70. void queue_log(const std::string& message);
  71. void scan_vault_contents(const std::string& path);
  72. void run_backup_job(JobConfig config, std::string home_dir);
  73. void run_restore_job(JobConfig config, std::string home_dir);
  74. bool create_tar_archive(const std::string& source_dir, const std::string& out_filename, bool strip_path);
  75. bool extract_tar_archive(const std::string& archive_path, const std::string& dest_dir, bool dry_run, bool use_absolute);
  76. std::string get_wallpaper_directory();
  77. void send_notification(const std::string& title, const std::string& body);
  78. };