/**
  * Seta um tooltip ao botão
  * 
  * @name set_tooltip($tip, $description="")
  * @param string $tip String para o tooltip
  * @param string $description String para a descrição longa
  */
 public function set_tooltip($tip, $description = "")
 {
     // Cria o tooltip
     $tt = new GtkTooltips();
     // Configura o tooltip
     $tt->set_tip($this, $tip, $description);
 }
 public function toolbarLoadXML($file, $mainObject = NULL)
 {
     // Lê o XML
     // @since rev 1
     $xml = new SimpleXMLElement(file_get_contents($file));
     // Cria o frame, o scrool e o treeview
     // @since rev 1
     $obj['object'] = new GtkToolBar();
     $toolbarName = (string) $xml['name'];
     $obj['object']->set_tooltips(TRUE);
     $clicked = (string) $xml['clicked'];
     // Percorre as configurações
     // @since rev 1
     $counter = 0;
     foreach ($xml as $toolitems) {
         // Verifica o tipo de configuração
         // @since rev 1
         if ($toolitems->getName() == "stockitem") {
             // Ajusta as informações
             // @since rev 1
             $toolitems = $toolitems[0];
             // Busca as configurações
             // @since rev 1
             $title = (string) $toolitems['title'];
             $name = (string) $toolitems['name'];
             $stock = (string) $toolitems['stock'];
             // Cria o botao
             // @since rev 1
             $obj[$name] = GtkToolButton::new_from_stock(constant($stock));
             $obj['object']->insert($obj[$name], $counter);
             // Adiciona o evento se houver
             // @since rev 1
             if (strlen($clicked) > 0) {
                 // Verifica se é orientado à objeto
                 // @since rev 1
                 if ($mainObject != NULL) {
                     $function = array($mainObject, $clicked);
                 } else {
                     $function = $clicked;
                 }
                 $obj[$name]->connect("clicked", $function, $name);
             }
             // Verifica se esta desabilitado
             // @since rev 1
             switch (strtoupper((string) $toolitems['enabled'])) {
                 case "FALSE":
                     $enabled = FALSE;
                     break;
                 case "TRUE":
                 default:
                     $enabled = TRUE;
                     break;
             }
             $obj[$name]->set_sensitive($enabled);
             // Verifica se possui tooltip
             // @since rev
             if (isset($toolitems['tooltip'])) {
                 $tt = new GtkTooltips();
                 $tt->set_tip($obj[$name], (string) $toolitems['tooltip']);
                 unset($tt);
             }
         } else {
             if ($toolitems->getName() == "separator") {
                 $obj['object']->insert(new GtkSeparatorToolItem(), $counter);
             } else {
                 if ($toolitems->getName() == "toolitem") {
                     // Busca o nome do item
                     $name = (string) $toolitems['name'];
                     // Cria o item
                     $obj[$name] = new GtkToolItem();
                     // Adiciona o item ao toolbar
                     $obj['object']->insert($obj[$name], $counter);
                 }
             }
         }
         // Soma o contador
         // @since rev 1
         $counter++;
     }
     // Retorna o toolbar
     // @since rev 1
     return $obj;
 }
<?php

$tooltips = new GtkTooltips();
// there can be only one
function showtips($tipsquery, $widget, $tip_text, $tip_private)
{
    $tipsquery->set_text($tip_private);
    $tipsquery->emit_stop_by_name('widget-entered');
    return false;
}
function starttips($tipsquery, $tooltips)
{
    if ($tooltips->enabled) {
        $tipsquery->start_query();
        $tooltips->disable();
    } else {
        // $tipsquery->stop_query(); - this is automatic when the caller button is clicked
        $tooltips->enable();
    }
}
$window = new GtkWindow();
$window->set_title('Tooltip');
$window->connect_simple('destroy', array('gtk', 'main_quit'));
$window->add($vbox = new GtkVBox());
$vbox->pack_start($button = new GtkButton('Button1'));
$tooltips->set_tip($button, 'This is button 1', 'Here is some help for button 1');
$vbox->pack_start($button = new GtkButton('Button2'));
$tooltips->set_tip($button, 'This is button 2. This is also a really long tooltip which probably won\'t fit on a single line and will therefore need to be wrapped. Hopefully the wrapping will work correctly.', 'Here is some Help for button 2');
$vbox->pack_start($button = new GtkButton('Override TipsQuery Label'));
$tooltips->set_tip($button, 'Toggle TipsQuery view.', 'Help for Help?');
$popup = new GtkWindow(Gtk::WINDOW_POPUP);
Exemple #4
0
    print "Hello World!\n";
    $window->destroy();
}
/*
 * Create a new top-level window and connect the signals to the appropriate
 * functions. Note that all constructors must be assigned by reference.
 */
$window = new GtkWindow();
$window->connect('destroy', 'destroy');
$window->connect('delete-event', 'delete_event');
$window->set_border_width(10);
/*
 * Create a button, connect its clicked signal to hello() function and add
 * the button to the window.
 */
$button = new GtkButton('Hello World!');
$button->connect('clicked', 'hello');
/*
 * Create a new tooltips object and use it to set a tooltip for the button.
 */
$tt = new GtkTooltips();
$tt->set_delay(200);
$tt->set_tip($button, 'Prints "Hello World!"', '');
$tt->enable();
$window->add($button);
/*
 * Show the window and all its child widgets.
 */
$window->show_all();
/* Run the main loop. */
Gtk::main();