function gtk_die($message) { $dialog = new GtkMessageDialog(null, 0, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, $message); $dialog->set_markup("<b>{$message}</b>\nPlease refer to the future docs for details!"); $dialog->run(); $dialog->destroy(); die($message . "\n"); }
public function onFullTextSearchClick() { if (!$this->manual) { // TODO: One might think aobut using an external browser or the online docs... $dialog = new \GtkMessageDialog($this->glade->get_widget('mainwindow'), 0, \Gtk::MESSAGE_ERROR, \Gtk::BUTTONS_OK, 'GtkHTML needed'); $dialog->set_markup('For doing full text searches GtkHTML support is required in your PHP configuration.'); $dialog->run(); $dialog->destroy(); return; } $input = trim($this->glade->get_widget('searchentry')->get_text()); if (strlen($input) == 0) { $dialog = new \GtkMessageDialog($this->glade->get_widget('mainwindow'), 0, \Gtk::MESSAGE_ERROR, \Gtk::BUTTONS_OK, 'No input'); $dialog->set_markup('No search term entered'); $dialog->run(); $dialog->destroy(); return; } $results = $this->manual->searchFulltext($input); $store = new \GtkTreeStore(\GObject::TYPE_STRING, \GObject::TYPE_PHP_VALUE); foreach ($results as $title => $found) { $man_container = $store->append(null, array($title, null)); $basenamelen = strlen('phar://' . $found->getArchiveFileName()); echo 'phar://' . $found->getArchiveFileName(), "\n"; foreach ($found as $item) { /** @var $item \SplFileObject */ $doc = \DomDocument::loadHTMLFile($item->getPathname()); $caption = $doc->getElementsByTagName('title')->item(0)->firstChild->wholeText; $store->append($man_container, array($caption, $item)); } } $tree = $this->glade->get_widget('searchtreeview'); $tree->set_model($store); $tree->get_selection()->connect('changed', array($this->mainWindow, 'onSearchResultClick')); /* TODO: Move to view */ $cell_renderer = new \GtkCellRendererText(); $colExt = new \GtkTreeViewColumn('', $cell_renderer, 'text', 0); $tree->append_column($colExt); }
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(); } }