Blame platform-overview/C/tour-get_object.page

Packit 1470ea
Packit 1470ea
      xmlns:its="http://www.w3.org/2005/11/its"
Packit 1470ea
      type="topic" style="task"
Packit 1470ea
      id="tour-get_object">
Packit 1470ea
Packit 1470ea
  <info>
Packit 1470ea
    <link type="next" xref="tour-application"/>
Packit 1470ea
    <revision version="0.1" date="2013-06-17" status="stub"/>
Packit 1470ea
Packit 1470ea
    <credit type="author copyright">
Packit 1470ea
      <name>Ekaterina Gerasimova</name>
Packit 1470ea
      <email its:translate="no">kittykat3756@gmail.com</email>
Packit 1470ea
      <years>2013</years>
Packit 1470ea
    </credit>
Packit 1470ea
    <credit type="author copyright">
Packit 1470ea
      <name>Gordon Hill</name>
Packit 1470ea
      <email its:translate="no">caseyweederman@gmail.com</email>
Packit 1470ea
      <years>2013</years>
Packit 1470ea
    </credit>
Packit 1470ea
Packit 1470ea
    <include href="cc-by-sa-3-0.xml" xmlns="http://www.w3.org/2001/XInclude"/>
Packit 1470ea
Packit 1470ea
    <desc>Add the window specified in the UI file to the application using
Packit 1470ea
    GtkBuilder.</desc>
Packit 1470ea
  </info>
Packit 1470ea
Packit 1470ea
  <title>GtkBuilder</title>
Packit 1470ea
  <links type="prevnext" style="top"/>
Packit 1470ea
  <links type="series" style="floatend">
Packit 1470ea
    <title>Get started with GNOME</title>
Packit 1470ea
  </links>
Packit 1470ea
Packit 1470ea
  

GtkBuilder accepts UI descriptions and turns them into Gtk applications.

Packit 1470ea
  In this case, the UI description is in the file <file>helloworld.glade</file>
Packit 1470ea
  and can be read by the get_object() method.

Packit 1470ea
Packit 1470ea
  <example>
Packit 1470ea
    

Load the UI file using GtkBuilder and get the window object

Packit 1470ea
    using the <gui>Name</gui> (or <gui>ID</gui>) chosen in Glade, and add the
Packit 1470ea
    window object to the application:

Packit 1470ea
Packit 1470ea
    
Packit 1470ea
    _onStartup() {
Packit 1470ea
        let builder = new Gtk.Builder();
Packit 1470ea
        builder.add_from_file('helloworld.glade');
Packit 1470ea
        this._window = builder.get_object('window1');
Packit 1470ea
        this.application.add_window(this._window);
Packit 1470ea
    }
Packit 1470ea
};
Packit 1470ea
]]>
Packit 1470ea
  </example>
Packit 1470ea
  <links type="prevnext"/>
Packit 1470ea
</page>