Blame platform-demos/pt_BR/switch.js.page

Packit 1470ea
Packit 1470ea
<page xmlns="http://projectmallard.org/1.0/" xmlns:its="http://www.w3.org/2005/11/its" xmlns:xi="http://www.w3.org/2001/XInclude" type="guide" style="task" id="switch.js" xml:lang="pt-BR">
Packit 1470ea
  <info>
Packit 1470ea
  <title type="text">Switch (JavaScript)</title>
Packit 1470ea
    <link type="guide" xref="beginner.js#buttons"/>
Packit 1470ea
    <revision version="0.1" date="2012-06-18" status="draft"/>
Packit 1470ea
Packit 1470ea
    <credit type="author copyright">
Packit 1470ea
      <name>Taryn Fox</name>
Packit 1470ea
      <email its:translate="no">jewelfox@fursona.net</email>
Packit 1470ea
      <years>2012</years>
Packit 1470ea
    </credit>
Packit 1470ea
Packit 1470ea
    <desc>A sliding switch that can be flipped on and off</desc>
Packit 1470ea
  
Packit 1470ea
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
Packit 1470ea
      <mal:name>Rafael Ferreira</mal:name>
Packit 1470ea
      <mal:email>rafael.f.f1@gmail.com</mal:email>
Packit 1470ea
      <mal:years>2013</mal:years>
Packit 1470ea
    </mal:credit>
Packit 1470ea
  </info>
Packit 1470ea
Packit 1470ea
  <title>Switch</title>
Packit 1470ea
  <media type="image" mime="image/png" src="media/switchanimals.png"/>
Packit 1470ea
  

A Switch has two positions, on and off. This example shows how you can use multiple switches together to control which <link xref="image.js">Image</link> is shown in the window. The pictures used in this example <link href="https://live.gnome.org/TarynFox?action=AttachFile&do=get&target=Animal+Photos.zip">can be downloaded here</link>.

Packit 1470ea
  <note>

The window will contain a "broken image" icon instead of a picture if picture files named <file>redfox.png</file>, <file>muteswan.png</file>, <file>fruitbat.png</file>, and <file>gentoopenguin.png</file> aren't in the same directory. You can change the code and the pictures around as you like, but the Creative Commons-licensed photos used in this example were taken from the following sources and cropped to 640x425:

Packit 1470ea
    <list>
Packit 1470ea
        <item>

<link href="http://en.wikipedia.org/wiki/File:Fuzzy_Freddy.jpg">Red fox photo</link> by Rob Lee, licensed <link href="http://creativecommons.org/licenses/by/2.0/deed.en">CC-By</link>

</item>
Packit 1470ea
        <item>

<link href="http://en.wikipedia.org/wiki/File:Pygoscelis_papua_-Nagasaki_Penguin_Aquarium_-swimming_underwater-8a.jpg">Gentoo penguin photo</link> by Ken Funakoshi, licensed <link href="http://creativecommons.org/licenses/by-sa/2.0/deed.en">CC-By-SA</link>

</item>
Packit 1470ea
        <item>

<link href="http://www.flickr.com/photos/shekgraham/127431519/in/photostream/">Fruit bat photo</link> by Shek Graham, licensed <link href="http://creativecommons.org/licenses/by/2.0/deed.en">CC-By</link>

</item>
Packit 1470ea
        <item>

<link href="http://commons.wikimedia.org/wiki/File:Mute_Swan-Mindaugas_Urbonas.jpg">Mute swan photo</link> by Mindaugas Urbonas, licensed <link href="http://creativecommons.org/licenses/by-sa/2.5/deed.en">CC-By-SA</link>

</item>
Packit 1470ea
    </list>
Packit 1470ea
    

Photo credits and licensing information are shown in the application's <link xref="aboutdialog.js">AboutDialog</link>. Always remember to credit the original artist when using <link href="http://creativecommons.org">Creative Commons-licensed works!</link>

</note>
Packit 1470ea
    <links type="section"/>
Packit 1470ea
Packit 1470ea
  <section id="imports">
Packit 1470ea
    <title>Libraries to import</title>
Packit 1470ea
    
