function setup_yes_no_dialog() { $dialog = new GtkDialog(); $dialog->vbox->pack_start($hbox = new GtkHBox()); $hbox->pack_start(new GtkLabel('Phone Number: '), 0); $hbox->pack_start($phone = new GtkEntry(), 0); // note 1 $dialog->vbox->pack_start($hbox2 = new GtkHBox()); $button_ok = GtkButton::new_from_stock(Gtk::STOCK_OK); $button_ok->set_size_request(87, 33); $hbox2->pack_start(new GtkLabel()); $hbox2->pack_start($button_ok, 0); $phone->connect('activate', 'on_enter', $button_ok); // note 2 $button_ok->connect('clicked', 'on_ok_button', $dialog); $dialog->set_has_separator(false); $dialog->action_area->set_size_request(-1, 1); $dialog->show_all(); $dialog->run(); $dialog->destroy(); global $response; $response->set_text($phone->get_text()); }
/** * Return the widget's content */ public function getValue() { return parent::get_text(); }
function run_gource(GtkWindow $wnd, GtkEntry $txtRepositoryPath, $options) { //fetch the values from the widgets into variables $strRepositoryPath = $txtRepositoryPath->get_text(); //Do some error checking $errors = null; if (strlen($strRepositoryPath) == 0) { $errors .= "you need some path!.\r\n"; } if ($errors !== null) { //save setting $settings = new Settings(); $settings->set("last_repo_path", $strRepositoryPath); //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" . "<span foreground='red'>" . $errors . "</span>"); $dialog->run(); $dialog->destroy(); } else { $dialog = new GtkMessageDialog($wnd, Gtk::DIALOG_MODAL, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK); $dialog->set_markup("running gource on repository...\npath: " . $txtRepositoryPath->get_text() . "\n"); $dialog->run(); $dialog->destroy(); $arr_hide_options = array(); $arr_normal_options = array(); foreach ($options as $option_name => $option) { if ($option->get_active() != 1) { continue; } switch ($option_name) { case 'chkOptionHideFiles': $arr_hide_options[] = "files"; break; case 'chkOptionHideFilenames': $arr_hide_options[] = "filenames"; break; case 'chkOptionHideDirnames': $arr_hide_options[] = "dirnames"; break; case 'chkOptionHideDates': $arr_hide_options[] = "date"; break; case 'chkOptionHideProgress': $arr_hide_options[] = "progress"; break; case 'chkOptionHideBloom': $arr_hide_options[] = "bloom"; break; case 'chkOptionHideMouse': $arr_hide_options[] = "mouse"; break; case 'chkOptionHideTree': $arr_hide_options[] = "tree"; break; case 'chkOptionHideUsers': $arr_hide_options[] = "users"; break; case 'chkOptionHideUsernames': $arr_hide_options[] = "usernames"; break; case 'chkOptionFullscreen': $arr_normal_options[] = "--fullscreen"; break; case 'chkOptionMultiSampling': $arr_normal_options[] = "--multi-sampling"; break; case 'chkOptionTransparent': $arr_normal_options[] = "--transparent"; break; case 'chkOptionSaveConfig': $arr_normal_options[] = "--save-config default.conf"; break; } } // "&" is added to run gource in background if (!empty($arr_hide_options)) { $str_hide_options = implode(',', $arr_hide_options); $str_normal_options = implode(' ', $arr_normal_options); system('gource ' . $txtRepositoryPath->get_text() . " --hide {$str_hide_options} {$str_normal_options} &", $gource_return); } else { $str_normal_options = implode(' ', $arr_normal_options); system('gource ' . $txtRepositoryPath->get_text() . " {$str_normal_options} &", $gource_return); } //No error. You would need to hide the dialog now //instead of destroying it (because when you destroy it, //Gtk::main_quit() gets called) and show the main window //$wnd->destroy(); } }
/** * Validate the content of GtkEntry * @ignore-autocomplete on */ public function validateMask() { $valid = FALSE; $text = parent::get_text(); $mask = $this->mask; $len = strlen($text); $text_char = substr($text, $len - 1, 1); $mask_char = substr($mask, $len - 1, 1); // compare the typed character with the mask if ($mask_char == '9') { $valid = preg_match("/([0-9])/", $text_char); } elseif ($mask_char == 'a') { $valid = preg_match("/([a-z])/", $text_char); } elseif ($mask_char == 'A') { $valid = preg_match("/([A-Z])/", $text_char); } elseif ($mask_char == 'X') { $valid = (preg_match("/([a-z])/", $text_char) or preg_match("/([A-Z])/", $text_char) or preg_match("/([0-9])/", $text_char)); } // if not valid, remove if (!$valid) { $this->Set(substr($text, 0, -1)); } }
/** * Método que valida o conteudo GtkEntry * * @name __valMask() * @access private * @author Pablo Dall'Oglio */ public function __valMask() { // Armazena texto do entry $text = parent::get_text(); // Busca o ultimo char do texto e da mascara $text_char = substr($text, strlen($text) - 1, 1); $mask_char = substr($this->__maskString, strlen($text) - 1, 1); // Compara os caracteres digitados com a máscara if ($mask_char == '9') { $valid = ereg('([0-9])', $text_char); } elseif ($mask_char == 'a') { $valid = ereg('([a-z])', $text_char); } elseif ($mask_char == 'A') { $valid = ereg('([A-Z])', $text_char); } elseif ($mask_char == 'X') { $valid = (ereg('([a-z])', $text_char) or ereg('([A-Z])', $text_char) or ereg('([0-9])', $text_char)); } // Caracteres que não se aplicam no escopo da máscara são removidos if (!$valid) { $this->__setMask(substr($text, 0, -1)); } }