implement destructors

This commit is contained in:
yggverse 2024-08-12 09:45:22 +03:00
parent ee890b9859
commit a8df7e1ebe
12 changed files with 92 additions and 9 deletions

View File

@ -61,6 +61,17 @@ Browser::Browser(
);
}
Browser::~Browser()
{
destroy();
delete header;
header = nullptr;
delete main;
main = nullptr;
}
void Browser::mainTabAppend()
{
main->tabAppend();

View File

@ -35,6 +35,8 @@ namespace app
const lib::Database & db
);
~Browser();
void mainTabAppend();
void debug();

View File

@ -6,15 +6,41 @@ using namespace app::browser;
Header::Header()
{
// Init header bar
set_show_title_buttons(
SHOW_TITLE_BUTTONS
);
pack_start(
* new header::Menu()
);
// Init menu
menu = new header::Menu();
pack_start(
* new header::Tab()
* menu
);
// Init tab
tab = new header::Tab();
pack_start(
* tab
);
}
Header::~Header()
{
// Menu
remove(
* menu
);
delete menu;
menu = nullptr;
// Tab
remove(
* tab
);
delete tab;
tab = nullptr;
}

View File

@ -5,13 +5,26 @@
namespace app::browser
{
namespace header
{
class Menu;
class Tab;
}
class Header : public Gtk::HeaderBar
{
private:
app::browser::header::Menu * menu;
app::browser::header::Tab * tab;
public:
const bool SHOW_TITLE_BUTTONS = true;
Header();
~Header();
};
}

View File

@ -10,7 +10,7 @@ Menu::Menu()
);
// Build tab submenu
auto tab = Gio::Menu::create();
tab = Gio::Menu::create();
tab->append(
_("New tab.."),
@ -18,7 +18,7 @@ Menu::Menu()
);
// Build tool submenu
auto tool = Gio::Menu::create();
tool = Gio::Menu::create();
tool->append(
_("Debug"),
@ -26,7 +26,7 @@ Menu::Menu()
);
// Build main menu
auto main = Gio::Menu::create();
main = Gio::Menu::create();
main->append_submenu(
_("Tab"),
@ -46,4 +46,6 @@ Menu::Menu()
set_menu_model(
main
);
}
}
Menu::~Menu() = default;

View File

@ -9,11 +9,19 @@ namespace app::browser::header
{
class Menu : public Gtk::MenuButton
{
private:
Glib::RefPtr<Gio::Menu> tab,
tool,
main;
public:
const char* TOOLTIP = _("Menu");
Menu();
~Menu();
};
}

View File

@ -11,4 +11,6 @@ Tab::Tab()
set_icon_name(
ICON
);
}
}
Tab::~Tab() = default;

View File

@ -14,6 +14,8 @@ namespace app::browser::header
const char* TOOLTIP = _("New tab");
Tab();
~Tab();
};
}

View File

@ -18,6 +18,17 @@ Main::Main()
);
}
Main::~Main()
{
remove(
* tab
);
delete tab;
tab = nullptr;
}
void Main::tabAppend()
{
tab->append(

View File

@ -20,6 +20,8 @@ namespace app::browser
Main();
~Main();
void tabAppend();
};
}

View File

@ -10,6 +10,8 @@ Tab::Tab()
);
}
Tab::~Tab() = default;
void Tab::append(
const char * request,
bool open,

View File

@ -28,6 +28,8 @@ namespace app::browser::main
Tab();
~Tab();
void append(
const char * request,
bool open,