Packit 1470ea
#!/usr/bin/gjs
Packit 1470ea
Packit 1470ea
const Gio = imports.gi.Gio;
Packit 1470ea
const Gtk = imports.gi.Gtk;
Packit 1470ea
const Lang = imports.lang;
Packit 1470ea
]]>
Packit 1470ea
    

These are the libraries we need to import for this application to run. Remember that the line which tells GNOME that we're using Gjs always needs to go at the start.

Packit 1470ea
    </section>
Packit 1470ea
Packit 1470ea
  <section id="applicationwindow">
Packit 1470ea
    <title>Creating the application window</title>
Packit 1470ea
    
Packit 1470ea
const SwitchExample = new Lang.Class({
Packit 1470ea
    Name: 'Switch Example',
Packit 1470ea
Packit 1470ea
    // Create the application itself
Packit 1470ea
    _init: function() {
Packit 1470ea
        this.application = new Gtk.Application({
Packit 1470ea
            application_id: 'org.example.jsswitch',
Packit 1470ea
            flags: Gio.ApplicationFlags.FLAGS_NONE
Packit 1470ea
        });
Packit 1470ea
Packit 1470ea
    // Connect 'activate' and 'startup' signals to the callback functions
Packit 1470ea
    this.application.connect('activate', Lang.bind(this, this._onActivate));
Packit 1470ea
    this.application.connect('startup', Lang.bind(this, this._onStartup));
Packit 1470ea
    },
Packit 1470ea
Packit 1470ea
    // Callback function for 'activate' signal presents window when active
Packit 1470ea
    _onActivate: function() {
Packit 1470ea
        this._window.present();
Packit 1470ea
    },
Packit 1470ea
Packit 1470ea
    // Callback function for 'startup' signal creates the menu and builds the UI
Packit 1470ea
    _onStartup: function() {
Packit 1470ea
        this._initMenus();
Packit 1470ea
        this._buildUI ();
Packit 1470ea
    },
Packit 1470ea
]]>
Packit 1470ea
    

All the code for this sample goes in the SwitchExample class. The above code creates a <link href="http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gtk.Application.html">Gtk.Application</link> for our widgets and window to go in.

Packit 1470ea
    <note>

Before we call _buildUI to create the window and the widgets inside it, we need to call _initMenus, which tells GNOME to create the menu. We can put the actual code for _initMenus after the code for _buildUI, since it doesn't matter what order we put them in so long as _initMenus is called first in _onStartup.

</note>
Packit 1470ea
    
Packit 1470ea
    // Build the application's UI
Packit 1470ea
    _buildUI: function() {
Packit 1470ea
Packit 1470ea
        // Create the application window
Packit 1470ea
        this._window = new Gtk.ApplicationWindow({
Packit 1470ea
            application: this.application,
Packit 1470ea
            window_position: Gtk.WindowPosition.CENTER,
Packit 1470ea
            border_width: 20,
Packit 1470ea
            title: "Animal Creator"});
Packit 1470ea
]]>
Packit 1470ea
    

The _buildUI function is where we put all the code to create the application's user interface. The first step is creating a new <link xref="GtkApplicationWindow.js">Gtk.ApplicationWindow</link> to put all our widgets into.

Packit 1470ea
  </section>
Packit 1470ea
Packit 1470ea
  <section id="button">
Packit 1470ea
    <title>Creating the switches</title>
Packit 1470ea
    
Packit 1470ea
        // Create the image widget and set its default picture
Packit 1470ea
        this._image = new Gtk.Image ({file: "redfox.png"});
Packit 1470ea
]]>
Packit 1470ea
Packit 1470ea
    

We first create the <link xref="image.js">Image</link> that the switches will control. Remember that a file named <file>redfox.png</file> needs to be in the same directory as this application.

Packit 1470ea
Packit 1470ea
    
Packit 1470ea
        // Create a label for the first switch
Packit 1470ea
        this._flyLabel = new Gtk.Label ({
Packit 1470ea
            label: "Make it fly",
Packit 1470ea
            margin_right: 30});
Packit 1470ea
Packit 1470ea
        // Create the first switch and set its default position
Packit 1470ea
        this._flySwitch = new Gtk.Switch ({active: false});
Packit 1470ea
        this._flySwitch.connect ('notify::active', Lang.bind (this, this._switchFlip));
