<?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" lang="ru">

  <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>

    <license xmlns="http://projectmallard.org/1.0/" href="http://creativecommons.org/licenses/by-sa/3.0/us/">
<p>This work is licensed under a
<link href="http://creativecommons.org/licenses/by-sa/3.0/us/">Creative Commons
Attribution-Share Alike 3.0 United States License</link>.</p>
<p>As a special exception, the copyright holders give you permission to copy,
modify, and distribute the example code contained in this document under the
terms of your choosing, without restriction.</p>
</license>

    <desc>Bind functions to events using Lang.</desc>
  </info>

  <title>Actions and signals</title>

  <links type="prevnext" style="top"/>
  <links type="series" style="floatend">
    <title>Get started with GNOME</title>
  </links>

  <p>Gtk has a set of predefined events that you can use in your application.</p>
  <example>
    <p>Declare <code>HelloWorld</code> as a new class.</p>

    <code>
class HelloWorld {
</code>

    <p><code>constructor</code> is called when a new instance is created. Create a
    <code>GtkApplication</code>, then connect <code>activate</code> to the
    existing Gtk event <code>_onActivate</code> and <code>startup</code> to
    <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>Show the window upon application activation:</p>
    <code>
    _onActivate() {
        this._window.show_all();
    }
</code>
  </example>
  <links type="prevnext"/>
</page>
