#pragma once #include #include #include #include #include "config.h" #include "rsync_manager.h" #include "snapshot_manager.h" #include "system_tray.h" #include "settings_dialog.h" class MainWindow { public: MainWindow(Config& config); ~MainWindow(); GtkWidget* widget() const { return window_; } void run(); void show(); void hide(); bool is_visible() const; void start_quick_backup(); SystemTray& tray() { return tray_; } private: void build_ui(); void build_menu(); void build_toolbar(); void build_statusbar(); void refresh_snapshot_list(); void browse_path(const std::string& snapshot, const std::string& path); void navigate_up(); void show_sudo_dialog(std::function callback); void open_backup_window(const std::string& description = ""); void close_backup_window(); void append_backup_line(const std::string& line, const char* tag = nullptr); void install_cronjob(); void remove_cronjob(); void show_log_window(); void append_live_log(const std::string& line, const char* tag = nullptr); void load_log_history(); static void on_backup(GtkWidget* w, gpointer d); static void on_restore(GtkWidget* w, gpointer d); static void on_delete_snapshot(GtkWidget* w, gpointer d); static void on_new_backup(GtkWidget* w, gpointer d); static void on_settings(GtkWidget* w, gpointer d); static void on_quit(GtkWidget* w, gpointer d); static void on_about(GtkWidget* w, gpointer d); static void on_show_log(GtkWidget* w, gpointer d); static void on_snapshot_selected(GtkListBox* box, GtkListBoxRow* row, gpointer d); static void on_file_row_activated(GtkTreeView* tree, GtkTreePath* path, GtkTreeViewColumn* col, gpointer d); static gboolean on_file_button_press(GtkWidget* widget, GdkEventButton* event, gpointer d); static void on_navigate_up(GtkWidget* w, gpointer d); static void on_system_backup(GtkWidget* w, gpointer d); static void on_system_restore(GtkWidget* w, gpointer d); static void on_install_cron(GtkWidget* w, gpointer d); static void on_remove_cron(GtkWidget* w, gpointer d); static gboolean on_tray_close(GtkWidget* widget, GdkEvent* event, gpointer d); Config& config_; RsyncManager rsync_; SnapshotManager snapshots_; SystemTray tray_; GtkWidget* window_ = nullptr; GtkWidget* notebook_ = nullptr; GtkWidget* snapshot_listbox_ = nullptr; GtkWidget* file_tree_ = nullptr; GtkWidget* path_entry_ = nullptr; GtkWidget* statusbar_ = nullptr; GtkWidget* nav_label_ = nullptr; GtkListStore* file_store_ = nullptr; GtkWidget* toolbar_ = nullptr; GtkWidget* live_log_textview_ = nullptr; GtkWidget* live_log_label_ = nullptr; GtkWidget* backlog_textview_ = nullptr; GtkWidget* backlog_scrolled_ = nullptr; /* Backup progress window */ GtkWidget* backup_win_ = nullptr; GtkWidget* backup_cmd_label_ = nullptr; GtkWidget* backup_output_view_ = nullptr; GtkWidget* backup_progress_ = nullptr; GtkWidget* backup_status_label_ = nullptr; GtkWidget* backup_time_label_ = nullptr; GtkWidget* backup_size_label_ = nullptr; GtkWidget* backup_cancel_btn_ = nullptr; GtkWidget* backup_close_btn_ = nullptr; std::string log_path_; std::string current_snapshot_; std::string current_path_; std::string current_sudo_password_; std::vector path_stack_; int col_name = 0, col_size = 1, col_type = 2, col_permissions = 3, col_mtime = 4; };