mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
restore previous tab session on browser launch
This commit is contained in:
parent
9b13d3f270
commit
eaa4b78dbd
3 changed files with 53 additions and 3 deletions
|
|
@ -47,7 +47,10 @@ void Main::refresh()
|
||||||
|
|
||||||
void Main::tab_append()
|
void Main::tab_append()
|
||||||
{
|
{
|
||||||
|
const unsigned char * REQUEST; // @TODO
|
||||||
|
|
||||||
mainTab->append(
|
mainTab->append(
|
||||||
|
REQUEST,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,44 @@ Tab::Tab(
|
||||||
SCROLLABLE
|
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(
|
signal_switch_page().connect(
|
||||||
[this](Gtk::Widget*, guint)
|
[this](Gtk::Widget*, guint)
|
||||||
{
|
{
|
||||||
|
|
@ -54,8 +91,6 @@ Tab::Tab(
|
||||||
action__refresh->activate();
|
action__refresh->activate();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// @TODO restore session from DB
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tab::shutdown()
|
void Tab::shutdown()
|
||||||
|
|
@ -133,6 +168,7 @@ void Tab::refresh(
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tab::append(
|
void Tab::append(
|
||||||
|
const unsigned char * REQUEST,
|
||||||
const bool & FOCUS
|
const bool & FOCUS
|
||||||
) {
|
) {
|
||||||
auto tabPage = new tab::Page(
|
auto tabPage = new tab::Page(
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,16 @@ namespace app::browser::main
|
||||||
// Database
|
// Database
|
||||||
sqlite3 * db;
|
sqlite3 * db;
|
||||||
|
|
||||||
|
struct DB
|
||||||
|
{
|
||||||
|
enum APP_BROWSER_MAIN_TAB
|
||||||
|
{
|
||||||
|
ID,
|
||||||
|
TIME,
|
||||||
|
REQUEST,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
Glib::RefPtr<Gio::SimpleAction> action__refresh,
|
Glib::RefPtr<Gio::SimpleAction> action__refresh,
|
||||||
action__tab_close_active,
|
action__tab_close_active,
|
||||||
|
|
@ -60,6 +70,7 @@ namespace app::browser::main
|
||||||
);
|
);
|
||||||
|
|
||||||
void append(
|
void append(
|
||||||
|
const unsigned char * REQUEST,
|
||||||
const bool & FOCUS
|
const bool & FOCUS
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue