from typing import TYPE_CHECKING
from logic import actions

if TYPE_CHECKING:
    from gui.ui_library import Ui_Library

class Ui_Initialization:
    def __init__(self, ui: Ui_Library):
        self.ui = ui
    
    def connect_button(self):
        self.ui.save_btn.clicked.connect(self.ui.record_book)
        self.ui.delete_btn.clicked.connect(self.ui.delete_book)
        self.ui.change_list_signal.connect(self.ui.refresh_title_list)

        self.ui.search_input.textChanged.connect(self.ui.search_book)

    def fulfill_list(self):
        self.ui.title_list.addItems(actions.list_titles())
