/** * prepares a widget to accept directories only * Just a shortcut for the exhausted programmer * @static * @param GtkWidget The widget which shall accept directories * * @return boolean If all was ok */ function attachDirectory($widget) { return Gtk_FileDrop::attach($widget, array('inode/directory')); }
/** * Creates the page for displaying the package file manager * options that relate to the entire package, regardless of * the release. * * Package options are those such as: base install directory, * the license, the package name, etc. * * @return array * @access private */ function _createPackagePage() { // Create some containers. $mainVBox =& new GtkVBox(); // Create the hbox for the file selection. $packageDirHBox =& new GtkHBox(); // We need an entries for the file. $packageDirEntry =& new GtkEntry(); $packageDirButton =& new GtkButton('Select'); // Allow users to drop files in the entry box if possible. @(include_once 'Gtk/FileDrop.php'); if (class_exists('Gtk_FileDrop')) { Gtk_FileDrop::attach($packageDirEntry, array('inode/directory')); } // Create the file selection. $packageDirFS =& new GtkFileSelection('Package Directory'); $packageDirFS->set_position(GTK_WIN_POS_CENTER); // Set the default path to the pear directory. require_once 'PEAR/Config.php'; $pearConfig =& new PEAR_Config(); $packageDirFS->set_filename($pearConfig->get('php_dir')); // Make the ok button set the entry value. $okButton = $packageDirFS->ok_button; $okButton->connect_object('clicked', array(&$this, '_setPackageDirEntry'), $packageDirEntry, $packageDirFS); // Make the cancel button hide the selection. $cancelButton = $packageDirFS->cancel_button; $cancelButton->connect_object('clicked', array(&$packageDirFS, 'hide')); // Make the button show the file selection. $packageDirButton->connect_object('clicked', array(&$packageDirFS, 'show')); // Pack the package file directory pieces. $packageDirLabel =& new GtkLabel('Package File Directory'); $packageDirLabel->set_usize(140, -1); $packageDirLabel->set_alignment(0, 0.5); $packageDirHBox->pack_start($packageDirLabel, false, false, 3); $packageDirHBox->pack_start($packageDirEntry, false, false, 3); $packageDirHBox->pack_start($packageDirButton, false, false, 3); // We need an entry for the package name. $packageNameEntry =& new GtkEntry(); $packageNameBox =& new GtkHBox(); $packageNameLabel =& new GtkLabel('Package Name'); $packageNameLabel->set_usize(140, -1); $packageNameLabel->set_alignment(0, 0.5); $packageNameBox->pack_start($packageNameLabel, false, false, 3); $packageNameBox->pack_start($packageNameEntry, false, false, 3); // We need a simple entry box for the base install directory. $baseEntry =& new GtkEntry(); $baseBox =& new GtkHBox(); $baseLabel =& new GtkLabel('Base Install Dir'); $baseLabel->set_usize(140, -1); $baseLabel->set_alignment(0, 0.5); $baseBox->pack_start($baseLabel, false, false, 3); $baseBox->pack_start($baseEntry, false, false, 3); // We need an entry for the summary. $summaryEntry =& new GtkEntry(); $summaryBox =& new GtkHBox(); $summaryLabel =& new GtkLabel('Package Summary'); $summaryLabel->set_usize(140, -1); $summaryLabel->set_alignment(0, 0.5); $summaryBox->pack_start($summaryLabel, false, false, 3); $summaryBox->pack_start($summaryEntry, false, false, 3); // We need a text area for the description. $descriptionText =& new GtkText(); $descriptionBox =& new GtkVBox(); $descriptionLabel =& new GtkLabel('Package Description'); $descriptionLabel->set_usize(140, -1); $descriptionLabel->set_alignment(0, 0.5); $descriptionText->set_editable(true); $descriptionText->set_line_wrap(true); $descriptionText->set_word_wrap(true); $descriptionText->set_usize(-1, 100); $descriptionBox->pack_start($descriptionLabel, false, false, 3); $descriptionBox->pack_start($descriptionText, true, true, 3); // We need a button to do the work. $submitButton =& new GtkButton('Submit'); $submitButton->connect_object('clicked', array(&$this, '_setPackageOptions'), $packageDirEntry, $packageNameEntry, $baseEntry, $summaryEntry, $descriptionText); $submitBox =& new GtkHBox(); $submitBox->pack_end($submitButton, false, false, 5); // Import the options if there is a package.xml file // in the package directory. $packageDirEntry->connect('changed', array(&$this, '_importPackageOptions'), $packageNameEntry, $baseEntry, $summaryEntry, $descriptionText); // Pack everything away. $mainVBox->pack_start($packageDirHBox, false, false, 3); $mainVBox->pack_start($packageNameBox, false, false, 3); $mainVBox->pack_start($baseBox, false, false, 3); $mainVBox->pack_start($summaryBox, false, false, 3); $mainVBox->pack_start($descriptionBox, true, true, 3); $mainVBox->pack_start($submitBox, false, false, 3); return array(&$mainVBox, new GtkLabel('Package')); }