Yoda/src/app/browser.cpp

135 lines
2.2 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-08-11 22:04:34 +03:00
// Init window
2024-08-08 12:44:27 +03:00
set_title(
2024-08-12 21:30:30 +03:00
_("Yoda")
2024-08-08 12:44:27 +03:00
);
set_default_size(
2024-08-24 19:06:42 +03:00
WIDTH,
HEIGHT
2024-08-08 12:44:27 +03:00
);
2024-08-08 15:19:04 +03:00
2024-08-11 22:04:34 +03:00
// Init header widget
2024-08-27 15:46:57 +03:00
browserHeader = new browser::Header();
2024-08-11 22:04:34 +03:00
2024-08-08 15:19:04 +03:00
set_titlebar(
2024-08-27 15:46:57 +03:00
* browserHeader
2024-08-11 22:04:34 +03:00
);
// Init main widget
2024-08-27 15:46:57 +03:00
browserMain = new browser::Main();
2024-08-11 22:04:34 +03:00
set_child(
2024-08-27 15:46:57 +03:00
* browserMain
2024-08-11 22:04:34 +03:00
);
// Init actions
add_action(
2024-08-12 18:12:01 +03:00
"tab_append",
2024-08-16 19:45:42 +03:00
[this]
{
2024-08-27 15:46:57 +03:00
browserMain->tab_append();
2024-08-16 19:45:42 +03:00
}
2024-08-08 13:33:23 +03:00
);
2024-08-11 09:55:10 +03:00
2024-08-14 07:11:24 +03:00
add_action(
"tab_update",
2024-08-16 19:45:42 +03:00
[this]
{
2024-08-27 15:46:57 +03:00
browserMain->tab_update();
2024-08-16 19:45:42 +03:00
}
2024-08-14 07:11:24 +03:00
);
2024-08-12 20:24:06 +03:00
// Close
2024-08-12 19:11:00 +03:00
add_action(
"tab_close",
2024-08-16 19:45:42 +03:00
[this]
{
2024-08-27 15:46:57 +03:00
browserMain->tab_close();
2024-08-16 19:45:42 +03:00
}
2024-08-12 19:11:00 +03:00
);
2024-08-12 20:24:06 +03:00
// Close submenu
add_action(
"tab_close_left",
2024-08-16 19:45:42 +03:00
[this]
{
2024-08-27 15:46:57 +03:00
browserMain->tab_close_left();
2024-08-16 19:45:42 +03:00
}
2024-08-12 20:24:06 +03:00
);
add_action(
"tab_close_right",
2024-08-16 19:45:42 +03:00
[this]
{
2024-08-27 15:46:57 +03:00
browserMain->tab_close_right();
2024-08-16 19:45:42 +03:00
}
2024-08-12 20:24:06 +03:00
);
add_action(
"tab_close_all",
2024-08-16 19:45:42 +03:00
[this]
{
2024-08-27 15:46:57 +03:00
browserMain->tab_close_all();
2024-08-16 19:45:42 +03:00
}
2024-08-12 20:24:06 +03:00
);
// Tool
2024-08-11 09:55:10 +03:00
add_action(
"debug",
2024-08-16 19:45:42 +03:00
[this]
{
gtk_window_set_interactive_debugging(
true
);
}
2024-08-11 09:55:10 +03:00
);
2024-08-20 16:25:53 +03:00
// Hidden
add_action(
"refresh",
[this]
{
2024-08-27 15:53:15 +03:00
browserMain->refresh();
2024-08-27 15:46:57 +03:00
browserHeader->set_title(
2024-08-27 16:39:44 +03:00
browserMain->get_current_tab_page_title()
);
browserHeader->set_subtitle(
browserMain->get_current_tab_page_subtitle()
2024-08-20 16:25:53 +03:00
);
}
);
2024-08-29 02:45:46 +03:00
add_action(
"tab_history_back",
[this]
{
// @TODO
}
);
add_action(
"tab_history_forward",
[this]
{
// @TODO
}
);
2024-08-11 09:55:10 +03:00
}
2024-08-12 09:45:22 +03:00
Browser::~Browser()
{
2024-08-27 15:46:57 +03:00
delete browserHeader;
delete browserMain;
2024-08-16 19:45:42 +03:00
}