1. Overview
The main_window.hpp file implements the primary GTK workflow for source selection, scanning, recovery and reporting.
This is an interface and data-contract file. It declares the public and internal types used by this subsystem, allowing implementation files and callers to share a stable compile-time contract.
Its paired source or interface file is main_window.cpp.
Primary responsibilities:
- Build dashboard, recovery wizard and about views
- Enumerate devices and select sources
- Start background scan and recovery workers
- Display progress, logs and results
- Persist language and theme preferences
2. File Identity and Scope
- Source path:
src/main_window.hpp - Language: C++
- File role: interface and data-contract file
- Physical lines: 189
- Non-empty lines: 159
- SHA-256:
b40de08b1132f6392b2d15b49d0ddb08ef367bc1f9f8cf60be46966c3620067f
The declarations in this file use the global namespace.
3. Dependencies
3.1 Project Headers
device_enumerator.hppmodels.hpprecovery_worker.hppscan_worker.hpp
3.2 Standard and External Headers
gtkmm.hgiomm.hchronocstdintstringvector
These dependencies define the file’s compile-time integration with the recovery engine, GTK interface, on-disk format decoders, operating-system services, or C++ standard library.
4. Declared Types
- class
MainWindowderives from or specifiespublic Gtk::Window. - enum class
ThemeMode. - enum class
WizardStep.
4.1 Enumeration Values
ThemeMode defines:
DarkLight
WizardStep defines:
SourceDestinationScanRecover
5. Constants and Configuration Values
No preprocessor or compile-time constants were detected as top-level declarations in this file.
6. Data Members and Persistent State
The interface declares the following state-bearing members:
ThemeMode current_theme_=ThemeMode::DarkWizardStep current_step_=WizardStep::SourceGlib::RefPtr<Gtk::CssProvider> css_provider_Gtk::Box main_box_{Gtk::Orientation::HORIZONTAL,0}Gtk::Stack page_stack_Gtk::Box sidebar_{Gtk::Orientation::VERTICAL,10}Gtk::Box dashboard_page_{Gtk::Orientation::VERTICAL,16}Gtk::Box recovery_page_{Gtk::Orientation::VERTICAL,16}Gtk::Box about_page_{Gtk::Orientation::VERTICAL,24}Gtk::Grid cards_grid_Gtk::Frame card_status_Gtk::Frame card_source_Gtk::Frame card_update_Gtk::Label status_card_label_Gtk::Label source_card_label_Gtk::Label update_card_label_Gtk::Frame devices_frame_Gtk::ScrolledWindow devices_scroller_Gtk::ListBox devices_list_Gtk::Label brand_label_Gtk::Button btn_dashboard_Gtk::Button btn_recovery_Gtk::Button btn_about_Gtk::Button btn_refresh_Gtk::Button btn_theme_dark_Gtk::Button btn_theme_light_Gtk::Button*dashboard_button_=nullptrGtk::Button*recovery_button_=nullptrGtk::Button*about_button_=nullptrstd::vector<Gtk::Button*> sidebar_buttons_Gtk::DropDown lang_combo_bool lang_changing_=falseGtk::Box recovery_header_{Gtk::Orientation::VERTICAL,8}Gtk::Label recovery_title_Gtk::Label recovery_subtitle_Gtk::Frame wizard_frame_Gtk::Box wizard_root_{Gtk::Orientation::VERTICAL,12}Gtk::Stack wizard_stack_Gtk::Box wizard_nav_{Gtk::Orientation::HORIZONTAL,8}Gtk::Button btn_wizard_back_Gtk::Button btn_wizard_next_Gtk::Label wizard_notice_label_Gtk::Box source_step_box_{Gtk::Orientation::VERTICAL,8}Gtk::Label source_step_label_Gtk::Box source_button_row_{Gtk::Orientation::HORIZONTAL,8}Gtk::Button btn_open_image_Gtk::Button btn_use_selected_device_Gtk::Button btn_launch_elevated_Gtk::ScrolledWindow recovery_devices_scroller_Gtk::ListBox recovery_devices_list_Gtk::Box destination_step_box_{Gtk::Orientation::VERTICAL,8}Gtk::Label destination_step_label_Gtk::Box destination_button_row_{Gtk::Orientation::HORIZONTAL,8}Gtk::Entry entry_output_Gtk::Button btn_choose_destination_Gtk::Box scan_step_box_{Gtk::Orientation::VERTICAL,8}Gtk::Label scan_step_label_Gtk::ProgressBar scan_progress_bar_Gtk::Label scan_status_label_Gtk::Label scan_timer_label_Gtk::Button btn_scan_now_Gtk::Box recover_step_box_{Gtk::Orientation::VERTICAL,8}Gtk::Label recover_step_label_Gtk::Frame results_frame_Gtk::ScrolledWindow results_scroller_Gtk::Box results_tree_box_{Gtk::Orientation::VERTICAL,8}Gtk::Label results_count_label_Gtk::Label results_selected_label_Gtk::Box results_actions_row_{Gtk::Orientation::HORIZONTAL,8}Gtk::Button btn_results_select_all_Gtk::Button btn_results_clear_Gtk::Button btn_recover_now_Gtk::ScrolledWindow log_scroller_Gtk::TextView log_view_Glib::RefPtr<Gtk::TextBuffer> log_buffer_Glib::RefPtr<Gtk::FileDialog> file_dialog_Glib::RefPtr<Gtk::FileDialog> folder_dialog_std::vector<DeviceInfo> devices_std::string selected_source_path_std::string selected_source_label_std::string output_dir_ScanReport last_report_std::vector<bool> result_selection_std::vector<Gtk::CheckButton*> result_check_buttons_ScanWorker scan_worker_RecoveryWorker recovery_worker_ScanProgress last_scan_progress_sigc::connection scan_timer_connection_std::chrono::steady_clock::time_point scan_started_at_{}
These members hold configuration, parser context, UI widgets, source references, progress state, recovered metadata, or temporary resources according to the owning type.
7. API and Function Inventory
The following callable interfaces or definitions were detected:
~MainWindow()override– Destroys the object and releases resources owned by the instance.void build_headerbar()– Constructs the requested object, data structure or user-interface component.void build_sidebar()– Constructs the requested object, data structure or user-interface component.void build_dashboard()– Constructs the requested object, data structure or user-interface component.void build_recovery_page()– Constructs the requested object, data structure or user-interface component.void build_wizard()– Constructs the requested object, data structure or user-interface component.void build_about_page()– Constructs the requested object, data structure or user-interface component.void update_action_controls()– Refreshes the related state or presentation from current data.void apply_theme(ThemeMode mode)– Implements the operation identified by this API and updates or returns the associated state.void apply_inline_css()– Implements the operation identified by this API and updates or returns the associated state.void update_theme_buttons()– Refreshes the related state or presentation from current data.void activate_sidebar_button(Gtk::Button*button)– Implements the operation identified by this API and updates or returns the associated state.void refresh_devices()– Refreshes the related state or presentation from current data.void populate_device_lists()– Refreshes the related state or presentation from current data.void select_source(const std::string&path,const std::string&label)– Implements the operation identified by this API and updates or returns the associated state.void update_source_state()– Refreshes the related state or presentation from current data.void update_wizard_step()– Refreshes the related state or presentation from current data.void append_log(const std::string&line)– Updates the relevant collection or range state.void on_sidebar_dashboard()– Handles the related event, callback or user action.void on_sidebar_recovery()– Handles the related event, callback or user action.void on_sidebar_about()– Handles the related event, callback or user action.void on_refresh_devices()– Handles the related event, callback or user action.void on_language_changed()– Handles the related event, callback or user action.void on_open_image()– Handles the related event, callback or user action.void on_choose_destination()– Handles the related event, callback or user action.void on_use_selected_device()– Handles the related event, callback or user action.void on_dashboard_device_activated(Gtk::ListBoxRow*row)– Handles the related event, callback or user action.void on_recovery_device_activated(Gtk::ListBoxRow*row)– Handles the related event, callback or user action.void on_theme_dark()– Handles the related event, callback or user action.void on_theme_light()– Handles the related event, callback or user action.void on_wizard_back()– Handles the related event, callback or user action.void on_wizard_next()– Handles the related event, callback or user action.void on_scan_now()– Handles the related event, callback or user action.void on_recover_now()– Handles the related event, callback or user action.void on_launch_elevated()– Handles the related event, callback or user action.void on_scan_progress(const ScanProgress&progress)– Handles the related event, callback or user action.void on_scan_completed(const ScanReport&report)– Handles the related event, callback or user action.void on_recovery_completed(const RecoveryResult&result)– Handles the related event, callback or user action.void populate_scan_results(const ScanReport&report)– Refreshes the related state or presentation from current data.void update_selected_results_state()– Refreshes the related state or presentation from current data.std::vector<size_t> selected_result_indices()const– Implements the operation identified by this API and updates or returns the associated state.void set_all_results_selected(bool selected)– Persists or exports the supplied state to the relevant destination.static std::string result_group_label(const ScanResult&result)– Implements the operation identified by this API and updates or returns the associated state.static std::string result_subgroup_label(const ScanResult&result)– Implements the operation identified by this API and updates or returns the associated state.void minimize_window()– Implements the operation identified by this API and updates or returns the associated state.void hide_window()– Implements the operation identified by this API and updates or returns the associated state.static std::string human_size(uint64_t bytes)– Implements the operation identified by this API and updates or returns the associated state.static std::string read_language()– Reads or derives the requested information and returns or stores the decoded result.static void save_language(const std::string&lang_code)– Persists or exports the supplied state to the relevant destination.static std::string read_theme()– Reads or derives the requested information and returns or stores the decoded result.static void save_theme(const std::string&theme_code)– Persists or exports the supplied state to the relevant destination.
8. Operational Flow
The subsystem represented by this file normally participates in the following flow:
- Build dashboard, recovery wizard and about views.
- Enumerate devices and select sources.
- Start background scan and recovery workers.
- Display progress, logs and results.
- Persist language and theme preferences.
- Expose or execute the detected APIs:
~MainWindow, build_headerbar, build_sidebar, build_dashboard, build_recovery_page, build_wizard, build_about_page, update_action_controls, apply_theme, apply_inline_css, update_theme_buttons, activate_sidebar_button, refresh_devices, populate_device_lists, select_source, update_source_state, update_wizard_step, append_logand additional helpers. - Return explicit results, progress data, recovered records, or diagnostics to the calling layer.
9. Validation and Error Handling
- Byte offsets, sizes and lengths must be validated before arithmetic and before every read to avoid overflow and out-of-bounds access.
- Input and output paths require existence checks, permission handling and safe destination construction.
10. Runtime, Concurrency, and Resource Management
- GTK lifecycle: widget ownership, signal connections and main-thread affinity must be preserved.
- GTK objects and callbacks must obey main-thread affinity and signal lifetime rules.
11. Security and Data-Recovery Considerations
- Recovery code should prefer read-only source access and avoid writing to the original damaged medium.
- Raw devices and image files are treated as untrusted binary input; every offset and length must remain bounded by the source size.
- Recovered names and destination paths must be sanitized to prevent directory traversal and accidental overwrite outside the selected export directory.
12. Implementation Considerations
- Changes to public declarations can affect every translation unit that includes this header and should preserve binary and source compatibility where required.
- State-bearing members should have explicit ownership and initialization semantics, especially for references, pointers, file descriptors and GTK widgets.
- Large-device arithmetic uses 64-bit values; additions and multiplications should be checked before use as offsets or allocation sizes.
13. Integration with the Recovery Pipeline
- The file belongs to the application startup or presentation layer.
- It receives or presents data produced by scan and recovery services.
- Long-running operations should remain delegated to worker classes rather than blocking the GTK main loop.
14. Licensing and Provenance
No explicit copyright or software-license statement was detected in the opening section of this individual file. Distribution terms should therefore be verified against the project-level license and repository metadata.
The SHA-256 value in this document can be used to associate the generated documentation with the exact source version analyzed.
