2024-08-12 21:35:52 +03:00
|
|
|
#ifndef APP_BROWSER_MAIN_TAB_HPP
|
|
|
|
#define APP_BROWSER_MAIN_TAB_HPP
|
2024-08-10 17:57:15 +03:00
|
|
|
|
2024-09-08 03:49:08 +03:00
|
|
|
#include <giomm/simpleaction.h>
|
2024-08-12 16:12:36 +03:00
|
|
|
#include <glibmm/i18n.h>
|
2024-09-08 03:49:08 +03:00
|
|
|
#include <glibmm/refptr.h>
|
2024-08-20 16:32:20 +03:00
|
|
|
#include <glibmm/ustring.h>
|
2024-08-10 17:57:15 +03:00
|
|
|
#include <gtkmm/notebook.h>
|
2024-09-09 05:06:36 +03:00
|
|
|
#include <sqlite3.h>
|
2024-08-10 17:57:15 +03:00
|
|
|
|
2024-08-11 22:04:34 +03:00
|
|
|
namespace app::browser::main
|
2024-08-10 17:57:15 +03:00
|
|
|
{
|
2024-08-27 16:50:17 +03:00
|
|
|
namespace tab
|
|
|
|
{
|
2024-08-27 17:03:22 +03:00
|
|
|
class Label;
|
2024-08-27 16:50:17 +03:00
|
|
|
class Page;
|
|
|
|
}
|
|
|
|
|
2024-08-13 07:55:23 +03:00
|
|
|
class Tab : public Gtk::Notebook
|
|
|
|
{
|
2024-09-11 00:01:42 +03:00
|
|
|
public:
|
2024-09-09 07:18:49 +03:00
|
|
|
|
2024-09-11 00:48:56 +03:00
|
|
|
/*
|
|
|
|
* Class database
|
|
|
|
*
|
|
|
|
* Allowed parental access to enums and relationship methods
|
|
|
|
*/
|
2024-09-11 00:01:42 +03:00
|
|
|
struct DB
|
2024-09-09 11:08:00 +03:00
|
|
|
{
|
2024-09-11 00:29:47 +03:00
|
|
|
struct APP_BROWSER_MAIN_TAB__SESSION
|
2024-09-11 00:01:42 +03:00
|
|
|
{
|
2024-09-11 00:29:47 +03:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
ID,
|
|
|
|
TIME,
|
|
|
|
PAGE_NUMBER,
|
|
|
|
IS_CURRENT,
|
|
|
|
LABEL_TEXT
|
2024-09-11 00:48:56 +03:00
|
|
|
}; // table fields index
|
2024-09-11 00:29:47 +03:00
|
|
|
|
|
|
|
static int init(
|
|
|
|
sqlite3 * db
|
2024-09-11 00:48:56 +03:00
|
|
|
); // return SQLite status code
|
2024-09-11 00:01:42 +03:00
|
|
|
|
2024-09-11 00:32:30 +03:00
|
|
|
static int clean(
|
2024-09-11 00:29:47 +03:00
|
|
|
sqlite3 * db
|
2024-09-11 00:48:56 +03:00
|
|
|
); // return SQLite status code
|
2024-09-11 00:01:42 +03:00
|
|
|
|
2024-09-11 00:29:47 +03:00
|
|
|
static sqlite3_int64 add(
|
|
|
|
sqlite3 * db,
|
|
|
|
const int & PAGE_NUMBER,
|
|
|
|
const bool & IS_CURRENT,
|
|
|
|
const Glib::ustring & LABEL_TEXT
|
2024-09-11 00:48:56 +03:00
|
|
|
); // return last insert ID
|
2024-09-11 00:01:42 +03:00
|
|
|
|
2024-09-11 00:29:47 +03:00
|
|
|
};
|
2024-09-09 11:08:00 +03:00
|
|
|
};
|
|
|
|
|
2024-09-11 00:48:56 +03:00
|
|
|
/*
|
|
|
|
* Internal members
|
|
|
|
*/
|
2024-09-11 00:01:42 +03:00
|
|
|
private:
|
2024-08-26 22:29:09 +03:00
|
|
|
|
2024-09-11 00:01:42 +03:00
|
|
|
// Database
|
|
|
|
sqlite3 * db;
|
2024-08-27 17:03:22 +03:00
|
|
|
|
2024-09-11 00:01:42 +03:00
|
|
|
// Actions
|
|
|
|
Glib::RefPtr<Gio::SimpleAction> action__refresh,
|
|
|
|
action__tab_close_active,
|
|
|
|
action__tab_close_all,
|
|
|
|
action__tab_page_navigation_history_back,
|
|
|
|
action__tab_page_navigation_history_forward,
|
|
|
|
action__tab_page_navigation_update;
|
2024-08-27 16:50:17 +03:00
|
|
|
|
2024-09-11 00:01:42 +03:00
|
|
|
// Defaults
|
|
|
|
const bool REORDERABLE = true;
|
|
|
|
const bool SCROLLABLE = true;
|
2024-09-08 03:49:08 +03:00
|
|
|
|
2024-09-11 00:48:56 +03:00
|
|
|
/*
|
|
|
|
* Class API
|
|
|
|
*/
|
2024-08-14 07:56:34 +03:00
|
|
|
public:
|
2024-08-13 07:55:23 +03:00
|
|
|
|
2024-09-08 03:49:08 +03:00
|
|
|
Tab(
|
2024-09-09 05:06:36 +03:00
|
|
|
sqlite3 * db,
|
2024-09-08 03:49:08 +03:00
|
|
|
const Glib::RefPtr<Gio::SimpleAction> & ACTION__REFRESH,
|
2024-09-08 17:58:40 +03:00
|
|
|
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_CLOSE_ACTIVE,
|
2024-09-08 18:19:29 +03:00
|
|
|
const Glib::RefPtr<Gio::SimpleAction> & ACTION__MAIN_TAB_CLOSE_ALL,
|
2024-09-08 03:49:08 +03:00
|
|
|
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_BACK,
|
2024-09-08 04:20:25 +03:00
|
|
|
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_HISTORY_FORWARD,
|
|
|
|
const Glib::RefPtr<Gio::SimpleAction> & ACTION__TAB_PAGE_NAVIGATION_UPDATE
|
2024-09-08 03:49:08 +03:00
|
|
|
);
|
2024-08-10 17:57:15 +03:00
|
|
|
|
2024-09-05 02:31:23 +03:00
|
|
|
// Actions
|
2024-09-10 20:37:38 +03:00
|
|
|
int append(
|
|
|
|
const Glib::ustring & LABEL_TEXT,
|
|
|
|
const bool & IS_CURRENT
|
2024-09-05 16:40:41 +03:00
|
|
|
);
|
|
|
|
|
2024-08-12 21:12:08 +03:00
|
|
|
void close(
|
2024-08-27 14:20:47 +03:00
|
|
|
const int & PAGE_NUMBER
|
2024-08-12 21:12:08 +03:00
|
|
|
);
|
|
|
|
|
2024-08-12 20:24:06 +03:00
|
|
|
void close_left();
|
|
|
|
void close_right();
|
|
|
|
void close_all();
|
2024-08-12 17:56:58 +03:00
|
|
|
|
2024-09-05 16:48:28 +03:00
|
|
|
void page_navigation_update(
|
2024-09-05 18:20:47 +03:00
|
|
|
const int & PAGE_NUMBER,
|
2024-09-06 01:58:47 +03:00
|
|
|
const bool & ADD_HISTORY
|
2024-09-05 16:40:41 +03:00
|
|
|
);
|
2024-08-29 03:38:49 +03:00
|
|
|
|
2024-09-05 22:04:01 +03:00
|
|
|
void page_navigation_history_back(
|
2024-09-05 16:48:28 +03:00
|
|
|
const int & PAGE_NUMBER
|
|
|
|
);
|
2024-08-29 03:08:20 +03:00
|
|
|
|
2024-09-05 22:04:01 +03:00
|
|
|
void page_navigation_history_forward(
|
2024-09-05 16:48:28 +03:00
|
|
|
const int & PAGE_NUMBER
|
|
|
|
);
|
2024-09-06 01:45:47 +03:00
|
|
|
|
2024-09-10 20:37:38 +03:00
|
|
|
void refresh(
|
|
|
|
const int & PAGE_NUMBER
|
|
|
|
);
|
|
|
|
|
2024-09-10 03:23:29 +03:00
|
|
|
int restore();
|
|
|
|
|
2024-09-11 00:32:30 +03:00
|
|
|
void clean();
|
2024-09-10 22:15:57 +03:00
|
|
|
|
|
|
|
void save();
|
2024-09-09 23:21:07 +03:00
|
|
|
|
2024-09-06 01:45:47 +03:00
|
|
|
// Getters
|
|
|
|
Glib::ustring get_page_title(
|
|
|
|
const int & PAGE_NUMBER
|
|
|
|
);
|
|
|
|
|
2024-09-10 07:50:15 +03:00
|
|
|
Glib::ustring get_page_description(
|
2024-09-06 01:45:47 +03:00
|
|
|
const int & PAGE_NUMBER
|
|
|
|
);
|
2024-09-11 00:01:42 +03:00
|
|
|
|
|
|
|
tab::Label * get_tabLabel(
|
|
|
|
const int & PAGE_NUMBER
|
|
|
|
);
|
|
|
|
|
|
|
|
tab::Page * get_tabPage(
|
|
|
|
const int & PAGE_NUMBER
|
|
|
|
);
|
2024-08-10 17:57:15 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-08-12 21:35:52 +03:00
|
|
|
#endif // APP_BROWSER_MAIN_TAB_HPP
|