Exemple #1
0
 /**
  * Constructor Method
  */
 function __construct()
 {
     parent::__construct();
     parent::set_size_request(840, 640);
     parent::set_position(GTK::WIN_POS_CENTER);
     parent::connect_simple('delete-event', array($this, 'onClose'));
     parent::connect_simple('destroy', array('Gtk', 'main_quit'));
     parent::set_title(self::APP_TITLE);
     parent::set_icon(GdkPixbuf::new_from_file('favicon.png'));
     $gtk = GtkSettings::get_default();
     $gtk->set_long_property("gtk-button-images", TRUE, 0);
     $gtk->set_long_property("gtk-menu-images", TRUE, 0);
     self::$inst = $this;
     $ini = parse_ini_file('application.ini');
     $lang = $ini['language'];
     TAdiantiCoreTranslator::setLanguage($lang);
     TApplicationTranslator::setLanguage($lang);
     date_default_timezone_set($ini['timezone']);
     $this->content = new GtkFixed();
     $vbox = new GtkVBox();
     parent::add($vbox);
     $vbox->pack_start(GtkImage::new_from_file('app/images/pageheader-gtk.png'), false, false);
     $MenuBar = TMenuBar::newFromXML('menu.xml');
     $vbox->pack_start($MenuBar, false, false);
     $vbox->pack_start($this->content, true, true);
     parent::show_all();
 }
 function __update($data)
 {
     $this->list->clear();
     foreach ($data as $char) {
         $z = get_zone_name($char['map'], $char["xpos"], $char["ypos"]);
         if ($z == " ") {
             $z = get_map_name($char['map']);
         }
         $this->list->append(array($char['name'], GdkPixbuf::new_from_file("./img/{$char['race']}-{$char['gender']}.gif"), GdkPixbuf::new_from_file("./img/{$char['class']}.gif"), $char['level'], $char['latency'], $z));
     }
     $this->list->set_sort_column_id(0, Gtk::SORT_ASCENDING);
 }
 /**
  * Constructor Method
  */
 function __construct()
 {
     parent::__construct();
     parent::set_size_request(840, 640);
     parent::set_position(GTK::WIN_POS_CENTER);
     parent::connect_simple('delete-event', array($this, 'onClose'));
     parent::connect_simple('destroy', array('Gtk', 'main_quit'));
     parent::set_title(self::APP_TITLE);
     parent::set_icon(GdkPixbuf::new_from_file('favicon.png'));
     $gtk = GtkSettings::get_default();
     $gtk->set_long_property("gtk-button-images", TRUE, 0);
     $gtk->set_long_property("gtk-menu-images", TRUE, 0);
     self::$inst = $this;
     set_error_handler(array('TCoreApplication', 'errorHandler'));
 }
 function loadFiles($mFile, $strDir)
 {
     $hdl = dir($strDir);
     $mFile->clear();
     $pb = null;
     while (false !== ($file = $hdl->read())) {
         $path = $hdl->path . DIRECTORY_SEPARATOR . $file;
         if (is_dir($path) && $file !== '.') {
             $mFile->append(array($file, '<span color="#00F">' . $file . '</span>', $path, true, null));
         } else {
             if (substr($path, -4) == '.png' || substr($path, -4) == '.jpg') {
                 if ($this->bLoadPreview) {
                     $pb = GdkPixbuf::new_from_file($path)->scale_simple(32, 32, Gdk::INTERP_BILINEAR);
                 }
                 $mFile->append(array($file, $file, $path, false, $pb));
             }
         }
     }
 }
