Callback called twice

From: Date: Sat, 11 Mar 2006 16:57:01 +0000
Subject: Callback called twice
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-6780@lists.php.net to get a copy of this message
Hi all i have used a GtkCombo and populate it with GtkListItem. I have strange problem when i retrive the selected item from the list because when a select-child event occur the callback is called twice. I have posted the code for a best explanation: <?php error_reporting(E_ALL); if (!extension_loaded('gtk')) { dl('php_gtk.' . PHP_SHLIB_SUFFIX); } $main =& new GtkWindow(GTK_WINDOW_TOPLEVEL); $main->set_title('File chooser'); $main->set_position(GTK_WIN_POS_CENTER); $main->set_policy(false, false, false); $main->connect_object('destroy', array('gtk', 'main_quit')); /*** GtkCombo to list all system folders */ $combo =& new GtkCombo(); $combo->set_usize(280, -1); $entry = $combo->entry; $list = $combo->list; $list->set_selection_mode(GTK_SELECTION_SINGLE); function GetSysFolder() { if (!empty($_ENV)) { $drive = $_ENV['SystemDrive']."\\"; $documents = str_replace("\\\\", "\\", $_ENV['USERPROFILE']); $desktop = $documents."\\Desktop"; return array($drive, $documents, $desktop); } } function GetItemSelected() { global $list, $system_folder; $selected = $list->selection[0]; $count = count($system_folder); $name = $selected->get_name(); for ($i = 0; $i < $count; $i++) { if ($name == $i) { $item_value = $selected->get_data($i); } } printf("%s \n", $item_value); return; } $system_folder = GetSysFolder(); $count = count($system_folder); for ($i = 0; $i < $count; $i++) { $item =& new GtkListItem($system_folder[$i]); $item->set_name($i); $item->set_data($i, $system_folder[$i]); $list->add($item); $list->show_all(); } $list->select_item(0); $list->connect_object('select-child', 'GetItemSelected'); /*** Call the GetItemSelected when start the app because any selection occur */ GetItemSelected(); $main->add($combo); $main->show_all(); Gtk::main(); ?> Thanks to all

« previous php.gtk.general (#6780) next »