#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "BookList.hpp" #include "BookShelf.hpp" #include "BookDetails.hpp" #include "TagManagerDialog.hpp" #include "SettingsDialog.hpp" // Forward-declare the hash helper you already have. std::string sha256_file(const std::string& path); /** * @brief Top-level GTK window that wires the data model to the visual shelf. * * BibliothecaWindow owns the high-level widgets (header bar, search UI, * placeholder states) and orchestrates updates coming from @ref BookList. */ class BibliothecaWindow : public Gtk::Window { public: explicit BibliothecaWindow(DatabaseManager& db, BookList& bookList); private: // UI setup helpers void buildHeaderBar(); void buildPlaceholder(); void buildToast(); void buildBatchActionBar(); void showPlaceholderIfEmpty(); void updateVisibleView(); void updateBatchActionBar(); // Toast notification void showToast(const Glib::ustring& message, bool is_error = false); void hideToast(); // Keyboard handling bool onKeyPressed(guint keyval, guint keycode, Gdk::ModifierType state); // Callbacks void onAddBookClicked(); void onBookActivated(const Book& book); void onSearchChanged(); void onSearchToggle(); void onSearchModeChanged(); // Batch operations void onBatchTagClicked(); void onBatchDeleteClicked(); void onBatchSelectAllClicked(); void onBatchClearSelectionClicked(); // Tag management void onManageTagsClicked(); // Settings void onSettingsClicked(); void applySettings(); void onScanLibrary(); // Model (not owned) DatabaseManager& m_db; BookList& m_bookList; // UI Gtk::HeaderBar m_headerBar; Gtk::Button m_addBookButton; Gtk::Button m_backButton; Gtk::Button m_tagsButton; Gtk::Button m_settingsButton; Gtk::ToggleButton m_searchButton; Gtk::Box m_mainBox {Gtk::Orientation::VERTICAL}; Gtk::SearchBar m_searchBar; Gtk::SearchEntry m_searchEntry; Gtk::Overlay m_overlay; Gtk::Stack m_stack; // Toast notification widgets Gtk::Revealer m_toastRevealer; Gtk::Box m_toastBox {Gtk::Orientation::HORIZONTAL}; Gtk::Label m_toastLabel; Gtk::Button m_toastCloseButton; sigc::connection m_toastTimeout; Gtk::Box m_placeholder {Gtk::Orientation::VERTICAL}; Gtk::Image m_placeholderIcon; Gtk::Label m_placeholderLabel; Gtk::Box m_noResults {Gtk::Orientation::VERTICAL}; Gtk::Label m_noResultsLabel; // Owned shelf view std::unique_ptr m_shelf; std::unique_ptr m_bookDetails; std::string m_lastQuery; // Batch action bar widgets Gtk::Revealer m_batchActionRevealer; Gtk::Box m_batchActionBox {Gtk::Orientation::HORIZONTAL}; Gtk::Label m_batchSelectionLabel; Gtk::Button m_batchTagButton; Gtk::Button m_batchDeleteButton; Gtk::Button m_batchSelectAllButton; Gtk::Button m_batchClearButton; // Tag popover for batch tagging Gtk::Popover m_tagPopover; Gtk::Box m_tagPopoverBox {Gtk::Orientation::VERTICAL}; Gtk::Entry m_tagPopoverEntry; Gtk::Button m_tagPopoverApplyButton; // Keyboard controller Glib::RefPtr m_keyController; };