function load_pixbufs()
{
    global $background, $back_width, $back_height, $images, $image_names;
    $i = 0;
    /* We pass NULL for the error return location, we don't care
     * about the error message.
     */
    $background = GdkPixbuf::new_from_file(BACKGROUND_NAME);
    if (!$background) {
        return false;
    }
    $back_width = $background->get_width();
    $back_height = $background->get_height();
    for ($i = 0; $i < N_IMAGES; $i++) {
        $images[$i] = GdkPixbuf::new_from_file('../demos/' . $image_names[$i]);
        if (!$images[$i]) {
            return false;
        }
    }
    return true;
}
 /**
  * Cria a janela no modo splash
  * 
  * @name set_splash_image($image)
  * @param string $image Caminho para a imagem do splash
  * @return GtkFixed
  */
 public function set_splash_image($image)
 {
     // Carrega a imagem
     $pixbuf = GdkPixbuf::new_from_file($image);
     // Modifica as propriedades da janela
     parent::set_type_hint(Gdk::WINDOW_TYPE_HINT_SPLASHSCREEN);
     parent::set_size_request($pixbuf->get_width(), $pixbuf->get_height());
     parent::set_position(GTK::WIN_POS_CENTER);
     parent::realize();
     // Adiciona a imagem no fundo do GtkWindow
     list($pixmap, $mask) = $pixbuf->render_pixmap_and_mask(255);
     $style = parent::get_style();
     $style = $style->copy();
     $style->bg_pixmap[Gtk::STATE_NORMAL] = $pixmap;
     parent::set_style($style);
     // Adiciona um fixed para futuros widgets
     $fixed = new GtkFixed();
     parent::add($fixed);
     // Mostra o splash
     parent::show_all();
     // Retorna o fixed para adição de widgets
     return $fixed;
 }
Exemple #7
0
 function __construct()
 {
     parent::__construct();
     $this->set_transient_for($GLOBALS['XMONEY_JANELA_PRINCIPAL']);
     $this->set_modal(true);
     $this->set_icon(GdkPixbuf::new_from_file(XMONEY_IMAGES . DIRECTORY_SEPARATOR . 'logo.png'));
     $this->set_logo(GdkPixbuf::new_from_file(XMONEY_IMAGES . DIRECTORY_SEPARATOR . 'logo.png'));
     $this->set_name(XMONEY_TITULO);
     $this->set_version(XMONEY_DESC_VERSAO);
     $this->set_comments(XMONEY_DESCRICAO);
     $this->set_copyright(XMONEY_COPYRIGHT);
     $this->set_license(latin1(file_get_contents(XMONEY_LICENCA)));
     $this->set_authors(array(file_get_contents(XMONEY_AUTORES)));
     $this->set_url_hook(array($this, 'site_clicked'));
     $this->set_email_hook(array($this, 'email_clicked'));
     $this->set_website('http://www.gamuza.com.br/xmoney');
     $this->set_website_label('Website do X-Money');
     // Maybe a Bug???
     foreach ($this->action_area as $child) {
         if ($child instanceof GtkButton) {
             $child->connect('clicked', array($this, 'close_event'));
         }
     }
 }
 function __update($bt = NULL, $passive = false)
 {
     global $auth;
     if (!$passive) {
         $fdata = file_get_contents("http://{$auth['login']}:{$auth['pass']}@{$auth['web']}/sess_system.php");
         $mdata = @unserialize($fdata);
         //var_dump($fdata,$mdata);
         $this->update_data("http://{$auth['web']}/XML/sess_xml-stats" . $mdata['serv'][$auth['realmid']]['sid']);
         //$this->update_data("http://127.0.0.1/ascent_stats/svn/Cache/XML/sess_xml-stats".$mdata['serv'][0]['sid']);
     }
     $widget = $this->da;
     $this->m_ssdata_clear();
     $this->is_lock = false;
     $this->update_sinfo(true);
     $this->pixmap->draw_pixbuf($widget->style->black_gc, GdkPixbuf::new_from_file("./img/map.jpg"), 0, 0, 0, 0);
     $data = $this->data;
     if (is_array($data) and count($data) > 1) {
         foreach ($data as $key => $val) {
             if ($this->ss == "") {
                 $this->pixmap->draw_pixbuf($widget->style->black_gc, GdkPixbuf::new_from_file("./img/{$val['f']}_point.gif"), 0, 0, $val['x'], $val['y']);
             } elseif (sString($val['name'], $this->ss)) {
                 $this->pixmap->draw_pixbuf($widget->style->black_gc, GdkPixbuf::new_from_file("./img/{$val['f']}_point.gif"), 0, 0, $val['x'], $val['y']);
             }
         }
     }
     $widget->queue_draw();
     if ($this->wp) {
         $this->wp->__update($this->data);
     }
 }
