From 02b0b42b6b03f707242f461b0bea8bb4be16d16c Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 2 Sep 2024 16:25:31 +0300 Subject: [PATCH] make children widgets managed --- src/app/browser.cpp | 10 ++-------- src/app/browser.hpp | 3 +-- src/app/browser/header.cpp | 13 +++---------- src/app/browser/header.hpp | 3 +-- src/app/browser/header/main.cpp | 10 ++-------- src/app/browser/header/main.hpp | 3 +-- src/app/browser/main.cpp | 7 +------ src/app/browser/main.hpp | 2 +- src/app/browser/main/tab/page.cpp | 13 +++---------- src/app/browser/main/tab/page.hpp | 3 +-- src/app/browser/main/tab/page/navbar.cpp | 19 +++++-------------- src/app/browser/main/tab/page/navbar.hpp | 3 +-- .../browser/main/tab/page/navbar/history.cpp | 10 ++-------- .../browser/main/tab/page/navbar/history.hpp | 3 +-- 14 files changed, 25 insertions(+), 77 deletions(-) diff --git a/src/app/browser.cpp b/src/app/browser.cpp index 34669d75..362ee4c6 100644 --- a/src/app/browser.cpp +++ b/src/app/browser.cpp @@ -19,14 +19,14 @@ Browser::Browser( ); // Init header widget - browserHeader = new browser::Header(); + browserHeader = Gtk::make_managed(); set_titlebar( * browserHeader ); // Init main widget - browserMain = new browser::Main(); + browserMain = Gtk::make_managed(); set_child( * browserMain @@ -127,10 +127,4 @@ Browser::Browser( browserMain->tab_history_forward(); } ); -} - -Browser::~Browser() -{ - delete browserHeader; - delete browserMain; } \ No newline at end of file diff --git a/src/app/browser.hpp b/src/app/browser.hpp index 579d7fd1..2bc8840f 100644 --- a/src/app/browser.hpp +++ b/src/app/browser.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace lib { @@ -31,8 +32,6 @@ namespace app //const Glib::RefPtr & app, //const std::shared_ptr & db ); - - ~Browser(); }; } diff --git a/src/app/browser/header.cpp b/src/app/browser/header.cpp index b547c3a2..a3fa2c99 100644 --- a/src/app/browser/header.cpp +++ b/src/app/browser/header.cpp @@ -13,34 +13,27 @@ Header::Header() ); // Init menu - headerMenu = new header::Menu(); + headerMenu = Gtk::make_managed(); pack_start( * headerMenu ); // Init tab - headerTab = new header::Tab(); + headerTab = Gtk::make_managed(); pack_start( * headerTab ); // Init main widget - headerMain = new header::Main(); + headerMain = Gtk::make_managed(); set_title_widget( * headerMain ); } -Header::~Header() -{ - delete headerMain; - delete headerMenu; - delete headerTab; -} - void Header::set_title( const Glib::ustring & VALUE ) { diff --git a/src/app/browser/header.hpp b/src/app/browser/header.hpp index 12fc35f1..8c26b583 100644 --- a/src/app/browser/header.hpp +++ b/src/app/browser/header.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace app::browser { @@ -27,8 +28,6 @@ namespace app::browser Header(); - ~Header(); - void set_title( const Glib::ustring & VALUE ); diff --git a/src/app/browser/header/main.cpp b/src/app/browser/header/main.cpp index c7212b5a..fd50b4b8 100644 --- a/src/app/browser/header/main.cpp +++ b/src/app/browser/header/main.cpp @@ -16,25 +16,19 @@ Main::Main() ); // Init title - mainTitle = new main::Title(); + mainTitle = Gtk::make_managed(); append( * mainTitle ); - mainSubtitle = new main::Subtitle(); + mainSubtitle = Gtk::make_managed(); append( * mainSubtitle ); } -Main::~Main() -{ - delete mainTitle; - delete mainSubtitle; -} - void Main::set_title( const Glib::ustring & VALUE ) { diff --git a/src/app/browser/header/main.hpp b/src/app/browser/header/main.hpp index ecfaeeef..69bcad06 100644 --- a/src/app/browser/header/main.hpp +++ b/src/app/browser/header/main.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace app::browser::header { @@ -23,8 +24,6 @@ namespace app::browser::header Main(); - ~Main(); - void set_title( const Glib::ustring & VALUE ); diff --git a/src/app/browser/main.cpp b/src/app/browser/main.cpp index 17fcf42b..df1702fe 100644 --- a/src/app/browser/main.cpp +++ b/src/app/browser/main.cpp @@ -15,18 +15,13 @@ Main::Main() ); // Init tabs - mainTab = new main::Tab(); + mainTab = Gtk::make_managed(); append( * mainTab ); } -Main::~Main() -{ - delete mainTab; -} - // Getters Glib::ustring Main::get_current_tab_page_title() { diff --git a/src/app/browser/main.hpp b/src/app/browser/main.hpp index 3b7f0164..82416c3f 100644 --- a/src/app/browser/main.hpp +++ b/src/app/browser/main.hpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace app::browser { @@ -23,7 +24,6 @@ namespace app::browser public: Main(); - ~Main(); // Getters Glib::ustring get_current_tab_page_title(); diff --git a/src/app/browser/main/tab/page.cpp b/src/app/browser/main/tab/page.cpp index 09c7901d..e2864f58 100644 --- a/src/app/browser/main/tab/page.cpp +++ b/src/app/browser/main/tab/page.cpp @@ -33,7 +33,7 @@ Page::Page( ); // Init components - pageNavbar = new page::Navbar( + pageNavbar = Gtk::make_managed( REQUEST ); @@ -41,13 +41,13 @@ Page::Page( * pageNavbar ); - pageProgressbar = new page::Progressbar(); + pageProgressbar = Gtk::make_managed(); append( * pageProgressbar ); - pageContent = new page::Content(); + pageContent = Gtk::make_managed(); append( * pageContent @@ -61,13 +61,6 @@ Page::Page( ); } -Page::~Page() -{ - delete pageNavbar; - delete pageContent; - delete pageProgressbar; -} - // Getters Glib::ustring Page::get_title() { diff --git a/src/app/browser/main/tab/page.hpp b/src/app/browser/main/tab/page.hpp index 58ab837f..69770432 100644 --- a/src/app/browser/main/tab/page.hpp +++ b/src/app/browser/main/tab/page.hpp @@ -13,6 +13,7 @@ #include #include #include +#include namespace app::browser::main::tab { @@ -55,8 +56,6 @@ namespace app::browser::main::tab const Glib::ustring & REQUEST = "" ); - ~Page(); - // Getters Glib::ustring get_title(); Glib::ustring get_subtitle(); diff --git a/src/app/browser/main/tab/page/navbar.cpp b/src/app/browser/main/tab/page/navbar.cpp index e3385645..fd7c3785 100644 --- a/src/app/browser/main/tab/page/navbar.cpp +++ b/src/app/browser/main/tab/page/navbar.cpp @@ -36,25 +36,25 @@ Navbar::Navbar( ); // Init components - navbarBase = new navbar::Base(); + navbarBase = Gtk::make_managed(); append( * navbarBase ); - navbarHistory = new navbar::History(); + navbarHistory = Gtk::make_managed(); append( * navbarHistory ); - navbarUpdate = new navbar::Update(); + navbarUpdate = Gtk::make_managed(); append( * navbarUpdate ); - navbarRequest = new navbar::Request( + navbarRequest = Gtk::make_managed( REQUEST ); @@ -62,7 +62,7 @@ Navbar::Navbar( * navbarRequest ); - navbarBookmark = new navbar::Bookmark(); + navbarBookmark = Gtk::make_managed(); append( * navbarBookmark @@ -86,15 +86,6 @@ Navbar::Navbar( ); } -Navbar::~Navbar() -{ - delete navbarBase; - delete navbarBookmark; - delete navbarHistory; - delete navbarRequest; - delete navbarUpdate; -}; - // Actions void Navbar::back() { diff --git a/src/app/browser/main/tab/page/navbar.hpp b/src/app/browser/main/tab/page/navbar.hpp index 6f09e955..0c7aa72c 100644 --- a/src/app/browser/main/tab/page/navbar.hpp +++ b/src/app/browser/main/tab/page/navbar.hpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace app::browser::main::tab::page { @@ -35,8 +36,6 @@ namespace app::browser::main::tab::page const Glib::ustring & REQUEST ); - ~Navbar(); - // Actions void back(); diff --git a/src/app/browser/main/tab/page/navbar/history.cpp b/src/app/browser/main/tab/page/navbar/history.cpp index da5505b9..840e2ba7 100644 --- a/src/app/browser/main/tab/page/navbar/history.cpp +++ b/src/app/browser/main/tab/page/navbar/history.cpp @@ -10,25 +10,19 @@ History::History() "linked" // merge children elements ); - historyBack = new history::Back(); + historyBack = Gtk::make_managed(); append( * historyBack ); - historyForward = new history::Forward(); + historyForward = Gtk::make_managed(); append( * historyForward ); } -History::~History() -{ - delete historyBack; - delete historyForward; -}; - // Actions void History::back() { diff --git a/src/app/browser/main/tab/page/navbar/history.hpp b/src/app/browser/main/tab/page/navbar/history.hpp index 93fd707e..0302c70d 100644 --- a/src/app/browser/main/tab/page/navbar/history.hpp +++ b/src/app/browser/main/tab/page/navbar/history.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include namespace app::browser::main::tab::page::navbar @@ -36,8 +37,6 @@ namespace app::browser::main::tab::page::navbar History(); - ~History(); - void back(); void forward();