Browse Source

implement destructors

CPP-GTK4
yggverse 4 months ago
parent
commit
a8df7e1ebe
  1. 11
      src/app/browser.cpp
  2. 2
      src/app/browser.hpp
  3. 30
      src/app/browser/header.cpp
  4. 13
      src/app/browser/header.hpp
  5. 8
      src/app/browser/header/menu.cpp
  6. 8
      src/app/browser/header/menu.hpp
  7. 2
      src/app/browser/header/tab.cpp
  8. 2
      src/app/browser/header/tab.hpp
  9. 11
      src/app/browser/main.cpp
  10. 2
      src/app/browser/main.hpp
  11. 2
      src/app/browser/main/tab.cpp
  12. 2
      src/app/browser/main/tab.hpp

11
src/app/browser.cpp

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

2
src/app/browser.hpp

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

30
src/app/browser/header.cpp

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

13
src/app/browser/header.hpp

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

8
src/app/browser/header/menu.cpp

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

8
src/app/browser/header/menu.hpp

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

2
src/app/browser/header/tab.cpp

@ -12,3 +12,5 @@ Tab::Tab()
ICON ICON
); );
} }
Tab::~Tab() = default;

2
src/app/browser/header/tab.hpp

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

11
src/app/browser/main.cpp

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

2
src/app/browser/main.hpp

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

2
src/app/browser/main/tab.cpp

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

2
src/app/browser/main/tab.hpp

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

Loading…
Cancel
Save