From f72bf5e723c93a9cf22eb138a694daef6dbeb58a Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 12 Aug 2024 20:24:06 +0300 Subject: [PATCH] implement multi-tab close action --- src/app/browser.cpp | 42 ++++++++++++++++++++++++++++++++++++ src/app/browser.hpp | 3 +++ src/app/browser/main.cpp | 15 +++++++++++++ src/app/browser/main.hpp | 3 +++ src/app/browser/main/tab.cpp | 19 +++++++++++++++- src/app/browser/main/tab.hpp | 3 +++ 6 files changed, 84 insertions(+), 1 deletion(-) diff --git a/src/app/browser.cpp b/src/app/browser.cpp index 3f296be1..6f551c19 100644 --- a/src/app/browser.cpp +++ b/src/app/browser.cpp @@ -41,6 +41,7 @@ Browser::Browser( ) ); + // Close add_action( "tab_close", sigc::mem_fun( @@ -49,6 +50,32 @@ Browser::Browser( ) ); + // Close submenu + add_action( + "tab_close_left", + sigc::mem_fun( + * this, + & Browser::main_tab_close_left + ) + ); + + add_action( + "tab_close_right", + sigc::mem_fun( + * this, + & Browser::main_tab_close_right + ) + ); + + add_action( + "tab_close_all", + sigc::mem_fun( + * this, + & Browser::main_tab_close_all + ) + ); + + // Tool add_action( "debug", sigc::mem_fun( @@ -79,6 +106,21 @@ void Browser::main_tab_close() main->tab_close(); }; +void Browser::main_tab_close_left() +{ + main->tab_close_left(); +}; + +void Browser::main_tab_close_right() +{ + main->tab_close_right(); +}; + +void Browser::main_tab_close_all() +{ + main->tab_close_all(); +}; + void Browser::debug() { gtk_window_set_interactive_debugging( diff --git a/src/app/browser.hpp b/src/app/browser.hpp index ba34409e..4c0911e9 100644 --- a/src/app/browser.hpp +++ b/src/app/browser.hpp @@ -40,6 +40,9 @@ namespace app void main_tab_append(); void main_tab_close(); + void main_tab_close_left(); + void main_tab_close_right(); + void main_tab_close_all(); void debug(); }; diff --git a/src/app/browser/main.cpp b/src/app/browser/main.cpp index 38b2ae3d..970f325f 100644 --- a/src/app/browser/main.cpp +++ b/src/app/browser/main.cpp @@ -45,4 +45,19 @@ void Main::tab_append() void Main::tab_close() { tab->close(); +}; + +void Main::tab_close_left() +{ + tab->close_left(); +}; + +void Main::tab_close_right() +{ + tab->close_right(); +}; + +void Main::tab_close_all() +{ + tab->close_all(); }; \ No newline at end of file diff --git a/src/app/browser/main.hpp b/src/app/browser/main.hpp index 5d01dd20..5ce6173d 100644 --- a/src/app/browser/main.hpp +++ b/src/app/browser/main.hpp @@ -25,6 +25,9 @@ namespace app::browser void tab_append(); void tab_close(); + void tab_close_left(); + void tab_close_right(); + void tab_close_all(); }; } diff --git a/src/app/browser/main/tab.cpp b/src/app/browser/main/tab.cpp index ef273600..1ae3840a 100644 --- a/src/app/browser/main/tab.cpp +++ b/src/app/browser/main/tab.cpp @@ -68,6 +68,23 @@ void Tab::close() remove_page( get_current_page() ); + + // @TODO clean memory + // @TODO fix GtkGizmo reported min height -3, but sizes must be >= 0 +} + +void Tab::close_left() +{} // @TODO + +void Tab::close_right() +{} // @TODO + +void Tab::close_all() +{ + while (0 <= get_current_page()) + { + close(); + } } void Tab::on_label_click( @@ -77,6 +94,6 @@ void Tab::on_label_click( ) { if (n == 2) // double click { - Tab::close(); + close(); } } \ No newline at end of file diff --git a/src/app/browser/main/tab.hpp b/src/app/browser/main/tab.hpp index 331c4875..c25905a8 100644 --- a/src/app/browser/main/tab.hpp +++ b/src/app/browser/main/tab.hpp @@ -50,6 +50,9 @@ namespace app::browser::main ); void close(); + void close_left(); + void close_right(); + void close_all(); void update(); };