/* * Create a list widget and populate it with month names. */ $list = new GtkList(); $list->set_selection_mode(GTK_SELECTION_BROWSE); foreach (range(1, 12) as $month_num) { $items[] = new GtkListItem(strftime('%B', mktime(0, 0, 0, $month_num))); } $list->append_items($items); /* * Create a scrolled window and add the list widget to it - this provides * automatic scrollbars. */ $scrolled_window = new GtkScrolledWindow(); $scrolled_window->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); $scrolled_window->add_with_viewport($list); /* * Add scrolled window and button to the vertical layout box. */ $box->pack_start($scrolled_window); $box->pack_start($button, false); /* * Add layout box to the window, set window attributes and show everything. */ $window->add($box); $window->set_title('PHP Rules!'); $window->set_name('MainWindow'); $window->set_usize(150, 200); $window->show_all(); /* Run the main loop. */ Gtk::main();
/** * Show a popup with information about the application. * * The popup should show information about the version, * the author, the license, where to get the latest * version and a short description. * * @access public * @param none * @return void */ function about() { // Create the new window. $about = new GtkWindow(); $about->set_title('About PHPUnit GUI Gtk'); $about->set_usize(250, -1); // Put two vboxes in the hbox. $vBox = new GtkVBox(); $about->add($vBox); // Create the labels. $version = new GtkLabel(" Version: 1.0"); $license = new GtkLabel(" License: PHP License v3.0"); $where = new GtkLabel(" Download from: http://pear.php.net/PHPUnit/"); $unitAuth = new GtkLabel(" PHPUnit Author: Sebastian Bergman"); $gtkAuth = new GtkLabel(" Gtk GUI Author: Scott Mattocks"); // Align everything to the left $where->set_alignment(0, 0.5); $version->set_alignment(0, 0.5); $license->set_alignment(0, 0.5); $gtkAuth->set_alignment(0, 0.5); $unitAuth->set_alignment(0, 0.5); // Pack everything into the vBox; $vBox->pack_start($version); $vBox->pack_start($license); $vBox->pack_start($where); $vBox->pack_start($unitAuth); $vBox->pack_start($gtkAuth); // Connect the destroy signal. $about->connect('destroy', array('gtk', 'true')); // Show the goods. $about->show_all(); }