diff --git a/src/app/browser/main.cpp b/src/app/browser/main.cpp index a4a16738..13127eb7 100644 --- a/src/app/browser/main.cpp +++ b/src/app/browser/main.cpp @@ -47,7 +47,10 @@ void Main::refresh() void Main::tab_append() { + const unsigned char * REQUEST; // @TODO + mainTab->append( + REQUEST, true ); }; diff --git a/src/app/browser/main/tab.cpp b/src/app/browser/main/tab.cpp index 6dd8fa8c..9a1db64f 100644 --- a/src/app/browser/main/tab.cpp +++ b/src/app/browser/main/tab.cpp @@ -46,7 +46,44 @@ Tab::Tab( SCROLLABLE ); - // Init event listeners + // Init events + signal_realize().connect( + [this] + { + // Restore session from DB + sqlite3_stmt* statement; + + int prepare = sqlite3_prepare_v3( + this->db, + R"SQL( + SELECT * FROM `app_browser_main_tab` + )SQL", + -1, + SQLITE_PREPARE_NORMALIZE, + &statement, + nullptr + ); + + if (prepare == SQLITE_OK) + { + while (sqlite3_step(statement) == SQLITE_ROW) + { + append( + sqlite3_column_text( + statement, + DB::APP_BROWSER_MAIN_TAB::REQUEST + ), + true + ); + } + } + + sqlite3_finalize( + statement + ); + } + ); + signal_switch_page().connect( [this](Gtk::Widget*, guint) { @@ -54,8 +91,6 @@ Tab::Tab( action__refresh->activate(); } ); - - // @TODO restore session from DB } void Tab::shutdown() @@ -133,6 +168,7 @@ void Tab::refresh( } void Tab::append( + const unsigned char * REQUEST, const bool & FOCUS ) { auto tabPage = new tab::Page( diff --git a/src/app/browser/main/tab.hpp b/src/app/browser/main/tab.hpp index 4fcd9e01..2d52f1cf 100644 --- a/src/app/browser/main/tab.hpp +++ b/src/app/browser/main/tab.hpp @@ -21,6 +21,16 @@ namespace app::browser::main // Database sqlite3 * db; + struct DB + { + enum APP_BROWSER_MAIN_TAB + { + ID, + TIME, + REQUEST, + }; + }; + // Actions Glib::RefPtr action__refresh, action__tab_close_active, @@ -60,6 +70,7 @@ namespace app::browser::main ); void append( + const unsigned char * REQUEST, const bool & FOCUS );