Packit 1470ea
Packit 1470ea
        // Create a label for the second switch
Packit 1470ea
        this._birdLabel = new Gtk.Label ({
Packit 1470ea
            label: "Make it a bird",
Packit 1470ea
            margin_right: 30});
Packit 1470ea
Packit 1470ea
        // Create the second switch
Packit 1470ea
        this._birdSwitch = new Gtk.Switch ({active: false});
Packit 1470ea
        this._birdSwitch.connect ('notify::active', Lang.bind (this, this._switchFlip));
Packit 1470ea
]]>
Packit 1470ea
Packit 1470ea
    

We use a <link xref="label.js">Label</link> to mark each Switch, and give them a bit of a margin on the right so that they aren't crammed right next to the Switches. After that we create the Switches, and set them to be switched off by default.

Packit 1470ea
    

The signal a switch sends out when it's flipped on or off is called notify::active. After we create each switch, we connect its notify::active signal to a function called _switchFlip. If you have multiple switches that each do something different, you might want to connect them to different functions, but here they're both used for the same thing: To control what picture's displayed by _image.

Packit 1470ea
Packit 1470ea
    
Packit 1470ea
        // Create a grid for the labels and switches beneath the picture
Packit 1470ea
        this._UIGrid = new Gtk.Grid ({
Packit 1470ea
            halign: Gtk.Align.CENTER,
Packit 1470ea
            valign: Gtk.Align.CENTER,
Packit 1470ea
            margin_top: 20});
Packit 1470ea
Packit 1470ea
        // Attach the labels and switches to that grid
Packit 1470ea
        this._UIGrid.attach (this._flyLabel, 0, 0, 1, 1);
Packit 1470ea
        this._UIGrid.attach (this._flySwitch, 1, 0, 1, 1);
Packit 1470ea
        this._UIGrid.attach (this._birdLabel, 0, 1, 1, 1);
Packit 1470ea
        this._UIGrid.attach (this._birdSwitch, 1, 1, 1, 1);
Packit 1470ea
Packit 1470ea
        // Create a master grid to put both the UI and the picture into
Packit 1470ea
        this._mainGrid = new Gtk.Grid ({
Packit 1470ea
            halign: Gtk.Align.CENTER,
Packit 1470ea
            valign: Gtk.Align.CENTER });
Packit 1470ea
Packit 1470ea
        // Attach the picture and the UI grid to the master grid
Packit 1470ea
        this._mainGrid.attach (this._image, 0, 0, 1, 1);
Packit 1470ea
        this._mainGrid.attach (this._UIGrid, 0, 1, 1, 1);
Packit 1470ea
]]>
Packit 1470ea
    

We create a <link xref="grid.js">Grid</link> for the Labels and Switches first, so that we can organize them in a 2x2 layout with a margin between it and the Image. Then we put that Grid into a larger 2x1 Grid that has the Image on top, and the Grid with the Labels and Switches on the bottom.

Packit 1470ea
    
Packit 1470ea
        // Add the master grid to the window
Packit 1470ea
        this._window.add (this._mainGrid);
Packit 1470ea
Packit 1470ea
        // Show the window and all child widgets
Packit 1470ea
        this._window.show_all();
Packit 1470ea
    },
Packit 1470ea
]]>
Packit 1470ea
    

Finally, we add the larger Grid to the window, then tell the window to show itself and all the widgets inside of it.

Packit 1470ea
    </section>
Packit 1470ea
Packit 1470ea
    <section id="switch-handler">
Packit 1470ea
    <title>Function which handles the switches being flipped</title>
Packit 1470ea
Packit 1470ea
    
Packit 1470ea
    _switchFlip: function() {
Packit 1470ea
Packit 1470ea
        // Change the picture depending on which switches are flipped
Packit 1470ea
        if (this._flySwitch.get_active()) {
Packit 1470ea
Packit 1470ea
            if (this._birdSwitch.get_active()) this._image.set_from_file ("muteswan.png");
Packit 1470ea
Packit 1470ea
            else this._image.set_from_file ("fruitbat.png");
Packit 1470ea
        }
Packit 1470ea
Packit 1470ea
        else {
Packit 1470ea
Packit 1470ea
            if (this._birdSwitch.get_active()) this._image.set_from_file ("gentoopenguin.png");
Packit 1470ea
Packit 1470ea
            else this._image.set_from_file ("redfox.png");
Packit 1470ea
Packit 1470ea
        }
Packit 1470ea
Packit 1470ea
    },
