Exemplo n.º 1
2
 /**
  * Constructor Method
  */
 public function __construct()
 {
     parent::__construct();
     $lang_manager = new GtkSourceLanguagesManager();
     $lang = $lang_manager->get_language_from_mime_type('application/x-php');
     $this->buffer = new GtkSourceBuffer();
     $this->buffer->set_language($lang);
     $this->buffer->set_highlight(true);
     $this->buffer->set_check_brackets(TRUE);
     $this->set_buffer($this->buffer);
     $default_font = OS == 'WIN' ? 'Courier 10' : 'Monospace 10';
     $pango = new PangoFontDescription($default_font);
     $this->modify_font($pango);
     $this->set_auto_indent(TRUE);
     $this->set_insert_spaces_instead_of_tabs(TRUE);
     $this->set_tabs_width(4);
     $this->set_show_margin(FALSE);
     $this->set_show_line_numbers(true);
     $this->set_show_line_markers(true);
     $this->set_highlight_current_line(TRUE);
     $this->set_smart_home_end(TRUE);
 }
 /**
  * Evento executado ao inserir um texto no editor
  * 
  * @name __inserted_text
  * @param GtkTextBuff $widget GtkTextBuff do editor
  * @param GtkTextIter $iter GtkTextIter do cursor
  */
 public function __inserted_text($widget, $iter, $arg1, $arg2)
 {
     // Verifica se deve mostrar o autocomplete
     if (strlen($this->__last_token) >= 2) {
         // Busca a posição do cursor do texto em relação à janela
         $cursor_location = parent::get_iter_location($iter);
         $window_location = $this->get_window(GTK::TEXT_WINDOW_WIDGET)->get_origin();
         $x = $cursor_location->x + $window_location[0];
         $y = $cursor_location->y + $window_location[1] + 15;
         // Seta a posição do dialog e mostra
         $this->__widgets['autocomplete']->set_uposition($x, $y);
         $this->__widgets['autocomplete']->show();
         // Retorna o foco ao editor
         $window = parent::get_parent();
         while (strtolower(get_class($window)) != "gtkwindow") {
             $window = $window->get_parent();
         }
         $window->has_focus();
     }
 }