Exemple #9
0
<?php

$window = new GtkWindow();
$window->set_default_size(120, 120);
$vbox = new GtkVBox();
// new Button
$button = new GtkButton();
$button->set_label('Icon Test');
$p = GdkPixbuf::new_from_file('images/publica.png');
$a = new GtkImage();
$a->set_from_pixbuf($p);
$button->set_image($a);
$vbox->pack_start($button, false, false);
$window->add($vbox);
$window->show_all();
Gtk::main();
 public function on_toggle_format($column, $cell, $model, $iter, $col, $trueimage, $falseimage)
 {
     echo "OK";
     $path = $model->get_path($iter);
     $row_num = $path[0];
     $value = $model->get_value($iter, $col);
     if ($value == TRUE) {
         $pixbuf = GdkPixbuf::new_from_file($trueimage);
     } else {
         $pixbuf = GdkPixbuf::new_from_file($falseimage);
     }
     $cell->set_property("pixbuf", $pixbuf);
 }
 /**
  * Adiciona uma imagem no icoview apartir de um arquivo
  * 
  * @name add_image_from_file($file, $title="")
  * @param string $file Caminho da imagem a ser adicionada
  * @param string $title Titulo da imagem 
  */
 public function add_image_from_file($file, $title = "")
 {
     // Carrega o pixbuf
     $pixBuf = GdkPixbuf::new_from_file($file);
     // Busca o tamanho da imagem
     $width = $pixBuf->get_width();
     $height = $pixBuf->get_height();
     // Verifica se a foto é paisagem ou não
     if ($height > $width) {
         // Calcula o novo width
         if ($height > $this->imageHeight) {
             $newHeight = $this->imageHeight;
             $newWidth = $this->imageHeight * $width / $height;
         }
     } else {
         // Calcula o novo height
         if ($width > $this->imageWidth) {
             $newWidth = $this->imageWidth;
             $newHeight = $this->imageWidth * $height / $width;
         }
     }
     // Gera o thumb
     $pixBuf = $pixBuf->scale_simple($newWidth, $newHeight, Gdk::INTERP_HYPER);
     // Adiciona a imagem
     $this->model->append(array($pixBuf, $title));
 }
 /**
  * Class Constructor
  * @param $image Image path
  */
 public function __construct($image)
 {
     parent::__construct();
     $pixbuf = GdkPixbuf::new_from_file($image);
     parent::set_from_pixbuf($pixbuf);
 }
 public function minimize_onprint($widget, $event)
 {
     $pixbuf = GdkPixbuf::new_from_file($this->minimizeImage);
     $w = $pixbuf->get_width();
     $h = $pixbuf->get_height();
     $x = $widget->allocation->width - $w;
     $y = 0;
     $widget->window->draw_pixbuf($widget->style->bg_gc[Gtk::STATE_NORMAL], $pixbuf, 0, 0, $x, $y);
     return TRUE;
 }
