function add_row($table, $row, $label_text, $options) { $label = new GtkLabel($label_text); $label->set_use_underline(true); $label->set_alignment(0, 1); $table->attach($label, 0, 1, $row, $row + 1, Gtk::EXPAND + Gtk::FILL, 0, 0, 0); $option_menu = $this->create_option_menu($options); $label->set_mnemonic_widget($option_menu); $this->size_group->add_widget($option_menu); $table->attach($option_menu, 1, 2, $row, $row + 1, 0, 0, 0, 0); }
function get_data($title, $field_labels) { $dialog = new GtkDialog($title, null, Gtk::DIALOG_MODAL); // create a new dialog $dialog->set_position(Gtk::WIN_POS_CENTER_ALWAYS); $top_area = $dialog->vbox; // get the top area $top_area->pack_start($hbox = new GtkHBox()); $stock = GtkImage::new_from_stock(Gtk::STOCK_DIALOG_QUESTION, Gtk::ICON_SIZE_DIALOG); $hbox->pack_start($stock, 0, 0); // stuff in the icon // display the data entry form as table $table = new GtkTable(); // create a new table $row = 0; $input = array(); // holds the ID of each GtkEntry foreach ($field_labels as $field_label) { $label = new GtkLabel($field_label); $label->set_alignment(0, 0); // left-justify the label $table->attach($label, 0, 1, $row, $row + 1); // insert the label into table $input[$row] = new GtkEntry(); // create a new input field $table->attach($input[$row], 1, 2, $row, $row + 1); // add this besides the label if (eregi("password", $field_label)) { $input[$row]->set_visibility(false); } // show password entry as '*' ++$row; } $hbox->pack_start($table); $dialog->add_button(Gtk::STOCK_OK, Gtk::RESPONSE_OK); // add an OK button $dialog->set_has_separator(false); // don't display the set_has_separator $dialog->show_all(); // show the dialog $dialog->run(); // the dialog in action // grab the user input before destroying the dialog - note 1 $data = array(); // put user input in an array for ($i = 0; $i < count($input); ++$i) { $data[] = $input[$i]->get_text(); } $dialog->destroy(); // done. close the dialog box. return $data; // returns the user input as array }
public function __construct() { $this->frame = new GtkFrame(); $frameBox = new GtkVBox(false, 10); $frameBox->set_border_width(10); $titleBox = new GtkHBox(false, 10); $titleLabel = new GtkLabel("User Roles"); $titleLabel->set_markup("<span weight='bold'>User Roles</span>"); $titleLabel->set_alignment(0, 0.5); $this->statusLabel = new GtkLabel(""); $this->statusLabel->set_alignment(1, 0.5); $titleBox->pack_start($titleLabel, true, true, 0); $titleBox->pack_end($this->statusLabel, true, true, 0); $frameBox->pack_start($titleBox, false, false, 0); $this->frame->add($frameBox); $this->roleListStore = new GtkRefListStore(Gobject::TYPE_STRING); $this->roleListTree = new GtkRefTreeView($this->roleListStore); $this->roleListTree->set_headers_visible(false); $roleListSelection = $this->roleListTree->get_selection(); $roleListSelection->set_mode(Gtk::SELECTION_SINGLE); $roleListSelection->connect('changed', array($this, 'selectRoleToRemove')); $rolesWindow = new GtkScrolledWindow(); $rolesWindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); $rolesWindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN); $rolesWindow->add($this->roleListTree); $frameBox->pack_start($rolesWindow, true, true, 0); $renderer = new GtkCellRendererText(); $renderer->set_property("editable", false); $column = new GtkTreeViewColumn('Role', $renderer, "text", 0); $column->set_expand(true); $column->set_resizable(false); $this->roleListTree->append_column($column); $this->roleComboStore = new GtkRefListStore(Gobject::TYPE_STRING); $this->roleComboStore->refInsert(RoleEnum::getList()); $this->roleCombo = new GtkRefComboBox($this->roleComboStore); $roleCell = new GtkCellRendererText(); $roleCell->set_property('ellipsize', Pango::ELLIPSIZE_END); $this->roleCombo->pack_start($roleCell); $this->roleCombo->set_attributes($roleCell, 'text', 0); $this->roleCombo->connect('changed', array($this, 'selectRoleToAdd')); $this->addButton = new GtkButton("Add"); $this->addButton->set_sensitive(false); $this->removeButton = new GtkButton("Remove"); $this->removeButton->set_sensitive(false); $this->enableForm(false); $buttonBox = new GtkHBox(false, 8); $buttonBox->pack_end($this->removeButton, false, false, 0); $buttonBox->pack_end($this->addButton, false, false, 0); $buttonBox->pack_end($this->roleCombo, true, true, 0); $frameBox->pack_end($buttonBox, false, false, 0); }
public function __construct() { $this->frame = new GtkFrame(); $frameBox = new GtkVBox(false, 10); $frameBox->set_border_width(10); $titleBox = new GtkHBox(false, 10); $titleLabel = new GtkLabel("Users"); $titleLabel->set_markup("<span weight='bold'>Users</span>"); $titleLabel->set_alignment(0, 0.5); $this->statusLabel = new GtkLabel(""); $this->statusLabel->set_alignment(1, 0.5); $titleBox->pack_start($titleLabel, true, true, 0); $titleBox->pack_end($this->statusLabel, true, true, 0); $frameBox->pack_start($titleBox, false, false, 0); $this->frame->add($frameBox); $this->userListStore = new GtkRefListStore(Gobject::TYPE_STRING, Gobject::TYPE_STRING, Gobject::TYPE_STRING, Gobject::TYPE_STRING, Gobject::TYPE_STRING); $this->userListTree = new GtkRefTreeView($this->userListStore); $this->userListTree->set_rules_hint(true); $usersWindow = new GtkScrolledWindow(); $usersWindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); $usersWindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN); $usersWindow->add($this->userListTree); $frameBox->pack_start($usersWindow, true, true, 0); $cols = array('Username', 'First Name', 'Last Name', 'Email', 'Department'); foreach ($cols as $num => $item) { $renderer = new GtkCellRendererText(); $renderer->set_property("editable", false); $column = new GtkTreeViewColumn($item, $renderer, "text", $num); $column->set_sort_column_id($num); $column->set_expand(true); $column->set_resizable(true); $this->userListTree->append_column($column); } $userSelection = $this->userListTree->get_selection(); $userSelection->set_mode(Gtk::SELECTION_SINGLE); $userSelection->connect('changed', array($this, 'isSelected')); $this->newButton = new GtkButton("New"); $this->newButton->connect('clicked', array($this, 'deSelect')); $this->delButton = new GtkButton("Delete"); $this->delButton->set_sensitive(false); $this->delButton->connect('clicked', array($this, 'confirmDeletion')); $buttonBox = new GtkHBox(false, 8); $buttonBox->pack_end($this->newButton, false, false, 0); $buttonBox->pack_end($this->delButton, false, false, 0); $frameBox->pack_end($buttonBox, false, false, 0); }
private function createLabelText($label, $entryVisible = true) { $labelObj = new GtkLabel($label); $labelObj->set_alignment(1, 0.5); $entryObj = new GtkEntry(); $entryObj->set_visibility($entryVisible); return array($labelObj, $entryObj); }
$title->modify_font(new PangoFontDescription("Times New Roman Italic 10")); $title->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#0000ff")); $title->set_size_request(-1, 40); $vbox->pack_start($title, 0, 0); $vbox->pack_start(new GtkLabel('')); // create the clickable label $clickable_label = new GtkHBox(); $clickable_label->set_size_request(-1, 24); $vbox->pack_start($clickable_label, 0, 0); $clickable_label->pack_start(new GtkLabel("reference: php-gtk2 "), 0, 0); $clickable_label->pack_start(link("manual", "http://gtk.php.net/manual/en/gtkclasses.php"), 0, 0); $clickable_label->pack_start(new GtkLabel(" and "), 0, 0); $clickable_label->pack_start(link("mailing list", "http://www.nabble.com/Php---GTK---General-f171.html"), 0, 0); //$vbox->pack_start(new GtkLabel('')); $status = new GtkLabel(''); $status->set_alignment(0, 0); $vbox->pack_start($status, 0, 0); // function to setup the link function link($title, $url) { $label = new GtkLabel($title); $label->set_markup('<span color="blue"><u>' . $title . "</u></span>"); $eventbox = new GtkEventBox(); $eventbox->add($label); $eventbox->connect('button-press-event', 'on_click', $title, $url); $eventbox->connect('enter-notify-event', 'on_enter', $title, $url); $eventbox->connect('leave-notify-event', 'on_leave', $title, $url); return $eventbox; } function on_click($widget, $event, $title, $url) {
/** * @name __construct($text) * @param string $text Texto à ser mostrado no GtkLabel * @return GtkLabel */ public function __construct($text) { parent::__construct($text); // Alinha o texto ao meio e à esquerda parent::set_alignment(0, 1); }
/** * 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(); }