GtkNotebook

GtkNotebook example Here is a quick example for GtkNotebook. Actually, it seems that only switch-page signal can be sent.

<?php
error_reporting
(E_ALL);

# create the main window
$window = new GtkWindow();
 
$window->set_title('Notebook test');
$window->set_size_request( 100, 100 );  # set window size

# place window to screen center
$window->set_position(Gtk::WIN_POS_CENTER);
 
# when we destroy $wnd, terminate
# Gtk main_loop (Gtk::main()) and quit
$window->connect_simple('destroy',
  array(
'gtk', 'main_quit'));
 
# notebook test
$nb = new GtkNotebook();
$window->add($nb);

$titles = array('php', 'gtk', 'html', 'linux', 'windows');

foreach (
$titles as $title) {
 
$frame = new GtkFrame($title);
 
$label_title = new GtkLabel($title);
 
$nb->append_page($frame, $label_title);

 
$button = new GtkButton('test');
 
$frame->add($button);
}

$nb->connect_simple('change-current-page',
 
'notebook_change_current_page');
$nb->connect_simple('select-page',        
 
'notebook_select_page');
$nb->connect_simple('switch-page',        
 
'notebook_switch_page');
$nb->connect_simple('move-focus-out',     
 
'notebook_move_focus_out');
$nb->connect_simple('focus-tab',          
 
'notebook_focus_tab');
$window->show_all();
 
Gtk::main();

function
notebook_change_current_page($event, $userdata) {
  echo
"notebook_change_current_page()\n";
}

function
notebook_select_page($event, $userdata) {
  echo
"notebook_select_page()\n";
}

function
notebook_switch_page() {
  echo
"notebook_switch_page()\n";
}

function
notebook_move_focus_out($event, $userdata) {
  echo
"notebook_move_focus_out()\n";
}

function
notebook_focus_tab($event, $userdata) {
  echo
"notebook_focus_tab()\n";
}
?>
AttachmentSize
Notebook example.7.5 KB