Yoda/src/app/browser.cpp

141 lines
3.3 KiB
C++
Raw Normal View History

#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-08-12 14:18:09 +03:00
//const Glib::RefPtr<Gtk::Application> & app,
//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-08-12 19:11:00 +03:00
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-05 16:40:41 +03:00
// Tab actions
2024-08-12 20:24:06 +03:00
add_action(
2024-09-05 16:40:41 +03:00
"main_tab_append",
2024-08-16 19:45:42 +03:00
[this]
{
2024-09-05 16:40:41 +03:00
browserMain->tab_append();
2024-08-16 19:45:42 +03:00
}
2024-08-12 20:24:06 +03:00
);
2024-09-08 03:49:08 +03:00
const auto ACTION__MAIN_TAB_CLOSE = add_action(
2024-09-05 16:40:41 +03:00
"main_tab_close",
2024-08-16 19:45:42 +03:00
[this]
{
2024-09-05 16:40:41 +03:00
browserMain->tab_close();
2024-08-16 19:45:42 +03:00
}
2024-08-12 20:24:06 +03:00
);
add_action(
2024-09-05 16:40:41 +03:00
"main_tab_close_left",
2024-08-16 19:45:42 +03:00
[this]
{
2024-09-05 16:40:41 +03:00
browserMain->tab_close_left();
2024-08-16 19:45:42 +03:00
}
)->set_enabled(
false
2024-08-12 20:24:06 +03:00
);
2024-09-05 02:31:23 +03:00
add_action(
2024-09-05 16:40:41 +03:00
"main_tab_close_right",
2024-09-05 02:31:23 +03:00
[this]
{
2024-09-05 16:40:41 +03:00
browserMain->tab_close_right();
2024-09-05 02:31:23 +03:00
}
)->set_enabled(
false
2024-09-05 02:31:23 +03:00
);
add_action(
2024-09-05 16:40:41 +03:00
"main_tab_close_all",
2024-09-05 02:31:23 +03:00
[this]
{
2024-09-05 16:40:41 +03:00
browserMain->tab_close_all();
2024-09-05 02:31:23 +03:00
}
)->set_enabled(
false
2024-09-05 02:31:23 +03:00
);
2024-09-05 16:40:41 +03:00
// Tab page navigation actions
2024-09-08 04:20:25 +03:00
const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE = add_action(
2024-09-05 16:40:41 +03:00
"main_tab_page_navigation_update",
2024-09-05 23:14:16 +03:00
[this]
2024-09-05 16:40:41 +03:00
{
2024-09-05 22:04:01 +03:00
browserMain->tab_page_navigation_update();
2024-09-05 16:40:41 +03:00
}
2024-08-16 19:45:42 +03:00
);
2024-08-27 15:53:15 +03:00
2024-09-08 07:47:39 +03:00
ACTION__MAIN_TAB_PAGE_NAVIGATION_UPDATE->set_enabled(
false
);
2024-09-08 03:49:08 +03:00
const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_BACK = add_action(
2024-09-05 22:04:01 +03:00
"main_tab_page_navigation_history_back",
2024-09-05 23:14:16 +03:00
[this]
2024-09-05 16:40:41 +03:00
{
2024-09-05 22:04:01 +03:00
browserMain->tab_page_navigation_history_back();
2024-09-05 16:40:41 +03:00
}
2024-08-27 16:39:44 +03:00
);
2024-09-08 03:49:08 +03:00
const auto ACTION__MAIN_TAB_PAGE_NAVIGATION_HISTORY_FORWARD = add_action(
2024-09-05 22:04:01 +03:00
"main_tab_page_navigation_history_forward",
2024-09-05 16:40:41 +03:00
[this]
{
2024-09-05 22:04:01 +03:00
browserMain->tab_page_navigation_history_forward();
2024-09-05 16:40:41 +03:00
}
2024-08-20 16:25:53 +03:00
);
2024-09-08 02:09:54 +03:00
// Init widget
set_title(
_("Yoda")
);
set_default_size(
WIDTH,
HEIGHT
);
// Init header widget
browserHeader = Gtk::make_managed<browser::Header>();
set_titlebar(
* browserHeader
);
// Init main widget
2024-09-08 03:49:08 +03:00
browserMain = Gtk::make_managed<browser::Main>(
ACTION__REFRESH,
ACTION__MAIN_TAB_CLOSE,
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
set_child(
* browserMain
);
2024-08-16 19:45:42 +03:00
}