function icontip($widget, $x, $y, $keyboard_mode, $tooltip)
{
    $tooltip->set_icon(GdkPixbuf::new_from_file(dirname(__FILE__) . '/../apple-red.png'));
    return true;
    // return false or nothing to NOT show a tooltip
}
 /**
  * Fill one level of the treeview
  * @param $options array of options
  * @ignore-autocomplete on
  */
 private function fromOptions($parent, $options)
 {
     if (is_array($options)) {
         foreach ($options as $key => $option) {
             if (is_scalar($option)) {
                 $iter = $this->model->append($parent);
                 $pixbuf = GdkPixbuf::new_from_file('app/images/' . $this->itemIcon);
                 $this->model->set($iter, 0, $pixbuf);
                 $this->model->set($iter, 1, $option);
                 $this->model->set($iter, 2, array('key' => $key, 'value' => $option));
                 $this->model->set($iter, 3, 'child');
             } else {
                 if (is_array($option)) {
                     $iter = $this->model->append($parent);
                     $pixbuf = GdkPixbuf::new_from_file('lib/adianti/include/ttreeview/ico_folder.png');
                     $this->model->set($iter, 0, $pixbuf);
                     $this->model->set($iter, 1, $key);
                     $this->model->set($iter, 2, array('key' => $key, 'value' => $option));
                     $this->model->set($iter, 3, 'parent');
                     $this->fromOptions($iter, $option);
                 }
             }
         }
     }
 }
 function show_cell($cell, $content, $sel_options, $readonlys, $cname, $show_c, $show_row, &$span, &$result)
 {
     if ($this->debug >= 3 || $this->debug == $cell['type']) {
         echo "<p>etemplate.show_cell({$this->name},name='{$cell['name']}',type='{$cell['type']}',cname='{$cname}')</p>\n";
     }
     list($span) = explode(',', $cell['span']);
     // evtl. overriten later for type template
     $name = $this->expand_name($cell['name'], $show_c, $show_row, $content['.c'], $content['.row'], $content);
     // building the form-field-name depending on prefix $cname and possibl. Array-subscript in name
     if (ereg('^([^[]*)(\\[.*\\])$', $name, $regs)) {
         $form_name = $cname == '' ? $name : $cname . '[' . $regs[1] . ']' . $regs[2];
         eval(str_replace(']', "']", str_replace('[', "['", '$value = $content[' . $regs[1] . ']' . $regs[2] . ';')));
         $org_name = substr($regs[2], 1, -1);
         eval(str_replace(']', "']", str_replace('[', "['", '$var = &$result[' . $regs[1] . ']' . $regs[2] . ';')));
     } else {
         $form_name = $cname == '' ? $name : $cname . '[' . $name . ']';
         $value = $content[$name];
         $org_name = $name;
         $var =& $result[$name];
     }
     $readonly = $cell['readonly'] || $readonlys[$name] || $readonlys['__ALL__'];
     if ($cell['disabled'] || $cell['type'] == 'button' && $readonly) {
         if ($this->rows == 1) {
             return '';
             // if only one row omit cell
         }
         $cell = $this->empty_cell();
         // show nothing
         $value = '';
     }
     if ($cell['onchange']) {
         $options .= ' onChange="' . ($cell['onchange'] == '1' ? 'this.form.submit();' : $cell['onchange']) . '"';
     }
     if (strlen($label = $cell['label']) > 1) {
         $label = lang($label);
     }
     list($left_label, $right_label) = explode('%s', $label);
     //echo "show_cell: type='$cell[type]', name='$cell[name]'-->'$name', value='$value'\n";
     $widget = False;
     switch ($cell['type']) {
         case 'label':
             //  size: [[b]old][[i]talic]
             $value = strlen($value) > 1 && !$cell['no_lang'] ? lang($value) : $value;
             //if ($value != '' && strstr($cell['size'],'b')) $value = $this->html->bold($value);
             //if ($value != '' && strstr($cell['size'],'i')) $value = $this->html->italic($value);
             $html .= $value;
             if ($value) {
                 $widget =& new GtkLabel($value);
                 if ($cell['align'] != 'center') {
                     $widget->set_justify($cell['align'] == 'right' ? GTK_JUSTIFY_RIGHT : GTK_JUSTIFY_LEFT);
                 }
             }
             break;
         case 'raw':
             //$html .= $value;
             break;
         case 'int':
             // size: [min][,[max][,len]]
         // size: [min][,[max][,len]]
         case 'float':
             list($min, $max, $cell['size']) = explode(',', $cell['size']);
             if ($cell['size'] == '') {
                 $cell['size'] = $cell['type'] == 'int' ? 5 : 8;
             }
             // fall-through
         // fall-through
         case 'text':
             // size: [length][,maxLength]
             if ($readonly) {
                 //$html .= $this->html->bold($value);
             } else {
                 //$html .= $this->html->input($form_name,$value,'',$options.$this->html->formatOptions($cell['size'],'SIZE,MAXLENGTH'));
             }
             list($len, $max) = explode(',', $cell['size']);
             $widget =& new GtkEntry();
             $widget->set_text($value);
             if ($max) {
                 $widget->set_max_length($max);
             }
             $widget->set_editable(!$readonly);
             if ($len) {
                 $widget->set_usize($len * $this->font_width, 0);
             }
             break;
         case 'textarea':
             // Multiline Text Input, size: [rows][,cols]
             //$html .= $this->html->textarea($form_name,$value,$options.$this->html->formatOptions($cell['size'],'ROWS,COLS'));
             $widget =& new GtkText(null, null);
             $widget->insert_text($value, strlen($value));
             $widget->set_editable(!$readonly);
             break;
             /*				case 'date':
             					if ($cell['size'] != '')
             					{
             						$date = split('[/.-]',$value);
             						$mdy  = split('[/.-]',$cell['size']);
             						for ($value=array(),$n = 0; $n < 3; ++$n)
             						{
             							switch($mdy[$n])
             							{
             								case 'Y': $value[0] = $date[$n]; break;
             								case 'm': $value[1] = $date[$n]; break;
             								case 'd': $value[2] = $date[$n]; break;
             							}
             						}
             					}
             					else
             					{
             						$value = array(date('Y',$value),date('m',$value),date('d',$value));
             					}
             					if ($readonly)
             					{
             						$html .= $GLOBALS['phpgw']->common->dateformatorder($value[0],$value[1],$value[2]);
             					}
             					else
             					{
             						$html .= $this->sbox->getDate($name.'[Y]',$name.'[m]',$name.'[d]',$value,$options);
             					}
             					break;
             */
         /*				case 'date':
         					if ($cell['size'] != '')
         					{
         						$date = split('[/.-]',$value);
         						$mdy  = split('[/.-]',$cell['size']);
         						for ($value=array(),$n = 0; $n < 3; ++$n)
         						{
         							switch($mdy[$n])
         							{
         								case 'Y': $value[0] = $date[$n]; break;
         								case 'm': $value[1] = $date[$n]; break;
         								case 'd': $value[2] = $date[$n]; break;
         							}
         						}
         					}
         					else
         					{
         						$value = array(date('Y',$value),date('m',$value),date('d',$value));
         					}
         					if ($readonly)
         					{
         						$html .= $GLOBALS['phpgw']->common->dateformatorder($value[0],$value[1],$value[2]);
         					}
         					else
         					{
         						$html .= $this->sbox->getDate($name.'[Y]',$name.'[m]',$name.'[d]',$value,$options);
         					}
         					break;
         */
         case 'checkbox':
             if ($value) {
                 $options .= ' CHECKED';
             }
             //$html .= $this->html->input($form_name,'1','CHECKBOX',$options);
             $widget =& new GtkCheckButton($right_label);
             $right_label = '';
             $widget->set_active($value);
             break;
         case 'radio':
             // size: value if checked
             if ($value == $cell['size']) {
                 $options .= ' CHECKED';
             }
             //$html .= $this->html->input($form_name,$cell['size'],'RADIO',$options);
             if (isset($this->buttongroup[$form_name])) {
                 $widget =& new GtkRadioButton($this->buttongroup[$form_name], $right_label);
             } else {
                 $this->buttongroup[$form_name] = $widget =& new GtkRadioButton(null, $right_label);
             }
             $right_label = '';
             $widget->set_active($value == $cell['size']);
             break;
         case 'button':
             //$html .= $this->html->submit_button($form_name,$cell['label'],'',strlen($cell['label']) <= 1 || $cell['no_lang'],$options);
             $widget =& new GtkButton(strlen($cell['label']) > 1 ? lang($cell['label']) : $cell['label']);
             $widget->connect_object('clicked', array('etemplate', 'button_clicked'), &$var, $form_name);
             break;
         case 'hrule':
             //$html .= $this->html->hr($cell['size']);
             $widget =& new GtkHSeparator();
             break;
         case 'template':
             // size: index in content-array (if not full content is past further on)
             if ($this->autorepeat_idx($cell, $show_c, $show_row, $idx, $idx_cname) || $cell['size'] != '') {
                 if ($span == '' && isset($content[$idx]['span'])) {
                     // this allows a colspan in autorepeated cells like the editor
                     $span = explode(',', $content[$idx]['span']);
                     $span = $span[0];
                     if ($span == 'all') {
                         $span = 1 + $content['cols'] - $show_c;
                     }
                 }
                 $readonlys = $readonlys[$idx];
                 $content = $content[$idx];
                 $var =& $result[$idx];
                 if ($idx_cname != '') {
                     $cname .= $cname == '' ? $idx_cname : "[{$idx_cname}]";
                 }
                 //echo "<p>show_cell-autorepeat($name,$show_c,$show_row,cname='$cname',idx='$idx',idx_cname='$idx_cname',span='$span'): readonlys[$idx] ="; _debug_array($readonlys);
             } else {
                 $var =& $result;
             }
             if ($readonly) {
                 $readonlys['__ALL__'] = True;
             }
             $templ = is_object($cell['name']) ? $cell['name'] : new etemplate($name);
             $templ->widgets =& $this->widgets;
             //$html .= $templ->show($content,$sel_options,$readonlys,$cname,$show_c,$show_row);
             $widget = $templ->show($var, $content, $sel_options, $readonlys, $cname, $show_c, $show_row);
             break;
         case 'select':
             // size:[linesOnMultiselect]
             if (isset($sel_options[$name])) {
                 $sel_options = $sel_options[$name];
             } elseif (isset($sel_options[$org_name])) {
                 $sel_options = $sel_options[$org_name];
             } elseif (isset($content["options-{$name}"])) {
                 $sel_options = $content["options-{$name}"];
             }
             //$html .= $this->sbox->getArrayItem($form_name.'[]',$value,$sel_options,$cell['no_lang'],$options,$cell['size']);
             reset($sel_options);
             for ($maxlen = 0; list($key, $val) = each($sel_options);) {
                 if (!$cell['no_lang']) {
                     $sel_options[$key] = lang($val);
                 }
                 if (($len = strlen($sel_options[$key])) > $maxlen) {
                     $maxlen = $len;
                 }
             }
             $widget =& new GtkCombo();
             $widget->set_popdown_strings($sel_options);
             $entry = $widget->entry;
             $entry->set_text($sel_options[$value]);
             $entry->set_editable(False);
             $entry->set_usize($maxlen * $this->font_width, 0);
             if ($cell['onchange'] == '1') {
                 $entry->connect('changed', array('etemplate', 'submit'));
             }
             break;
             /*				case 'select-percent':
             					$html .= $this->sbox->getPercentage($form_name,$value,$options);
             					break;
             				case 'select-priority':
             					$html .= $this->sbox->getPriority($form_name,$value,$options);
             					break;
             				case 'select-access':
             					$html .= $this->sbox->getAccessList($form_name,$value,$options);
             					break;
             				case 'select-country':
             					$html .= $this->sbox->getCountry($form_name,$value,$options);
             					break;
             				case 'select-state':
             					$html .= $this->sbox->list_states($form_name,$value);  // no helptext - old Function!!!
             					break;
             				case 'select-cat':
             					$html .= $this->sbox->getCategory($form_name.'[]',$value,$cell['size'] >= 0,
             						False,$cell['size'],$options);
             					break;
             				case 'select-account':
             					$type = substr(strstr($cell['size'],','),1);
             					if ($type == '')
             					{
             						$type = 'accounts';	// default is accounts
             					}
             					$html .= $this->sbox->getAccount($form_name.'[]',$value,2,$type,0+$cell['size'],$options);
             					break;
             */
         /*				case 'select-percent':
         					$html .= $this->sbox->getPercentage($form_name,$value,$options);
         					break;
         				case 'select-priority':
         					$html .= $this->sbox->getPriority($form_name,$value,$options);
         					break;
         				case 'select-access':
         					$html .= $this->sbox->getAccessList($form_name,$value,$options);
         					break;
         				case 'select-country':
         					$html .= $this->sbox->getCountry($form_name,$value,$options);
         					break;
         				case 'select-state':
         					$html .= $this->sbox->list_states($form_name,$value);  // no helptext - old Function!!!
         					break;
         				case 'select-cat':
         					$html .= $this->sbox->getCategory($form_name.'[]',$value,$cell['size'] >= 0,
         						False,$cell['size'],$options);
         					break;
         				case 'select-account':
         					$type = substr(strstr($cell['size'],','),1);
         					if ($type == '')
         					{
         						$type = 'accounts';	// default is accounts
         					}
         					$html .= $this->sbox->getAccount($form_name.'[]',$value,2,$type,0+$cell['size'],$options);
         					break;
         */
         case 'image':
             if (!($path = $GLOBALS['phpgw']->common->image(substr($this->name, 0, strpos($this->name, '.')), $cell['label']))) {
                 $path = $cell['label'];
             }
             // name may already contain absolut path
             if (!isset($GLOBALS['phpgw_info']['etemplate']['pixbufs'][$path])) {
                 $GLOBALS['phpgw_info']['etemplate']['pixbufs'][$path] = GdkPixbuf::new_from_file('../..' . $path);
             }
             $pixbuf =& $GLOBALS['phpgw_info']['etemplate']['pixbufs'][$path];
             if ($pixbuf) {
                 $widget =& new GtkDrawingArea();
                 $widget->size($pixbuf->get_width(), $pixbuf->get_height());
                 $widget->connect('expose_event', array('etemplate', 'draw_image'), $pixbuf);
             } else {
                 echo "Can't load image '{$path}'";
             }
             break;
         default:
             //$html .= '<i>unknown type</i>';
             $widget =& new GtkLabel('unknown type: ' . $cell['type']);
             $widget->set_justify(GTK_JUSTIFY_LEFT);
             break;
     }
     if ($widget && !$readonly && !$this->no_result[$cell['type']]) {
         $this->widgets[] = array('widget' => &$widget, 'type' => $cell['type'], 'set_val' => $cell['type'] == 'radio' ? $cell['size'] : $sel_options, 'name' => $form_name, 'readonly' => $readonly);
     }
     if ($cell['type'] != 'button' && $cell['type'] != 'image' && ($left_label || $right_label)) {
         if (!$widget && !$right_label) {
             $widget =& new GtkLabel($left_label);
         } else {
             $hbox =& new GtkHBox(False, 5);
             if ($left_label) {
                 $left =& new GtkLabel($left_label);
                 $left->show();
                 $hbox->add($left);
             }
             if ($widget) {
                 $widget->show();
                 $hbox->add($widget);
             }
             if ($right_label) {
                 $right =& new GtkLabel($right_label);
                 $right->show();
                 $hbox->add($right);
             }
         }
     }
     if ($cell['help'] && $widget) {
         if (!$this->tooltips) {
             $this->tooltips =& new GtkTooltips();
         }
         $this->tooltips->set_tip($widget, lang($cell['help']), $this->name . '/' . $form_name);
     }
     return $hbox ? $hbox : $widget;
 }
