Capturando eventos do GtkNotebook
O GtkNotebook é um tabview, ou seja um container com abas, daquels que ficam em cima =)
As vezes precisamos saber se a aba foi trocada, se o usuario clicou em uma aba. Para isso se conecta ao um sinal chamado switch-page. A função callback terá 3 parametros, sendo importantes o 1º e o ultimo.
Segue um exemplo da utilização da funcionalidade:
$window = new GtkWindow();
$window->connect_simple("destroy", array("Gtk", "main_quit"));
$notebook = new GtkNotebook();
$notebook->append_page(new GtkFixed(), new GtkLabel("Page 1"));
$notebook->append_page(new GtkFixed(), new GtkLabel("Page 2"));
$notebook->append_page(new GtkFixed(), new GtkLabel("Page 3"));
$notebook->connect("switch-page", "notebook_onchage");
$window->set_size_request(500, 500);
$window->add($notebook);
$window->show_all();
Gtk::main();
function notebook_onchage($widget, $pointer, $page)
{
global $window;
$aba = $widget->get_nth_page($page);
$texto = $widget->get_tab_label_text($aba);
$window->set_title($texto);
}
Espero que ajude =)