[PHP-GTK]TrayBar

Started by Magrinho Loko, 14 de February , 2008, 01:08:59 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Magrinho Loko

Um code interessante, que eu consegui em algum lugar em um passado bem distante. Ele serve para incluir os codes criados em GTK na traybar (:

<?
/*
 * A sua classe principal, aquela aonde ficará a janela que surgirá como principal
 */
     class Principal{
      //Criando a função responsavel pela janela, botões, cores e afins
          function __construct(){             
              $window = $this->window = new GtkWindow();
              $window->set_title('..: Exemplo :..');
              $window->set_resizable(FALSE);
              $fixed = $this->fixed = new GtkFixed();
              //CENTRALIZA JANELA
              $window->set_position(GTK::WIN_POS_CENTER);
                         
              $text = $this->text = new GtkLabel();
    $text->set_markup("<span color='red'><b>Esse é um pograma que fica visivel após você selecionar o item Ver no traybar \n\t Até a próxima ;]</b></span>");
             
              $fixed->put($text,0,0);
             
              $pixbuf = $window->render_icon(
    Gtk::STOCK_FIND,
    Gtk::ICON_SIZE_DIALOG
  );
  $window->set_icon($pixbuf);
              $window->add($fixed);
              $window->connect_simple('destroy', array('Gtk', 'main_quit'));
              $window->show_all();
         }


     }
/*
 * A classe responsável por inserir no Traybar - Classe gringa, ou seja, trate-a bem,
 * e ela lhe manterá na vida boa por um bom tempo.
 */
class TrayApplication extends Principal{
   /**
    * Application Tray Menu
    *
    * @var GtkMenu
    */
   protected $_menu;
   /**
    * Application Tray Icon
    *
    * @var GtkStatusIcon
    */
   protected $_tray;
   /**
    * Application Constructor
    *
    * @param string $tooltip Tooltip to display for GtkStatusIcon object
    * @return void
    */
    //Criando a mágica
    public function __construct($tooltip) {
      $this->_menu = new GtkMenu();
      $this->_tray = new GtkStatusIcon();
      $this->_tray->set_tooltip($tooltip);
      $this->_tray->set_from_stock(Gtk::STOCK_EXECUTE);
      $this->_tray->connect('popup-menu', array($this, 'onMenu'));
     
      $verp = new GtkMenuItem('Ver');
      $verp->connect('activate', array($this, 'verP'));
      $this->_menu->append($verp);
     
      $quit = new GtkMenuItem('Sair');
      $quit->connect('activate', array($this, 'onQuit'));
      $this->_menu->append($quit);
     
      $this->_menu->show_all();
 
      $this->_tray->set_visible(true);
      $this->_tray->set_blinking(false);
 
      GtkStatusIcon::position_menu($this->_menu, $this->_tray);
 
      Gtk::main();
    }
    /**
     * Application Destructor
     *
     * @return void
     */
    public function __destruct() {
      @Gtk::main_quit();
    }
    /**
     * Event handler for onQuit
     *
     * @return void
     */
    public function onQuit() {
      $this->__destruct();
    }
    /**
     * Event handler for onMenu
     *
     * @return void
     */
    public function onMenu() {
      $this->_menu->popup();
    }
    /**
     * Mostra a janela do teu programa
     */
     function verP(){
        parent::__construct();
    }
  }
   
    //Exibe o programa, colocando ele no traybar.
   
     new TrayApplication('Teste');
     Gtk::main();
?>

Não lembro o autor do code original, mas enfim, foi um ser iluminado xD
Saudades do antigo Darkers.

rodweb

Esse código é novo? aqui não encontrou uma das classes...

Flws...

Magrinho Loko

Quote from: "rodweb"Esse código é novo? aqui não encontrou uma das classes...

Flws...

php-gtk2

Um site interessante que fala sobre isso tbm

http://www.kksou.com/php-gtk2
Saudades do antigo Darkers.