get_selection(); //we want to be able to select multiple rows $selection->set_mode(Gtk::SELECTION_MULTIPLE); // Buttons $bt_remove = new GtkButton("Remove Selection"); $bt_remove->connect_simple("clicked", "remove_selection", $selection); $bt_display = new GtkButton("Display Selection"); $bt_display->connect_simple("clicked", "display_selection", $selection); // Box $hbox = new GtkHBox(); function remove_selection($selection) { list($model, $arPaths) = $selection->get_selected_rows(); echo "Going to remove ".count($arPaths)." paths:\n"; foreach ($arPaths as $path) { $iter = $model->get_iter($path); echo ' ' . $model->get_value($iter, 0) . "\n"; // // This seems to operate only on half of the selected paths $model->remove($iter); } } function display_selection($selection) { list($model, $arPaths) = $selection->get_selected_rows(); echo "Selection is now:\n"; foreach ($arPaths as $path) { $iter = $model->get_iter($path); echo ' ' . $model->get_value($iter, 0) . "\n"; } } //add a column to display the data $col = new GtkTreeViewColumn('Number', new GtkCellRendererText(), 'text', 0); $view->append_column($col); //add some data to the model/store $model->append(array('Zero')); $model->append(array('One')); $model->append(array('Two')); $model->append(array('Three')); $model->append(array('Four')); $model->append(array('Five')); //add the view to the window $wnd = new GtkWindow(); $wnd->set_title('GtkTreeView selection test'); $wnd->connect_simple('destroy', array('Gtk', 'main_quit')); $hbox->pack_start($bt_remove); $hbox->pack_start($bt_display); $hbox->pack_start($view); $wnd->add($hbox); $wnd->show_all(); Gtk::main(); ?>