<?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-gjs" lang="zh-CN">

  <info>
    <link type="next" xref="tour-events"/>
    <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>Include bindings necessary to run your script.</desc>
  </info>

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

  <p><link href="https://wiki.gnome.org/Projects/Gjs">Gjs</link> is a
  JavaScript binding for GNOME and can be used to interact with Gtk. <link href="http://www.gtk.org/">Gtk</link> is a toolkit for creating graphical user
  interfaces.</p> <p>Open a text editor and paste in the lines of code. The
  complete script is available in the <link xref="tour-summary">Summary</link>.</p> <p>Create an <code>object</code> using
  your <code>class</code> and call the <code>run()</code> method:</p> <example>
  <p>Call the Gjs JavaScript binding. This instructs the shell to run this script
  with Gjs.</p>

  <code>
#!/usr/bin/gjs
</code>

  <p>Import <code>gi.Gtk</code> for <code>Gtk</code> functions. As both
  version 3.0 and 4.0 may be installed, make sure that the desired version
  is imported first.</p>

  <code>
imports.gi.versions.Gtk = '3.0';
const Gtk = imports.gi.Gtk;
</code>
</example>
  <links type="prevnext"/>
</page>
