Browse Source

implement multi-tab close action

CPP-GTK4
yggverse 3 months ago
parent
commit
f72bf5e723
  1. 42
      src/app/browser.cpp
  2. 3
      src/app/browser.hpp
  3. 15
      src/app/browser/main.cpp
  4. 3
      src/app/browser/main.hpp
  5. 19
      src/app/browser/main/tab.cpp
  6. 3
      src/app/browser/main/tab.hpp

42
src/app/browser.cpp

@ -41,6 +41,7 @@ Browser::Browser(
) )
); );
// Close
add_action( add_action(
"tab_close", "tab_close",
sigc::mem_fun( 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( add_action(
"debug", "debug",
sigc::mem_fun( sigc::mem_fun(
@ -79,6 +106,21 @@ void Browser::main_tab_close()
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() void Browser::debug()
{ {
gtk_window_set_interactive_debugging( gtk_window_set_interactive_debugging(

3
src/app/browser.hpp

@ -40,6 +40,9 @@ namespace app
void main_tab_append(); void main_tab_append();
void main_tab_close(); void main_tab_close();
void main_tab_close_left();
void main_tab_close_right();
void main_tab_close_all();
void debug(); void debug();
}; };

15
src/app/browser/main.cpp

@ -46,3 +46,18 @@ void Main::tab_close()
{ {
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();
};

3
src/app/browser/main.hpp

@ -25,6 +25,9 @@ namespace app::browser
void tab_append(); void tab_append();
void tab_close(); void tab_close();
void tab_close_left();
void tab_close_right();
void tab_close_all();
}; };
} }

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

@ -68,6 +68,23 @@ void Tab::close()
remove_page( remove_page(
get_current_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( void Tab::on_label_click(
@ -77,6 +94,6 @@ void Tab::on_label_click(
) { ) {
if (n == 2) // double click if (n == 2) // double click
{ {
Tab::close(); close();
} }
} }

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

@ -50,6 +50,9 @@ namespace app::browser::main
); );
void close(); void close();
void close_left();
void close_right();
void close_all();
void update(); void update();
}; };

Loading…
Cancel
Save