get_active_text(); $strPriority = $comboPriority->get_active_text(); //Do some error checking $errors = null; if(strlen($strEntity) == 0) { $errors .= "Entity is missing.\r\n"; } if(strlen($strPriority) == 0) { $errors .= "No priority given.\r\n"; } if($errors !== null) { //There was at least one error. //We show a message box with the errors $dialog = new GtkMessageDialog($wnd, Gtk::DIALOG_MODAL, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, $errors); $dialog->set_markup( "The following errors occured:\r\n" . "" . $errors . "" ); $dialog->run(); $dialog->destroy(); } else { $wnd->destroy(); } } function createWindow() { //Create the login window $wnd = new GtkWindow(); $wnd->set_title('Maarch Capture Connector'); //Close the main loop when the window is destroyed $wnd->connect_simple('destroy', array('gtk', 'main_quit')); //Set up all the widgets we need $lblCredit = new GtkLabel('Please provide your data'); //The second parameter says that the underscore should be parsed as underline $lblEntity = new GtkLabel('_Entity', true); $lbPriority = new GtkLabel('_Priority', true); $comboEntity = new GtkComboBox(); $comboPriority = new GtkComboBox(); $btnLaunchMaarch = new GtkButton('_Launch Maarch'); $btnCancel = new GtkButton('_Cancel'); //add an image $img = GtkImage::new_from_file('C:\php-gtk2\demos\maarch_logo.gif'); //Create a model $listStoreEntity = new GtkListStore(Gobject::TYPE_STRING); $listStorePriority = new GtkListStore(Gobject::TYPE_STRING); //Add some values $listStoreEntity->append(array('Direction des Ressources Humaines')); $listStoreEntity->append(array('Informatique')); $listStoreEntity->append(array('Comptabilité')); $listStorePriority->append(array('Haute')); $listStorePriority->append(array('Normale')); $listStorePriority->append(array('Faible')); //Set the model for the combo $comboEntity->set_model($listStoreEntity); $comboPriority->set_model($listStorePriority); //Create a cell renderer $cellRenderer = new GtkCellRendererText(); //Pack the cell renderer into the combo $comboEntity->pack_start($cellRenderer); $comboPriority->pack_start($cellRenderer); //Tell the combo where to get the text value of the cell renderer $comboEntity->set_attributes($cellRenderer, 'text', 0); $comboPriority->set_attributes($cellRenderer, 'text', 0); //Which widget should be activated when the //mnemonic (Alt+U or Alt+P) is pressed? //$lblEntity->set_mnemonic_widget($comboEntity); $lblEntity->set_mnemonic_widget($comboEntity); $lbPriority->set_mnemonic_widget($comboPriority); //Destroy the window when the user clicks Cancel $btnCancel->connect_simple('clicked', array($wnd, 'destroy')); //Call the launchMaarch function when the user clicks on click $btnLaunchMaarch->connect_simple('clicked', 'launchMaarch', $wnd, $comboEntity, $comboPriority); //Lay out all the widgets in the table $tbl = new GtkTable(3, 2); $tbl->attach($img, 0, 2, 0, 1); $tbl->attach($lblEntity, 0, 1, 1, 2); $tbl->attach($comboEntity, 1, 2, 1, 2); $tbl->attach($lbPriority, 0, 1, 2, 3); $tbl->attach($comboPriority, 1, 2, 2, 3); $tbl->attach($img, 1, 2, 2, 3); //Add the buttons to a button box $bbox = new GtkHButtonBox(); $bbox->set_layout(Gtk::BUTTONBOX_EDGE); $bbox->add($btnCancel); $bbox->add($btnLaunchMaarch); //Add the table and the button box to a vbox $vbox = new GtkVBox(); $vbox->pack_start($tbl); $vbox->pack_start($bbox); //Add the vbox to the window $wnd->add($vbox); //Show all widgets $wnd->show_all(); } createWindow(); //Start the main loop Gtk::main(); ?>