feat: x3-backup v1.0.0 initial release

GTK3 backup/snapshot tool using rsync backend.

Features:
- rsync-based snapshots with hardlink delta for space efficiency
- Snapshot sidebar with date-sorted list
- Full file browser with permissions display (name, size, perms, mtime)
- Right-click context menu: Restore file/dir with sudo prompt
- System tray icon: backup status, context menu (show/backup/settings/quit)
- Menu system: File, Backup, System, Help
- Settings dialog: backup destination, source path, retention, exclusions
- Cronjob management: install/remove scheduled backups
- Live Log tab: real-time rsync output during backup
- History Log tab: full log file viewer with color-coded entries
- System Backup mode: full root filesystem backup
- System Restore mode: restore entire system from snapshot
- CLI mode: --backup, --system-backup for cron/headless use
- /mnt always excluded from backups
- Preserves permissions, ACLs, xattrs (-aAX flags)
- Log file: ~/.config/x3-backup/x3-backup.log
- Config: ~/.config/x3-backup/settings.json
- uninstall.sh for clean removal
This commit is contained in:
x3
2026-09-07 17:20:41 +00:00
commit c8ef700612
20 changed files with 2535 additions and 0 deletions
+106
View File
@@ -0,0 +1,106 @@
#pragma once
#include <gtk/gtk.h>
#include <string>
#include <vector>
#include <fstream>
#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_sidebar();
void build_file_browser();
void build_statusbar();
void refresh_snapshot_list();
void load_selected_snapshot();
void browse_path(const std::string& snapshot, const std::string& path);
void navigate_up();
void on_backup_clicked();
void on_restore_clicked();
void on_delete_snapshot_clicked();
void on_new_backup_clicked();
void show_sudo_dialog(std::function<void(const std::string&)> callback);
void show_progress_dialog(const std::string& title);
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* progress_bar_ = nullptr;
GtkWidget* progress_label_ = nullptr;
GtkWidget* progress_window_ = nullptr;
GtkWidget* nav_label_ = nullptr;
GtkListStore* file_store_ = nullptr;
GtkWidget* toolbar_ = nullptr;
GtkWidget* log_window_ = nullptr;
GtkWidget* log_textview_ = nullptr;
guint log_timer_ = 0;
GtkWidget* live_log_textview_ = nullptr;
GtkWidget* live_log_label_ = nullptr;
GtkWidget* backlog_textview_ = nullptr;
GtkWidget* backlog_scrolled_ = nullptr;
std::string log_path_;
std::string current_snapshot_;
std::string current_path_;
std::vector<std::string> path_stack_;
int col_name = 0, col_size = 1, col_type = 2, col_permissions = 3, col_mtime = 4;
};