2024-08-10 17:57:15 +03:00
|
|
|
#include "browser.hpp"
|
|
|
|
#include "browser/header.hpp"
|
2024-08-11 22:04:34 +03:00
|
|
|
#include "browser/main.hpp"
|
2024-08-05 03:15:41 +03:00
|
|
|
|
2024-08-08 12:44:27 +03:00
|
|
|
using namespace app;
|
2024-08-05 03:15:41 +03:00
|
|
|
|
2024-08-11 09:55:10 +03:00
|
|
|
Browser::Browser(
|
2024-09-08 08:15:17 +03:00
|
|
|
const Glib::RefPtr<Gtk::Application> & APP
|
2024-08-12 14:18:09 +03:00
|
|
|
//const std::shared_ptr<lib::Database> & db
|
2024-08-11 09:55:10 +03:00
|
|
|
) {
|
2024-09-08 02:09:54 +03:00
|
|
|
// Init window actions
|
2024-09-08 03:49:08 +03:00
|
|
|
const auto ACTION__REFRESH = add_action(
|
2024-09-05 16:40:41 +03:00
|
|
|
"refresh",
|
2024-08-16 19:45:42 +03:00
|
|
|
[this]
|
|
|
|
{
|
2024-09-05 16:40:41 +03:00
|
|
|
browserMain->refresh();
|
2024-08-11 09:55:10 +03:00
|
|
|
|
2024-09-08 07:47:39 +03:00
|
|
|
browserHeader->refresh(
|
|
|
|
browserMain->get_current_tab_page_title(),
|
2024-09-05 16:40:41 +03:00
|
|
|
browserMain->get_current_tab_page_subtitle()
|
|
|
|
);
|
2024-08-16 19:45:42 +03:00
|
|
|
}
|
2024-08-14 07:11:24 +03:00
|
|
|
);
|
|
|
|
|
2024-09-08 17:48:19 +03:00
|
|
|
const auto ACTION__DEBUG = add_action(
|
2024-09-05 16:40:41 +03:00
|
|
|
"debug",
|
2024-08-16 19:45:42 +03:00
|
|
|
[this]
|
|
|
|
{
|
2024-09-05 16:40:41 +03:00
|
|
|
// @TODO https://gitlab.gnome.org/GNOME/gtkmm/-/commit/5f3b82537d3daad7bda59dd01e719788070f4b6c
|
|
|
|
gtk_window_set_interactive_debugging(
|
|
|
|
true
|
|
|
|
);
|
2024-08-16 19:45:42 +03:00
|
|
|
}
|
2024-08-12 19:11:00 +03:00
|
|
|
);
|
|
|
|
|
2024-09-08 08:15:17 +03:00
|
|
|
APP->set_accel_for_action(
|
|
|
|
"win.debug",
|
|
|
|
"<Primary>i"
|
2024-08-12 20:24:06 +03:00
|
|
|
);
|
|
|
|
|
2024-09-08 17:48:19 +03:00
|
|
|
const auto ACTION__MAIN_TAB_APPEND = add_action(
|
2024-09-08 08:15:17 +03:00
|
|
|
"main_tab_append",
|
|
|
|
[this]
|
|
|
|
{
|
|
|
|
browserMain->tab_append();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
APP->set_accel_for_action(
|
|
|
|
"win.main_tab_append",
|
|
|
|
"<Primary>t"
|
2024-08-12 20:24:06 +03:00
|
|
|
);
|
|
|
|
|
2024-09-08 17:58:40 +03:00
|
|
|
const auto ACTION__MAIN_TAB_CLOSE_ACTIVE = add_action(
|
|
|
|
"main_tab_close_active",
|
2024-09-08 08:15:17 +03:00
|
|
|
[this]
|
|
|
|
{
|
|
|
|
browserMain->tab_close();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2024-09-08 18:08:54 +03:00
|
|
|
ACTION__MAIN_TAB_CLOSE_ACTIVE->set_enabled(
|
|
|
|
false
|
|
|
|
);
|
|
|
|
|
|
|
|
APP->set_accel_for_action(
|
|
|
|
"win.main_tab_close_active",
|
|
|
|
"<Primary>Escape"
|
|
|
|
);
|
|
|
|
|
2024-09-08 08:15:17 +03:00
|
|
|
add_action(
|
|
|
|
"main_tab_close_left",
|
|
|
|
[this]
|
|
|
|
{
|
|
|
|
browserMain->tab_close_left();
|
|
|
|
}
|
|
|
|
)->set_enabled(
|
|
|
|
false
|
|
|
|
);
|
|
|
|
|
|
|
|
add_action(
|
|
|
|
"main_tab_close_right",
|
|
|
|
[this]
|
|
|
|
{
|
|
|
|
browserMain->tab_close_right();
|
|
|
|
}
|
|
|
|
)->set_enabled(
|
|
|
|
false
|
|
|
|
);
|
|
|
|
|
2024-09-08 17:58:40 +03:00
|
|
|
const auto ACTION__MAIN_TAB_CLOSE_ALL = add_action(
|
2024-09-08 08:15:17 +03:00
|
|
|
"main_tab_close_all",
|
|
|
|
[this]
|
|
|
|
{
|
|
|
|
browserMain->tab_close_all();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2024-09-08 17:58:40 +03:00
|
|
|
ACTION__MAIN_TAB_CLOSE_ALL->set_enabled(
|
|
|
|
false
|
|
|
|
);
|
|
|
|
|
2024-09-08 08:18:23 +03:00
|
|
|
const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE = add_action(
|
|
|
|
"main_tab_page_navigation_update",
|
|
|
|
[this]
|
|
|
|
{
|
|
|
|
browserMain->tab_page_navigation_update();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE->set_enabled(
|
|
|
|
false
|
2024-08-12 20:24:06 +03:00
|
|
|
);
|
|
|
|
|
2024-09-08 08:18:23 +03:00
|
|
|
APP->set_accel_for_action(
|
|
|
|
"win.main_tab_page_navigation_update",
|
|
|
|
"<Primary>r"
|
|
|
|
);
|
2024-09-08 08:15:17 +03:00
|
|
|
|
2024-09-08 08:18:23 +03:00
|
|
|
const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK = add_action(
|
|
|
|
"main_tab_page_navigation_history_back",
|
|
|
|
[this]
|
|
|
|
{
|
|
|
|
browserMain->tab_page_navigation_history_back();
|
|
|
|
}
|
|
|
|
);
|
2024-09-08 08:15:17 +03:00
|
|
|
|
2024-09-08 08:18:23 +03:00
|
|
|
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK->set_enabled(
|
|
|
|
false
|
2024-09-05 02:31:23 +03:00
|
|
|
);
|
|
|
|
|
2024-09-08 08:18:23 +03:00
|
|
|
APP->set_accel_for_action(
|
|
|
|
"win.main_tab_page_navigation_history_back",
|
|
|
|
"<Primary>Left"
|
|
|
|
);
|
2024-09-08 08:15:17 +03:00
|
|
|
|
2024-09-08 08:18:23 +03:00
|
|
|
const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD = add_action(
|
|
|
|
"main_tab_page_navigation_history_forward",
|
|
|
|
[this]
|
|
|
|
{
|
|
|
|
browserMain->tab_page_navigation_history_forward();
|
|
|
|
}
|
|
|
|
);
|
2024-09-08 08:15:17 +03:00
|
|
|
|
2024-09-08 08:18:23 +03:00
|
|
|
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD->set_enabled(
|
|
|
|
false
|
2024-09-05 02:31:23 +03:00
|
|
|
);
|
|
|
|
|
2024-09-08 08:18:23 +03:00
|
|
|
APP->set_accel_for_action(
|
|
|
|
"win.main_tab_page_navigation_history_forward",
|
|
|
|
"<Primary>Right"
|
|
|
|
);
|
2024-09-08 02:09:54 +03:00
|
|
|
|
|
|
|
// Init widget
|
|
|
|
set_title(
|
|
|
|
_("Yoda")
|
|
|
|
);
|
|
|
|
|
|
|
|
set_default_size(
|
|
|
|
WIDTH,
|
|
|
|
HEIGHT
|
|
|
|
);
|
|
|
|
|
2024-09-08 08:18:23 +03:00
|
|
|
// Init components
|
2024-09-08 17:48:19 +03:00
|
|
|
browserHeader = Gtk::make_managed<browser::Header>(
|
|
|
|
ACTION__DEBUG,
|
|
|
|
ACTION__MAIN_TAB_APPEND,
|
2024-09-08 17:58:40 +03:00
|
|
|
ACTION__MAIN_TAB_CLOSE_ACTIVE,
|
|
|
|
ACTION__MAIN_TAB_CLOSE_ALL,
|
2024-09-08 17:48:19 +03:00
|
|
|
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK,
|
|
|
|
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD,
|
|
|
|
ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
|
|
|
|
);
|
2024-09-08 02:09:54 +03:00
|
|
|
|
2024-09-08 08:18:23 +03:00
|
|
|
set_titlebar(
|
|
|
|
* browserHeader
|
|
|
|
);
|
2024-09-08 02:09:54 +03:00
|
|
|
|
2024-09-08 03:49:08 +03:00
|
|
|
browserMain = Gtk::make_managed<browser::Main>(
|
|
|
|
ACTION__REFRESH,
|
2024-09-08 17:58:40 +03:00
|
|
|
ACTION__MAIN_TAB_CLOSE_ACTIVE,
|
2024-09-08 18:19:29 +03:00
|
|
|
ACTION__MAIN_TAB_CLOSE_ALL,
|
2024-09-08 03:49:08 +03:00
|
|
|
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK,
|
2024-09-08 04:20:25 +03:00
|
|
|
ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD,
|
|
|
|
ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE
|
2024-09-08 03:49:08 +03:00
|
|
|
);
|
2024-09-08 02:09:54 +03:00
|
|
|
|
2024-09-08 08:18:23 +03:00
|
|
|
set_child(
|
|
|
|
* browserMain
|
|
|
|
);
|
2024-08-16 19:45:42 +03:00
|
|
|
}
|