MainWindow.hpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * GnomeSettingsVault - A GNOME configuration backup utility.
  3. * Copyright (C) 2026 Nicole Portas, nicole@equalmass.com
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. */
  10. #pragma once
  11. #include <gtkmm.h>
  12. #include <string>
  13. #include <fstream>
  14. #include <thread>
  15. #include <mutex>
  16. #include <queue>
  17. #include <atomic>
  18. struct JobConfig {
  19. bool themes;
  20. bool icons;
  21. bool wallpapers;
  22. bool extensions;
  23. bool dconf;
  24. bool dry_run;
  25. std::string vault_name;
  26. std::string custom_restore_path;
  27. };
  28. class MainWindow : public Gtk::Window {
  29. public:
  30. MainWindow();
  31. virtual ~MainWindow();
  32. private:
  33. Gtk::HeaderBar m_HeaderBar;
  34. Gtk::Box m_MainLayout;
  35. Gtk::Notebook m_Notebook;
  36. Gtk::ScrolledWindow m_ScrolledWindow;
  37. Gtk::TextView m_LogView;
  38. Glib::RefPtr<Gtk::TextBuffer> m_RefTextBuffer;
  39. Gtk::Box m_BottomBox;
  40. Gtk::Label m_StatusLabel;
  41. Gtk::CheckButton m_CheckDebugMode;
  42. Gtk::Box m_VBoxBackup;
  43. Gtk::Label m_LabelBackupInstruction;
  44. Gtk::CheckButton m_CheckThemesBackup;
  45. Gtk::CheckButton m_CheckIconsBackup;
  46. Gtk::CheckButton m_CheckWallpapersBackup;
  47. Gtk::CheckButton m_CheckExtensionsBackup;
  48. Gtk::CheckButton m_CheckDconfBackup;
  49. Gtk::Button m_ButtonBackup;
  50. Gtk::Box m_VBoxRestore;
  51. Gtk::Label m_LabelRestoreInstruction;
  52. Gtk::Button m_ButtonSelectVault;
  53. Gtk::Label m_LabelSelectedVault;
  54. Gtk::CheckButton m_CheckThemesRestore;
  55. Gtk::CheckButton m_CheckIconsRestore;
  56. Gtk::CheckButton m_CheckWallpapersRestore;
  57. Gtk::CheckButton m_CheckExtensionsRestore;
  58. Gtk::CheckButton m_CheckDconfRestore;
  59. Gtk::CheckButton m_CheckDryRunRestore;
  60. Gtk::Button m_ButtonRestore;
  61. Glib::Dispatcher m_Dispatcher;
  62. std::mutex m_LogMutex;
  63. std::queue<std::string> m_LogQueue;
  64. std::atomic<bool> m_WorkerRunning;
  65. std::atomic<bool> m_JobSuccess;
  66. std::atomic<bool> m_IsDebugMode;
  67. std::atomic<bool> m_LastJobWasRestore;
  68. std::string m_SelectedVaultPath;
  69. void on_button_backup_clicked();
  70. void on_button_restore_clicked();
  71. void on_button_select_vault_clicked();
  72. void on_dispatcher_ping();
  73. void add_log_ui(const std::string& message);
  74. void set_ui_locked(bool locked);
  75. void queue_log(const std::string& message);
  76. void scan_vault_contents(const std::string& path);
  77. void run_backup_job(JobConfig config, std::string home_dir);
  78. void run_restore_job(JobConfig config, std::string home_dir);
  79. bool create_tar_archive(const std::string& source_dir, const std::string& out_filename, bool strip_path);
  80. bool extract_tar_archive(const std::string& archive_path, const std::string& dest_dir, bool dry_run, bool use_absolute);
  81. std::string get_wallpaper_directory();
  82. };