<?php
//todo: cargar texto alternativo en el menu (idiomas, etc) 1101311032
require_once 'xzydialogs.php';
class xzyPopApp { //1101311032
var $timeout = 10000;
function __construct() {
}
function _menuadd(&$menu, $label, $action,$param) {
$menuitem = new GtkMenuItem($label);
$menuitem->connect_simple('activate', array(&$this,$action), $param);
$menu->append($menuitem);
}
function _collectmethods() {
$methods = get_class_methods($this);
foreach ($methods as $method) {
if ((substr($method,0,1) <> '_') and ($method <> 'run')) {
$tmp[$method] = $method;
}
}
return $tmp;
}
function _register_menu($param) {
$menu = new GtkMenu();
$methods = $this->_collectmethods();
foreach ($methods as $method) {
$label = str_replace('_',' ',$method);
$this->_menuadd($menu,$label,$method,$param);
}
return $menu;
}
function _get_clipboard() {
$clipboard = new GtkClipboard;
if ($clipboard->wait_is_text_available()) {
$text = $clipboard->wait_for_text();
return $text;
}
}
Function run() {
if (!isset($GLOBALS['argv'][1])) {
xzyDialogs::Alert("sin parametros.\n","Error");
echo "Error\n";
die();
}
$param = $GLOBALS['argv'][1];
$clipboard = $this->_get_clipboard();
$menu = $this->_register_menu($param);
$menu->show_all();
$menu->popup();
Gtk::timeout_add($this->timeout, 'Gtk::Main_quit');
Gtk::main();
}
}
?>