Packit 1470ea
]]>
Packit 1470ea
    

Each time a Switch is flipped, this function checks to see which of the two Switches are active afterwards, using the Switches' built-in get_active() function. It then changes the Image accordingly. You can change the filenames around as you like, so long as you have pictures to go with them.

Packit 1470ea
</section>
Packit 1470ea
Packit 1470ea
<section id="about">
Packit 1470ea
    <title>Creating the AboutDialog</title>
Packit 1470ea
    
Packit 1470ea
    _initMenus: function() {
Packit 1470ea
Packit 1470ea
        // Build the application's menu so we can have an "About" button
Packit 1470ea
        let menu = new Gio.Menu();
Packit 1470ea
        menu.append("About", 'app.about');
Packit 1470ea
        menu.append("Quit",'app.quit');
Packit 1470ea
        this.application.set_app_menu(menu);
Packit 1470ea
Packit 1470ea
        // Bind the "About" button to the _showAbout() function
Packit 1470ea
        let aboutAction = new Gio.SimpleAction ({ name: 'about' });
Packit 1470ea
        aboutAction.connect('activate', Lang.bind(this,
Packit 1470ea
            function() {
Packit 1470ea
                this._showAbout();
Packit 1470ea
            }));
Packit 1470ea
        this.application.add_action(aboutAction);
Packit 1470ea
Packit 1470ea
        // Bind the "Quit" button to the function that closes the window
Packit 1470ea
        let quitAction = new Gio.SimpleAction ({ name: 'quit' });
Packit 1470ea
        quitAction.connect('activate', Lang.bind(this,
Packit 1470ea
            function() {
Packit 1470ea
                this._window.destroy();
Packit 1470ea
            }));
Packit 1470ea
        this.application.add_action(quitAction);
Packit 1470ea
    },
Packit 1470ea
]]>
Packit 1470ea
    

The first step is building the <link xref="gmenu.js">GMenu</link> that the "About" button goes into. This is the menu that appears when you click the application's name in the upper-left corner of the screen, next to the Activities menu. Our menu only has two options in it: About, and Quit.

Packit 1470ea
Packit 1470ea
    
Packit 1470ea
    _showAbout: function () {
Packit 1470ea
Packit 1470ea
        // String arrays of the names of the people involved in the project
Packit 1470ea
        var artists = ['Rob Lee http://en.wikipedia.org/wiki/File:Fuzzy_Freddy.jpg', 'Ken Funakoshi http://en.wikipedia.org/wiki/File:Pygoscelis_papua_-Nagasaki_Penguin_Aquarium_-swimming_underwater-8a.jpg', 'Shek Graham http://www.flickr.com/photos/shekgraham/127431519/in/photostream/', 'Mindaugas Urbonas http://commons.wikimedia.org/wiki/File:Mute_Swan-Mindaugas_Urbonas.jpg'];
Packit 1470ea
        var authors = ["GNOME Documentation Team"];
Packit 1470ea
        var documenters = ["GNOME Documentation Team"];
Packit 1470ea
Packit 1470ea
        // Create the About dialog
Packit 1470ea
        let aboutDialog = new Gtk.AboutDialog({
Packit 1470ea
            title: "AboutDialog Example",
Packit 1470ea
            program_name: "Animal Creator",
Packit 1470ea
            copyright: "Copyright \xa9 2012 GNOME Documentation Team\n\nRed fox photo licensed CC-By by Rob Lee\nGentoo penguin photo licensed CC-By-SA by Ken Funakoshi\nFruit bat photo licensed CC-By by Shek Graham\nMute swan photo licensed CC-By-SA by Mindaugas Urbonas\nLinks to the originals are available under Credits.\n\nHave you hugged a penguin today?",
Packit 1470ea
            artists: artists,
Packit 1470ea
            authors: authors,
Packit 1470ea
            documenters: documenters,
Packit 1470ea
            website: "http://developer.gnome.org",
Packit 1470ea
            website_label: "GNOME Developer Website" });
Packit 1470ea
Packit 1470ea
        // Attach the About dialog to the window
Packit 1470ea
        aboutDialog.modal = true;
Packit 1470ea
        aboutDialog.transient_for = this._window;
Packit 1470ea
Packit 1470ea
        // Show the About dialog
Packit 1470ea
        aboutDialog.show();
Packit 1470ea
Packit 1470ea
        // Connect the Close button to the destroy signal for the dialog
Packit 1470ea
        aboutDialog.connect('response', function() {
Packit 1470ea
            aboutDialog.destroy();
Packit 1470ea
        });
Packit 1470ea
    }
