| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #pragma once
- #include <gtkmm.h>
- #include <string>
- #include <fstream>
- #include <thread>
- #include <mutex>
- #include <queue>
- #include <atomic>
- struct JobConfig {
- bool themes;
- bool icons;
- bool wallpapers;
- bool extensions;
- bool dconf;
- bool dry_run;
- };
- class MainWindow : public Gtk::Window {
- public:
- MainWindow();
- virtual ~MainWindow();
- private:
- // Core Layout
- Gtk::HeaderBar m_HeaderBar;
- Gtk::Box m_MainLayout;
- Gtk::Notebook m_Notebook;
-
- // Logging UI
- Gtk::ScrolledWindow m_ScrolledWindow;
- Gtk::TextView m_LogView;
- Glib::RefPtr<Gtk::TextBuffer> m_RefTextBuffer;
- Gtk::Label m_StatusLabel;
- // --- Backup Page Elements ---
- Gtk::Box m_VBoxBackup;
- Gtk::Label m_LabelBackupInstruction;
- Gtk::CheckButton m_CheckThemesBackup;
- Gtk::CheckButton m_CheckIconsBackup;
- Gtk::CheckButton m_CheckWallpapersBackup;
- Gtk::CheckButton m_CheckExtensionsBackup;
- Gtk::CheckButton m_CheckDconfBackup;
- Gtk::Button m_ButtonBackup;
- // --- Restore Page Elements ---
- Gtk::Box m_VBoxRestore;
- Gtk::Label m_LabelRestoreInstruction;
- Gtk::CheckButton m_CheckThemesRestore;
- Gtk::CheckButton m_CheckIconsRestore;
- Gtk::CheckButton m_CheckWallpapersRestore;
- Gtk::CheckButton m_CheckExtensionsRestore;
- Gtk::CheckButton m_CheckDconfRestore;
- Gtk::CheckButton m_CheckDryRunRestore;
- Gtk::Button m_ButtonRestore;
- // --- Threading & Concurrency ---
- Glib::Dispatcher m_Dispatcher;
- std::mutex m_LogMutex;
- std::queue<std::string> m_LogQueue;
- std::atomic<bool> m_WorkerRunning;
- std::ofstream m_LogFile;
- // --- Signal Handlers and Logic ---
- void on_button_backup_clicked();
- void on_button_restore_clicked();
-
- // --- UI Thread Functions ---
- void on_dispatcher_ping();
- void add_log_ui(const std::string& message);
- void set_ui_locked(bool locked);
- // --- Worker Thread Functions ---
- void queue_log(const std::string& message);
- void run_backup_job(JobConfig config, std::string home_dir, std::string wallpaper_dir);
- void run_restore_job(JobConfig config, std::string home_dir);
-
- bool create_tar_archive(const std::string& source_dir, const std::string& out_filename);
- bool extract_tar_archive(const std::string& archive_path, bool dry_run);
- std::string get_wallpaper_directory();
- };
|