File: tour-events.page

package info (click to toggle)
gnome-devel-docs 3.14.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 46,300 kB
  • ctags: 630
  • sloc: xml: 2,321; ansic: 2,040; python: 1,807; makefile: 747; sh: 504; cpp: 131
file content (76 lines) | stat: -rw-r--r-- 2,747 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?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="es">

  <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>Asociar funciones a eventos usando Lang.</desc>
  
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
      <mal:name>Daniel Mustieles</mal:name>
      <mal:email>daniel.mustieles@gmail.com</mal:email>
      <mal:years>2011-2014</mal:years>
    </mal:credit>
  
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
      <mal:name>Jorge González</mal:name>
      <mal:email>jorgegonz@svn.gnome.org</mal:email>
      <mal:years>2007-2010</mal:years>
    </mal:credit>
  
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
      <mal:name>Mario Carrión</mal:name>
      <mal:email>mario@monouml.org</mal:email>
      <mal:years>2006</mal:years>
    </mal:credit>
  </info>

  <title>Acciones y señales</title>

  <links type="prevnext" style="top"/>
  <links type="series" style="floatend">
    <title>Primeros pasos en GNOME</title>
  </links>

  <p>GTK+ tiene una serie de eventos predefinidos que puede usar en su aplicación.</p>
  <example>
    <p>Declare <code>HelloWorld</code> como una clase <code>Lang</code> nueva. Gjs requiere que las clases tengan la propiedad Nombre definida.</p>

    <code>
const HelloWorld = new Lang.Class({
    Name: 'HelloWorld',
</code>

    <p>Se llama a <code>_init</code> cuando se crea una instancia nueva. Cree una <code>GtkApplication</code>, conecte la señal <code>activate</code> al evento <code>_onActivate</code> de GTK+ existente y <code>startup</code> a <code>_onStartup</code>:</p>

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

    <p>Mostrar la ventana al activar la aplicación:</p>
    <code>
    _onActivate: function(){
        this._window.show_all();
    },
</code>
  </example>
  <links type="prevnext"/>
</page>