Packit 1470ea
Packit 1470ea
});
Packit 1470ea
]]>
Packit 1470ea
    

An <link xref="aboutdialog.js">AboutDialog</link> has a lot of different things you can set, to credit everyone who worked on the application and leave a note to whomever reads it. In this case, the copyright section contains our note and credits the original photographers, while the artists section shows you a list of the photographers with links to the original photos when you click the Credits button. The web URLs put after their names in the array turn their names into clickable links in the Credits section.

Packit 1470ea
Packit 1470ea
    
Packit 1470ea
// Run the application
Packit 1470ea
let app = new SwitchExample ();
Packit 1470ea
app.application.run (ARGV);
Packit 1470ea
]]>
Packit 1470ea
    

Finally, we create a new instance of the finished SwitchExample class, and set the application running.

Packit 1470ea
  </section>
Packit 1470ea
Packit 1470ea
  <section id="complete">
Packit 1470ea
    <title>Amostra de código completo</title>
Packit 1470ea
#!/usr/bin/gjs
Packit 1470ea
Packit 1470ea
imports.gi.versions.Gtk = '3.0';
Packit 1470ea
Packit 1470ea
const Gio = imports.gi.Gio;
Packit 1470ea
const Gtk = imports.gi.Gtk;
Packit 1470ea
Packit 1470ea
class SwitchExample {
Packit 1470ea
Packit 1470ea
    // Create the application itself
Packit 1470ea
    constructor() {
Packit 1470ea
        this.application = new Gtk.Application({
Packit 1470ea
            application_id: 'org.example.jsswitch'
Packit 1470ea
        });
Packit 1470ea
Packit 1470ea
        // Connect 'activate' and 'startup' signals to the callback functions
Packit 1470ea
        this.application.connect('activate', this._onActivate.bind(this));
Packit 1470ea
        this.application.connect('startup', this._onStartup.bind(this));
Packit 1470ea
    }
Packit 1470ea
Packit 1470ea
    // Callback function for 'activate' signal presents window when active
Packit 1470ea
    _onActivate() {
Packit 1470ea
        this._window.present();
Packit 1470ea
    }
Packit 1470ea
Packit 1470ea
    // Callback function for 'startup' signal creates the menu and builds the UI
Packit 1470ea
    _onStartup() {
Packit 1470ea
        this._initMenus();
Packit 1470ea
        this._buildUI();
Packit 1470ea
    }
Packit 1470ea
Packit 1470ea
    // Build the application's UI
Packit 1470ea
    _buildUI() {
Packit 1470ea
Packit 1470ea
        // Create the application window
Packit 1470ea
        this._window = new Gtk.ApplicationWindow({
Packit 1470ea
            application: this.application,
Packit 1470ea
            window_position: Gtk.WindowPosition.CENTER,
Packit 1470ea
            border_width: 20,
Packit 1470ea
            title: "Animal Creator"});
Packit 1470ea
Packit 1470ea
        // Create the image widget and set its default picture
Packit 1470ea
        this._image = new Gtk.Image ({file: "redfox.png"});
Packit 1470ea
Packit 1470ea
        // Create a label for the first switch
Packit 1470ea
        this._flyLabel = new Gtk.Label ({
Packit 1470ea
            label: "Make it fly",
Packit 1470ea
            margin_right: 30});
Packit 1470ea
Packit 1470ea
        // Create the first switch and set its default position
Packit 1470ea
        this._flySwitch = new Gtk.Switch ({active: false});
Packit 1470ea
        this._flySwitch.connect ('notify::active', this._switchFlip.bind(this));
Packit 1470ea
Packit 1470ea
        // Create a label for the second switch
Packit 1470ea
        this._birdLabel = new Gtk.Label ({
Packit 1470ea
            label: "Make it a bird",
Packit 1470ea
            margin_right: 30});
Packit 1470ea
Packit 1470ea
        // Create the second switch
Packit 1470ea
        this._birdSwitch = new Gtk.Switch ({active: false});
Packit 1470ea
        this._birdSwitch.connect ('notify::active', this._switchFlip.bind(this));
Packit 1470ea
Packit 1470ea
        // Create a grid for the labels and switches beneath the picture
Packit 1470ea
        this._UIGrid = new Gtk.Grid ({
Packit 1470ea
            halign: Gtk.Align.CENTER,
Packit 1470ea
            valign: Gtk.Align.CENTER,
Packit 1470ea
            margin_top: 20});
Packit 1470ea
Packit 1470ea
        // Attach the labels and switches to that grid
Packit 1470ea
        this._UIGrid.attach (this._flyLabel, 0, 0, 1, 1);
Packit 1470ea
        this._UIGrid.attach (this._flySwitch, 1, 0, 1, 1);
Packit 1470ea
        this._UIGrid.attach (this._birdLabel, 0, 1, 1, 1);
Packit 1470ea
        this._UIGrid.attach (this._birdSwitch, 1, 1, 1, 1);
Packit 1470ea
Packit 1470ea
        // Create a master grid to put both the UI and the picture into
Packit 1470ea
        this._mainGrid = new Gtk.Grid ({
Packit 1470ea
            halign: Gtk.Align.CENTER,
Packit 1470ea
            valign: Gtk.Align.CENTER });
Packit 1470ea
Packit 1470ea
        // Attach the picture and the UI grid to the master grid
Packit 1470ea
        this._mainGrid.attach (this._image, 0, 0, 1, 1);
Packit 1470ea
        this._mainGrid.attach (this._UIGrid, 0, 1, 1, 1);
Packit 1470ea
Packit 1470ea
        // Add the master grid to the window
Packit 1470ea
        this._window.add (this._mainGrid);
Packit 1470ea
Packit 1470ea
        // Show the window and all child widgets
Packit 1470ea
        this._window.show_all();
Packit 1470ea
    }
Packit 1470ea
Packit 1470ea
    _switchFlip() {
Packit 1470ea
Packit 1470ea
        // Change the picture depending on which switches are flipped
Packit 1470ea
        if (this._flySwitch.get_active()) {
Packit 1470ea
Packit 1470ea
            if (this._birdSwitch.get_active())
Packit 1470ea
                this._image.set_from_file ("muteswan.png");
Packit 1470ea
            else
Packit 1470ea
                this._image.set_from_file ("fruitbat.png");
Packit 1470ea
        } else {
Packit 1470ea
Packit 1470ea
            if (this._birdSwitch.get_active())
Packit 1470ea
                this._image.set_from_file ("gentoopenguin.png");
Packit 1470ea
            else
Packit 1470ea
                this._image.set_from_file ("redfox.png");
Packit 1470ea
        }
Packit 1470ea
    }
Packit 1470ea
Packit 1470ea
    _initMenus() {
Packit 1470ea
Packit 1470ea
        // Build the application's menu so we can have an "About" button
Packit 1470ea
        let menu = new Gio.Menu();
Packit 1470ea
        menu.append("About", 'app.about');
Packit 1470ea
        menu.append("Quit",'app.quit');
Packit 1470ea
        this.application.set_app_menu(menu);
Packit 1470ea
Packit 1470ea
        // Bind the "About" button to the _showAbout() function
Packit 1470ea
        let aboutAction = new Gio.SimpleAction ({ name: 'about' });
Packit 1470ea
        aboutAction.connect('activate', () => { this._showAbout(); });
Packit 1470ea
        this.application.add_action(aboutAction);
Packit 1470ea
Packit 1470ea
        // Bind the "Quit" button to the function that closes the window
Packit 1470ea
        let quitAction = new Gio.SimpleAction ({ name: 'quit' });
Packit 1470ea
        quitAction.connect('activate', () => { this._window.destroy(); });
Packit 1470ea
        this.application.add_action(quitAction);
Packit 1470ea
    }
Packit 1470ea
Packit 1470ea
    _showAbout() {
Packit 1470ea
Packit 1470ea
        // String arrays of the names of the people involved in the project
Packit 1470ea
        var artists = ['Rob Lee http://en.wikipedia.org/wiki/File:Fuzzy_Freddy.png', 'Ken Funakoshi http://en.wikipedia.org/wiki/File:Pygoscelis_papua_-Nagasaki_Penguin_Aquarium_-swimming_underwater-8a.png', 'Shek Graham http://www.flickr.com/photos/shekgraham/127431519/in/photostream/', 'Mindaugas Urbonas http://commons.wikimedia.org/wiki/File:Mute_Swan-Mindaugas_Urbonas.png'];
Packit 1470ea
        var authors = ["GNOME Documentation Team"];
Packit 1470ea
        var documenters = ["GNOME Documentation Team"];
Packit 1470ea
Packit 1470ea
        // Create the About dialog
Packit 1470ea
        let aboutDialog = new Gtk.AboutDialog({
Packit 1470ea
            title: "AboutDialog Example",
Packit 1470ea
            program_name: "Animal Creator",
Packit 1470ea
            copyright: "Copyright \xa9 2012 GNOME Documentation Team\n\nRed fox photo licensed CC-By by Rob Lee\nGentoo penguin photo licensed CC-By-SA by Ken Funakoshi\nFruit bat photo licensed CC-By by Shek Graham\nMute swan photo licensed CC-By-SA by Mindaugas Urbonas\nLinks to the originals are available under Credits.\n\nHave you hugged a penguin today?",
Packit 1470ea
            artists: artists,
Packit 1470ea
            authors: authors,
Packit 1470ea
            documenters: documenters,
Packit 1470ea
            website: "http://developer.gnome.org",
Packit 1470ea
            website_label: "GNOME Developer Website" });
Packit 1470ea
Packit 1470ea
        // Attach the About dialog to the window
Packit 1470ea
        aboutDialog.modal = true;
Packit 1470ea
        aboutDialog.transient_for = this._window;
Packit 1470ea
Packit 1470ea
        // Show the About dialog
Packit 1470ea
        aboutDialog.show();
Packit 1470ea
Packit 1470ea
        // Connect the Close button to the destroy signal for the dialog
Packit 1470ea
        aboutDialog.connect('response', function() {
Packit 1470ea
            aboutDialog.destroy();
Packit 1470ea
        });
Packit 1470ea
    }
Packit 1470ea
};
Packit 1470ea
Packit 1470ea
// Run the application
Packit 1470ea
let app = new SwitchExample ();
Packit 1470ea
app.application.run (ARGV);
Packit 1470ea
Packit 1470ea
  </section>