Exemple #17
0
 /**
  * Retorna un modelo de comandos administrativos disponibles
  */
 function cargar_comandos($seleccionar_proyecto = null)
 {
     $instalacion = $this->toba_instalador->get_instalacion();
     //---El formato es Nombre,Imagen,Clave, Label
     $modelo = new GtkTreeStore(Gtk::TYPE_STRING, Gtk::TYPE_OBJECT, Gtk::TYPE_STRING, Gtk::TYPE_STRING);
     $path = toba_nucleo::toba_dir() . '/www/img/instalacion.png';
     $img = GdkPixbuf::new_from_file($path);
     $raiz = null;
     $path_inst = $instalacion->get_dir();
     $nodo_instal = $modelo->append($raiz, array('Instalación', $img, 'instalacion', "Instalación"));
     $seleccion = null;
     if ($instalacion->existe_info_basica()) {
         //---Agrega las instancias
         foreach ($instalacion->get_lista_instancias() as $id_instancia) {
             $instancia = $instalacion->get_instancia($id_instancia);
             $path = toba_nucleo::toba_dir() . '/www/img/instancia.gif';
             $img = GdkPixbuf::new_from_file($path);
             $nodo_inst = $modelo->append($nodo_instal, array($id_instancia, $img, 'instalacion/' . $id_instancia, "Instancia {$id_instancia}"));
             //---Agrega los proyectos
             $path = toba_nucleo::toba_dir() . '/www/img/nucleo/proyecto.gif';
             $img = GdkPixbuf::new_from_file($path);
             foreach ($instancia->get_lista_proyectos_vinculados() as $id_proyecto) {
                 $nodo_pro = $modelo->append($nodo_inst, array($id_proyecto, $img, 'instalacion/' . $id_instancia . '/' . $id_proyecto, "Proyecto {$id_proyecto}"));
                 if ($id_proyecto == $seleccionar_proyecto) {
                     $seleccion = $nodo_pro;
                 }
             }
         }
         //---BASES
         $path = toba_nucleo::toba_dir() . '/www/img/fuente.png';
         $img = GdkPixbuf::new_from_file($path);
         $nodo_bases = $modelo->append($raiz, array('Bases', $img, 'base', 'Bases de Toba'));
         foreach ($instalacion->get_lista_bases() as $db) {
             $modelo->append($nodo_bases, array($db, $img, 'base_' . $db, "Base '{$db}'"));
         }
     }
     //--- Comandos extra
     $path = toba_nucleo::toba_dir() . '/www/img/cpu.png';
     $img = GdkPixbuf::new_from_file($path);
     $modelo->append($raiz, array('Núcleo', $img, 'nucleo', 'Núcleo de Toba'));
     $path = toba_nucleo::toba_dir() . '/www/img/ayuda.png';
     $img = GdkPixbuf::new_from_file($path);
     $modelo->append($raiz, array('Documentación', $img, 'doc', 'Documentación'));
     $path = toba_nucleo::toba_dir() . '/www/img/objetos/item.gif';
     $img = GdkPixbuf::new_from_file($path);
     $modelo->append($raiz, array('Items', $img, 'item', 'Items'));
     $path = toba_nucleo::toba_dir() . '/www/img/testing.gif';
     $img = GdkPixbuf::new_from_file($path);
     $modelo->append($raiz, array('Testing', $img, 'test', 'Testing'));
     //--- Expansion
     $this->comp['arbol_comandos']->set_model($modelo);
     $this->comp['arbol_comandos']->expand_row(0, true);
     if (isset($seleccion)) {
         return $seleccion;
     }
 }
Exemple #18
0
function timerSpin($file)
{
    // Timer which checks if Inkscape created preview of file
    global $timerSpin, $_preview;
    if (file_exists("{$file}.nul")) {
        // Preview created;
        Gtk::timeout_remove($timerSpin);
        $timerSpin = null;
        try {
            // Try to load the file to don't crash when file is broken
            $pixBuffer = GdkPixbuf::new_from_file_at_size($file, 200, 270);
            $_preview->set_from_pixbuf($pixBuffer);
        } catch (Exception $e) {
            gtIcon($_preview, Gtk::STOCK_MISSING_IMAGE);
        }
        unlink($file);
        unlink("{$file}.nul");
        spinnerToggle(false);
        return false;
    }
    return true;
}