Blob Blame History Raw
<?xml version="1.0" encoding="utf-8"?>
<page xmlns="http://projectmallard.org/1.0/" xmlns:its="http://www.w3.org/2005/11/its" type="topic" style="task" id="tour-events" xml:lang="pt-BR">

  <info>
    <link type="next" xref="tour-get_object"/>
    <revision version="0.1" date="2013-06-17" status="stub"/>

    <credit type="author copyright">
      <name>Ekaterina Gerasimova</name>
      <email its:translate="no">kittykat3756@gmail.com</email>
      <years>2013</years>
    </credit>
    <credit type="author copyright">
      <name>Gordon Hill</name>
      <email its:translate="no">caseyweederman@gmail.com</email>
      <years>2013</years>
    </credit>

    <include xmlns="http://www.w3.org/2001/XInclude" href="cc-by-sa-3-0.xml"/>

    <desc>Vincule funções a eventos usando Lang.</desc>
  
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
      <mal:name>Enrico Nicoletto</mal:name>
      <mal:email>liverig@gmail.com</mal:email>
      <mal:years>2009</mal:years>
    </mal:credit>
  
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
      <mal:name>Rafael Fontenelle</mal:name>
      <mal:email>rafaelff@gnome.org</mal:email>
      <mal:years>2013, 2014, 2016, 2017</mal:years>
    </mal:credit>
  
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
      <mal:name>Isaac Ferreira Filho</mal:name>
      <mal:email>isaacmob@riseup.net</mal:email>
      <mal:years>2018</mal:years>
    </mal:credit>
  </info>

  <title>Ações e sinais</title>

  <links type="prevnext" style="top"/>
  <links type="series" style="floatend">
    <title>Primeiros passos com GNOME</title>
  </links>

  <p>Gtk possui um conjunto de eventos pré-definidos que você pode usar em seu aplicativo.</p>
  <example>
    <p>Declare <code>HelloWorld</code> como uma nova classe.</p>

    <code>
class HelloWorld {
</code>

    <p><code>constructor</code> é chamado quando uma nova instância é criada. Crie um <code>GtkApplication</code> e, então, conecte <code>activate</code> ao evento Gtk existente <code>_onActivate</code> e <code>startup</code> para <code>_onStartup</code>:</p>

    <code>
    constructor() {
        this.application = new Gtk.Application();
        this.application.connect('activate', this._onActivate.bind(this));
        this.application.connect('startup', this._onStartup.bind(this));
    }
</code>

    <p>Mostre a janela na ativação do aplicativo:</p>
    <code>
    _onActivate() {
        this._window.show_all();
    }

</code>
  </example>
  <links type="prevnext"/>
</page>