Packit 1470ea
Packit 1470ea
  <section id="in-depth">
Packit 1470ea
    <title>In-depth documentation</title>
Packit 1470ea
<list>
Packit 1470ea
  <item>

<link href="http://developer.gnome.org/gio/unstable/GMenu.html">GMenu</link>

</item>
Packit 1470ea
  <item>

<link href="http://developer.gnome.org/gio/stable/GSimpleAction.html">GSimpleAction</link>

</item>
Packit 1470ea
  <item>

<link href="http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gtk.Application.html">Gtk.Application</link>

</item>
Packit 1470ea
  <item>

<link href="http://developer.gnome.org/gtk3/stable/GtkApplicationWindow.html">Gtk.ApplicationWindow</link>

</item>
Packit 1470ea
  <item>

<link href="http://www.roojs.org/seed/gir-1.2-gtk-3.0/gjs/Gtk.Grid.html">Gtk.Grid</link>

</item>
Packit 1470ea
  <item>

<link href="http://www.roojs.org/seed/gir-1.2-gtk-3.0/gjs/Gtk.Image.html">Gtk.Image</link>

</item>
Packit 1470ea
  <item>

<link href="http://www.roojs.org/seed/gir-1.2-gtk-3.0/gjs/Gtk.Label.html">Gtk.Label</link>

</item>
Packit 1470ea
  <item>

<link href="http://www.roojs.org/seed/gir-1.2-gtk-3.0/gjs/Gtk.Switch.html">Gtk.Switch</link>

</item>
Packit 1470ea
</list>
Packit 1470ea
  </section>
Packit 1470ea
</page>